max_stars_repo_path
stringlengths 4
237
| max_stars_repo_name
stringlengths 6
117
| max_stars_count
int64 0
95.2k
| id
stringlengths 1
7
| content
stringlengths 12
593k
| input_ids
sequencelengths 7
549k
|
---|---|---|---|---|---|
smapy/utils.py | pvk-developer/smapy | 3 | 154718 | # -*- coding: utf-8 -*-
import configparser
import copy
import importlib
import os
import pkgutil
from collections import defaultdict
def find_subclasses(parent_class, recursive=False):
"""Find the subclasses of a given parent class."""
subclasses = parent_class.__subclasses__()
if recursive:
for i in range(0, len(subclasses)):
temp = find_subclasses(subclasses[i])
if temp:
subclasses.extend(temp)
return subclasses
def recursivedict():
return defaultdict(recursivedict)
def read_conf(conf_file):
conf = configparser.ConfigParser(interpolation=None)
conf.optionxform = str # Prevent lowercase keys
if conf_file:
if not os.path.isfile(conf_file):
raise FileNotFoundError("File {} not found".format(conf_file))
conf.read(conf_file)
conf_dict = recursivedict()
for section, params in conf.items():
for key, value in params.items():
conf_dict[section][key] = eval(value)
return conf_dict
def setenv(conf):
for key, value in conf.items():
if key not in os.environ:
os.environ[key] = value
def get_bool(message, key, default=False):
if key not in message:
return default
value = message.get(key)
if not value:
return True
string = str(value).lower()
if string in ['true', 'yes', 'y', '1']:
return True
elif string in ['false', 'no', 'n', '0']:
return False
raise ValueError('Invalid boolean: {}'.format(string))
def sum_dicts(a, b):
"""Sum the values of the two dicts, no matter which type they are.
>>> sum_dicts({}, {})
{}
>>> sum_dicts({'a': 1}, {'a': 2})
{'a': 3}
>>> sum_dicts({'a': [1]}, {'a': [2], 'b': 3})
{'b': 3, 'a': [1, 2]}
>>> sum_dicts({'a': 1, 'b': 2, 'c': [1]}, {'b': 3, 'c': [4], 'd': [5]})
{'c': [1, 4], 'b': 5, 'd': [5], 'a': 1}
"""
merged = dict()
if a is None or b is None:
return a if a else b or {}
for key in set(a) | set(b):
value_a = a.get(key, type(b.get(key))())
value_b = b.get(key, type(a.get(key))())
if isinstance(value_a, dict) and isinstance(value_b, dict):
merged[key] = sum_dicts(value_a, value_b)
else:
merged[key] = value_a + value_b
return merged
def safecopy(obj):
# if isinstance(obj, dict):
# clone = dict()
# for key, value in obj.items():
# clone[key] = safecopy(value)
# return clone
# elif isinstance(obj, bs4.BeautifulSoup):
# return str(obj)
return copy.deepcopy(obj)
def get_ms(delta):
"""Convert a datetime.timedelta into the corresponding milliseconds.
>>> from datetime import timedelta
>>> get_ms(timedelta(1, 1, 1, 1))
86401001.001
>>> get_ms(timedelta(days=1))
86400000.0
>>> get_ms(timedelta(seconds=15))
15000.0
>>> get_ms(timedelta(milliseconds=15, microseconds=222))
15.222
"""
return delta.days * 24 * 60 * 60 * 1000 + delta.seconds * 1000 + delta.microseconds / 1000
def find_submodules(package):
if isinstance(package, str):
package = importlib.import_module(package)
submodules = list()
# Otherwise it is not a package but a module
if hasattr(package, '__path__'):
for _, name, __ in pkgutil.iter_modules(package.__path__):
full_name = package.__name__ + '.' + name
module = importlib.import_module(full_name)
submodules.append(module)
return submodules
| [
1,
396,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
5215,
2295,
16680,
13,
5215,
3509,
13,
5215,
1053,
1982,
13,
5215,
2897,
13,
5215,
282,
9415,
4422,
13,
3166,
16250,
1053,
2322,
8977,
13,
13,
13,
1753,
1284,
29918,
1491,
13203,
29898,
3560,
29918,
1990,
29892,
16732,
29922,
8824,
1125,
13,
1678,
9995,
12542,
278,
1014,
13203,
310,
263,
2183,
3847,
770,
1213,
15945,
13,
1678,
1014,
13203,
353,
3847,
29918,
1990,
17255,
1491,
13203,
1649,
580,
13,
13,
1678,
565,
16732,
29901,
13,
4706,
363,
474,
297,
3464,
29898,
29900,
29892,
7431,
29898,
1491,
13203,
22164,
13,
9651,
5694,
353,
1284,
29918,
1491,
13203,
29898,
1491,
13203,
29961,
29875,
2314,
13,
9651,
565,
5694,
29901,
13,
18884,
1014,
13203,
29889,
21843,
29898,
7382,
29897,
13,
13,
1678,
736,
1014,
13203,
13,
13,
13,
1753,
8304,
2347,
919,
7295,
13,
1678,
736,
2322,
8977,
29898,
3757,
1295,
2347,
919,
29897,
13,
13,
13,
1753,
1303,
29918,
5527,
29898,
5527,
29918,
1445,
1125,
13,
1678,
1970,
353,
2295,
16680,
29889,
3991,
11726,
29898,
1639,
3733,
362,
29922,
8516,
29897,
13,
1678,
1970,
29889,
3385,
29916,
689,
353,
851,
1678,
396,
4721,
794,
5224,
4878,
6611,
13,
13,
1678,
565,
1970,
29918,
1445,
29901,
13,
4706,
565,
451,
2897,
29889,
2084,
29889,
275,
1445,
29898,
5527,
29918,
1445,
1125,
13,
9651,
12020,
3497,
17413,
2392,
703,
2283,
6571,
451,
1476,
1642,
4830,
29898,
5527,
29918,
1445,
876,
13,
13,
4706,
1970,
29889,
949,
29898,
5527,
29918,
1445,
29897,
13,
13,
1678,
1970,
29918,
8977,
353,
8304,
2347,
919,
580,
13,
13,
1678,
363,
4004,
29892,
8636,
297,
1970,
29889,
7076,
7295,
13,
4706,
363,
1820,
29892,
995,
297,
8636,
29889,
7076,
7295,
13,
9651,
1970,
29918,
8977,
29961,
2042,
3816,
1989,
29962,
353,
19745,
29898,
1767,
29897,
13,
13,
1678,
736,
1970,
29918,
8977,
13,
13,
13,
1753,
731,
6272,
29898,
5527,
1125,
13,
1678,
363,
1820,
29892,
995,
297,
1970,
29889,
7076,
7295,
13,
4706,
565,
1820,
451,
297,
2897,
29889,
21813,
29901,
13,
9651,
2897,
29889,
21813,
29961,
1989,
29962,
353,
995,
13,
13,
13,
1753,
679,
29918,
11227,
29898,
4906,
29892,
1820,
29892,
2322,
29922,
8824,
1125,
13,
1678,
565,
1820,
451,
297,
2643,
29901,
13,
4706,
736,
2322,
13,
13,
1678,
995,
353,
2643,
29889,
657,
29898,
1989,
29897,
13,
1678,
565,
451,
995,
29901,
13,
4706,
736,
5852,
13,
13,
1678,
1347,
353,
851,
29898,
1767,
467,
13609,
580,
13,
1678,
565,
1347,
297,
6024,
3009,
742,
525,
3582,
742,
525,
29891,
742,
525,
29896,
2033,
29901,
13,
4706,
736,
5852,
13,
13,
1678,
25342,
1347,
297,
6024,
4541,
742,
525,
1217,
742,
525,
29876,
742,
525,
29900,
2033,
29901,
13,
4706,
736,
7700,
13,
13,
1678,
12020,
7865,
2392,
877,
13919,
7223,
29901,
6571,
4286,
4830,
29898,
1807,
876,
13,
13,
13,
1753,
2533,
29918,
8977,
29879,
29898,
29874,
29892,
289,
1125,
13,
1678,
9995,
11139,
278,
1819,
310,
278,
1023,
9657,
29879,
29892,
694,
4383,
607,
1134,
896,
526,
29889,
13,
13,
1678,
8653,
2533,
29918,
8977,
29879,
3319,
1118,
426,
1800,
13,
1678,
6571,
13,
1678,
8653,
2533,
29918,
8977,
29879,
3319,
29915,
29874,
2396,
29871,
29896,
1118,
11117,
29874,
2396,
29871,
29906,
1800,
13,
1678,
11117,
29874,
2396,
29871,
29941,
29913,
13,
1678,
8653,
2533,
29918,
8977,
29879,
3319,
29915,
29874,
2396,
518,
29896,
29962,
1118,
11117,
29874,
2396,
518,
29906,
1402,
525,
29890,
2396,
29871,
29941,
1800,
13,
1678,
11117,
29890,
2396,
29871,
29941,
29892,
525,
29874,
2396,
518,
29896,
29892,
29871,
29906,
12258,
13,
1678,
8653,
2533,
29918,
8977,
29879,
3319,
29915,
29874,
2396,
29871,
29896,
29892,
525,
29890,
2396,
29871,
29906,
29892,
525,
29883,
2396,
518,
29896,
29962,
1118,
11117,
29890,
2396,
29871,
29941,
29892,
525,
29883,
2396,
518,
29946,
1402,
525,
29881,
2396,
518,
29945,
29962,
1800,
13,
1678,
11117,
29883,
2396,
518,
29896,
29892,
29871,
29946,
1402,
525,
29890,
2396,
29871,
29945,
29892,
525,
29881,
2396,
518,
29945,
1402,
525,
29874,
2396,
29871,
29896,
29913,
13,
1678,
9995,
13,
13,
1678,
19412,
353,
9657,
580,
13,
1678,
565,
263,
338,
6213,
470,
289,
338,
6213,
29901,
13,
4706,
736,
263,
565,
263,
1683,
289,
470,
6571,
13,
13,
1678,
363,
1820,
297,
731,
29898,
29874,
29897,
891,
731,
29898,
29890,
1125,
13,
4706,
995,
29918,
29874,
353,
263,
29889,
657,
29898,
1989,
29892,
1134,
29898,
29890,
29889,
657,
29898,
1989,
876,
3101,
13,
4706,
995,
29918,
29890,
353,
289,
29889,
657,
29898,
1989,
29892,
1134,
29898,
29874,
29889,
657,
29898,
1989,
876,
3101,
13,
4706,
565,
338,
8758,
29898,
1767,
29918,
29874,
29892,
9657,
29897,
322,
338,
8758,
29898,
1767,
29918,
29890,
29892,
9657,
1125,
13,
9651,
19412,
29961,
1989,
29962,
353,
2533,
29918,
8977,
29879,
29898,
1767,
29918,
29874,
29892,
995,
29918,
29890,
29897,
13,
13,
4706,
1683,
29901,
13,
9651,
19412,
29961,
1989,
29962,
353,
995,
29918,
29874,
718,
995,
29918,
29890,
13,
13,
1678,
736,
19412,
13,
13,
13,
1753,
9437,
687,
2270,
29898,
5415,
1125,
13,
1678,
396,
565,
338,
8758,
29898,
5415,
29892,
9657,
1125,
13,
1678,
396,
268,
17432,
353,
9657,
580,
13,
1678,
396,
268,
363,
1820,
29892,
995,
297,
5446,
29889,
7076,
7295,
13,
1678,
396,
308,
17432,
29961,
1989,
29962,
353,
9437,
687,
2270,
29898,
1767,
29897,
13,
13,
1678,
396,
268,
736,
17432,
13,
13,
1678,
396,
25342,
338,
8758,
29898,
5415,
29892,
24512,
29946,
29889,
3629,
1300,
6845,
29903,
1132,
1125,
13,
1678,
396,
268,
736,
851,
29898,
5415,
29897,
13,
13,
1678,
736,
3509,
29889,
24535,
8552,
29898,
5415,
29897,
13,
13,
13,
1753,
679,
29918,
1516,
29898,
4181,
1125,
13,
1678,
9995,
18455,
263,
12865,
29889,
9346,
287,
2554,
964,
278,
6590,
3533,
21462,
29889,
13,
13,
1678,
8653,
515,
12865,
1053,
5335,
287,
2554,
13,
1678,
8653,
679,
29918,
1516,
29898,
9346,
287,
2554,
29898,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
876,
13,
268,
29947,
29953,
29946,
29900,
29896,
29900,
29900,
29896,
29889,
29900,
29900,
29896,
13,
1678,
8653,
679,
29918,
1516,
29898,
9346,
287,
2554,
29898,
16700,
29922,
29896,
876,
13,
268,
29947,
29953,
29946,
29900,
29900,
29900,
29900,
29900,
29889,
29900,
13,
1678,
8653,
679,
29918,
1516,
29898,
9346,
287,
2554,
29898,
23128,
29922,
29896,
29945,
876,
13,
268,
29896,
29945,
29900,
29900,
29900,
29889,
29900,
13,
1678,
8653,
679,
29918,
1516,
29898,
9346,
287,
2554,
29898,
19958,
21462,
29922,
29896,
29945,
29892,
9200,
23128,
29922,
29906,
29906,
29906,
876,
13,
268,
29896,
29945,
29889,
29906,
29906,
29906,
13,
1678,
9995,
13,
1678,
736,
19471,
29889,
16700,
334,
29871,
29906,
29946,
334,
29871,
29953,
29900,
334,
29871,
29953,
29900,
334,
29871,
29896,
29900,
29900,
29900,
718,
19471,
29889,
23128,
334,
29871,
29896,
29900,
29900,
29900,
718,
19471,
29889,
29885,
2357,
23128,
847,
29871,
29896,
29900,
29900,
29900,
13,
13,
13,
1753,
1284,
29918,
1491,
7576,
29898,
5113,
1125,
13,
1678,
565,
338,
8758,
29898,
5113,
29892,
851,
1125,
13,
4706,
3577,
353,
1053,
1982,
29889,
5215,
29918,
5453,
29898,
5113,
29897,
13,
13,
1678,
1014,
7576,
353,
1051,
580,
13,
13,
1678,
396,
13466,
372,
338,
451,
263,
3577,
541,
263,
3883,
13,
1678,
565,
756,
5552,
29898,
5113,
29892,
525,
1649,
2084,
1649,
29374,
13,
4706,
363,
17117,
1024,
29892,
4770,
297,
282,
9415,
4422,
29889,
1524,
29918,
7576,
29898,
5113,
17255,
2084,
1649,
1125,
13,
9651,
2989,
29918,
978,
353,
3577,
17255,
978,
1649,
718,
525,
6169,
718,
1024,
13,
9651,
3883,
353,
1053,
1982,
29889,
5215,
29918,
5453,
29898,
8159,
29918,
978,
29897,
13,
9651,
1014,
7576,
29889,
4397,
29898,
5453,
29897,
13,
13,
1678,
736,
1014,
7576,
13,
2
] |
handlers/play.py | Gautampro1834/Telegram_Vc_Bot | 0 | 192982 | <reponame>Gautampro1834/Telegram_Vc_Bot
from os import path
from typing import Dict
from pyrogram import Client
from pyrogram.types import Message, Voice
from typing import Callable, Coroutine, Dict, List, Tuple, Union
from callsmusic import callsmusic, queues
from helpers.admins import get_administrators
from os import path
import requests
import aiohttp
import youtube_dl
from youtube_search import YoutubeSearch
from pyrogram import filters, emoji
from pyrogram.types import InputMediaPhoto
from pyrogram.errors.exceptions.bad_request_400 import ChatAdminRequired
from pyrogram.errors.exceptions.flood_420 import FloodWait
import traceback
import os
import sys
from callsmusic.callsmusic import client as USER
from pyrogram.errors import UserAlreadyParticipant
import converter
from downloaders import youtube
from config import BOT_NAME as bn, DURATION_LIMIT
from helpers.filters import command, other_filters
from helpers.decorators import errors, authorized_users_only
from helpers.errors import DurationLimitError
from helpers.gets import get_url, get_file_name
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from cache.admins import admins as a
import os
import aiohttp
import aiofiles
import ffmpeg
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from config import que
from Python_ARQ import ARQ
from pyrogram.errors import UserNotParticipant
import json
import wget
chat_id = None
JOIN_ASAP = "You need to Join @GautamS_Mirror for using me :/"
def cb_admin_check(func: Callable) -> Callable:
async def decorator(client, cb):
admemes = a.get(cb.message.chat.id)
if cb.from_user.id in admemes:
return await func(client, cb)
else:
await cb.answer('You ain\'t allowed!', show_alert=True)
return
return decorator
def transcode(filename):
ffmpeg.input(filename).output("input.raw", format='s16le', acodec='pcm_s16le', ac=2, ar='48k').overwrite_output().run()
os.remove(filename)
# Convert seconds to mm:ss
def convert_seconds(seconds):
seconds = seconds % (24 * 3600)
seconds %= 3600
minutes = seconds // 60
seconds %= 60
return "%02d:%02d" % (minutes, seconds)
# Convert hh:mm:ss to seconds
def time_to_seconds(time):
stringt = str(time)
return sum(int(x) * 60 ** i for i, x in enumerate(reversed(stringt.split(':'))))
# Change image size
def changeImageSize(maxWidth, maxHeight, image):
widthRatio = maxWidth / image.size[0]
heightRatio = maxHeight / image.size[1]
newWidth = int(widthRatio * image.size[0])
newHeight = int(heightRatio * image.size[1])
newImage = image.resize((newWidth, newHeight))
return newImage
async def generate_cover(requested_by, title, views, duration, thumbnail):
async with aiohttp.ClientSession() as session:
async with session.get(thumbnail) as resp:
if resp.status == 200:
f = await aiofiles.open("background.png", mode="wb")
await f.write(await resp.read())
await f.close()
image1 = Image.open("./background.png")
image2 = Image.open("etc/foreground.png")
image3 = changeImageSize(1280, 720, image1)
image4 = changeImageSize(1280, 720, image2)
image5 = image3.convert("RGBA")
image6 = image4.convert("RGBA")
Image.alpha_composite(image5, image6).save("temp.png")
img = Image.open("temp.png")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("etc/font.otf", 32)
draw.text((205, 550), f"Title: {title}", (51, 215, 255), font=font)
draw.text(
(205, 590), f"Duration: {duration}", (255, 255, 255), font=font
)
draw.text((205, 630), f"Views: {views}", (255, 255, 255), font=font)
draw.text((205, 670),
f"Added By: {requested_by}",
(255, 255, 255),
font=font,
)
img.save("final.png")
os.remove("temp.png")
os.remove("background.png")
@Client.on_message(
filters.command("playlist")
& filters.group
& ~ filters.edited
)
async def playlist(client, message):
try:
await message._client.get_chat_member(int("-1001292906791"), message.from_user.id)
except UserNotParticipant:
await message.reply_text(JOIN_ASAP)
return
global que
queue = que.get(message.chat.id)
if not queue:
await message.reply_text('Player is idle')
temp = []
for t in queue:
temp.append(t)
now_playing = temp[0][0]
by = temp[0][1].mention(style='md')
msg = "**Now Playing** in {}".format(message.chat.title)
msg += "\n"+ now_playing
msg += "\n- Req by "+by
temp.pop(0)
if temp:
msg += '\n\n'
msg += '**Queue**'
for song in temp:
name = song[0]
usr = song[1].mention(style='md')
msg += f'\n- {name}'
msg += f'\n- Req by {usr}\n'
await message.reply_text(msg)
# ============================= Settings =========================================
def updated_stats(chat, queue, vol=100):
if chat.id in callsmusic.pytgcalls.active_calls:
#if chat.id in active_chats:
stats = 'Settings of **{}**'.format(chat.title)
if len(que) > 0:
stats += '\n\n'
stats += 'Volume : {}%\n'.format(vol)
stats += 'Songs in queue : `{}`\n'.format(len(que))
stats += 'Now Playing : **{}**\n'.format(queue[0][0])
stats += 'Requested by : {}'.format(queue[0][1].mention)
else:
stats = None
return stats
def r_ply(type_):
if type_ == 'play':
ico = '▶'
else:
ico = '⏸'
mar = InlineKeyboardMarkup(
[
[
InlineKeyboardButton('⏹', 'leave'),
InlineKeyboardButton('⏸', 'puse'),
InlineKeyboardButton('▶️', 'resume'),
InlineKeyboardButton('⏭', 'skip')
],
[
InlineKeyboardButton('Playlist 📖', 'playlist'),
],
[
InlineKeyboardButton("❌ Close",'cls')
]
]
)
return mar
@Client.on_message(
filters.command("current")
& filters.group
& ~ filters.edited
)
async def ee(client, message):
try:
await message._client.get_chat_member(int("-1001292906791"), message.from_user.id)
except UserNotParticipant:
await message.reply_text(JOIN_ASAP)
return
queue = que.get(message.chat.id)
stats = updated_stats(message.chat, queue)
if stats:
await message.reply(stats)
else:
await message.reply('No VoiceChat instances running in this chat')
@Client.on_message(
filters.command("player")
& filters.group
& ~ filters.edited
)
@authorized_users_only
async def settings(client, message):
try:
await message._client.get_chat_member(int("-1001292906791"), message.from_user.id)
except UserNotParticipant:
await message.reply_text(JOIN_ASAP)
return
playing = None
if message.chat.id in callsmusic.pytgcalls.active_calls:
playing = True
queue = que.get(message.chat.id)
stats = updated_stats(message.chat, queue)
if stats:
if playing:
await message.reply(stats, reply_markup=r_ply('pause'))
else:
await message.reply(stats, reply_markup=r_ply('play'))
else:
await message.reply('No VC instances running in this chat')
@Client.on_callback_query(filters.regex(pattern=r'^(playlist)$'))
@Client.on_callback_query(filters.regex(pattern=r'^(playlist)$'))
async def p_cb(b, cb):
global que
qeue = que.get(cb.message.chat.id)
type_ = cb.matches[0].group(1)
chat_id = cb.message.chat.id
m_chat = cb.message.chat
the_data = cb.message.reply_markup.inline_keyboard[1][0].callback_data
if type_ == 'playlist':
queue = que.get(cb.message.chat.id)
if not queue:
await cb.message.edit('Player is idle')
temp = []
for t in queue:
temp.append(t)
now_playing = temp[0][0]
by = temp[0][1].mention(style='md')
msg = "**Now Playing** in {}".format(cb.message.chat.title)
msg += "\n- "+ now_playing
msg += "\n- Req by "+by
temp.pop(0)
if temp:
msg += '\n\n'
msg += '**Queue**'
for song in temp:
name = song[0]
usr = song[1].mention(style='md')
msg += f'\n- {name}'
msg += f'\n- Req by {usr}\n'
await cb.message.edit(msg)
@Client.on_callback_query(filters.regex(pattern=r'^(play|pause|skip|leave|puse|resume|menu|cls)$'))
@cb_admin_check
async def m_cb(b, cb):
global que
qeue = que.get(cb.message.chat.id)
type_ = cb.matches[0].group(1)
chat_id = cb.message.chat.id
m_chat = cb.message.chat
the_data = cb.message.reply_markup.inline_keyboard[1][0].callback_data
if type_ == 'pause':
if (
chat_id not in callsmusic.pytgcalls.active_calls
) or (
callsmusic.pytgcalls.active_calls[chat_id] == 'paused'
):
await cb.answer('Chat is not connected!', show_alert=True)
else:
callsmusic.pytgcalls.pause_stream(chat_id)
await cb.answer('Music Paused!')
await cb.message.edit(updated_stats(m_chat, qeue), reply_markup=r_ply('play'))
elif type_ == 'play':
if (
chat_id not in callsmusic.pytgcalls.active_calls
) or (
callsmusic.pytgcalls.active_calls[chat_id] == 'playing'
):
await cb.answer('Chat is not connected!', show_alert=True)
else:
callsmusic.pytgcalls.resume_stream(chat_id)
await cb.answer('Music Resumed!')
await cb.message.edit(updated_stats(m_chat, qeue), reply_markup=r_ply('pause'))
elif type_ == 'playlist':
queue = que.get(cb.message.chat.id)
if not queue:
await cb.message.edit('Player is idle')
temp = []
for t in queue:
temp.append(t)
now_playing = temp[0][0]
by = temp[0][1].mention(style='md')
msg = "**Now Playing** in {}".format(cb.message.chat.title)
msg += "\n- "+ now_playing
msg += "\n- Req by "+by
temp.pop(0)
if temp:
msg += '\n\n'
msg += '**Queue**'
for song in temp:
name = song[0]
usr = song[1].mention(style='md')
msg += f'\n- {name}'
msg += f'\n- Req by {usr}\n'
await cb.message.edit(msg)
elif type_ == 'resume':
if (
chat_id not in callsmusic.pytgcalls.active_calls
) or (
callsmusic.pytgcalls.active_calls[chat_id] == 'playing'
):
await cb.answer('Chat is not connected or already playng', show_alert=True)
else:
callsmusic.pytgcalls.resume_stream(chat_id)
await cb.answer('Music Resumed!')
elif type_ == 'puse':
if (
chat_id not in callsmusic.pytgcalls.active_calls
) or (
callsmusic.pytgcalls.active_calls[chat_id] == 'paused'
):
await cb.answer('Chat is not connected or already paused', show_alert=True)
else:
callsmusic.pytgcalls.pause_stream(chat_id)
await cb.answer('Music Paused!')
elif type_ == 'cls':
await cb.answer('Closed menu')
await cb.message.delete()
elif type_ == 'menu':
stats = updated_stats(cb.message.chat, qeue)
await cb.answer('Menu opened')
marr = InlineKeyboardMarkup(
[
[
InlineKeyboardButton('⏹', 'leave'),
InlineKeyboardButton('⏸', 'puse'),
InlineKeyboardButton('▶️', 'resume'),
InlineKeyboardButton('⏭', 'skip')
],
[
InlineKeyboardButton('Playlist 📖', 'playlist'),
],
[
InlineKeyboardButton("❌ Close",'cls')
]
]
)
await cb.message.edit(stats, reply_markup=marr)
elif type_ == 'skip':
if qeue:
skip = qeue.pop(0)
if chat_id not in callsmusic.pytgcalls.active_calls:
await cb.answer('Chat is not connected!', show_alert=True)
else:
callsmusic.queues.task_done(chat_id)
if callsmusic.queues.is_empty(chat_id):
callsmusic.pytgcalls.leave_group_call(chat_id)
await cb.message.edit('- No More Playlist..\n- Leaving VC!')
else:
callsmusic.pytgcalls.change_stream(
chat_id,
callsmusic.queues.get(chat_id)["file"]
)
await cb.answer('Skipped')
await cb.message.edit((m_chat, qeue), reply_markup=r_ply(the_data))
await cb.message.reply_text(f'- Skipped track\n- Now Playing **{qeue[0][0]}**')
else:
if chat_id in callsmusic.pytgcalls.active_calls:
try:
callsmusic.queues.clear(chat_id)
except QueueEmpty:
pass
callsmusic.pytgcalls.leave_group_call(chat_id)
await cb.message.edit('Successfully Left the Chat!')
else:
await cb.answer('Chat is not connected!', show_alert=True)
@Client.on_message(command("play") & other_filters)
async def play(_, message: Message):
try:
await message._client.get_chat_member(int("-1001292906791"), message.from_user.id)
except UserNotParticipant:
await message.reply_text(JOIN_ASAP)
return
global que
lel = await message.reply("🔄 **Processing**")
administrators = await get_administrators(message.chat)
chid = message.chat.id
try:
user = await USER.get_me()
except:
user.first_name = "helper"
usar = user
wew = usar.id
try:
#chatdetails = await USER.get_chat(chid)
lmoa = await _.get_chat_member(chid,wew)
except:
for administrator in administrators:
if administrator == message.from_user.id:
try:
invitelink = await _.export_chat_invite_link(chid)
except:
await lel.edit(
"<b>Add me as admin of yor group first</b>",
)
return
try:
await USER.join_chat(invitelink)
await USER.send_message(message.chat.id,"I joined this group for playing music in VC")
await lel.edit(
"<b>helper userbot joined your chat</b>",
)
except UserAlreadyParticipant:
pass
except Exception as e:
#print(e)
await lel.edit(
f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your group due to heavy requests for userbot! Make sure user is not banned in group."
"\n\nOr manually ask @Gautam180304 to your Group and try again</b>",
)
pass
try:
chatdetails = await USER.get_chat(chid)
#lmoa = await client.get_chat_member(chid,wew)
except:
await lel.edit(
f"<i> {user.first_name} Userbot not in this chat, Ask admin to send /play command for first time or add {user.first_name} manually</i>"
)
return
sender_id = message.from_user.id
sender_name = message.from_user.first_name
await lel.edit("**__Searching Your Song__**")
sender_id = message.from_user.id
user_id = message.from_user.id
sender_name = message.from_user.first_name
user_name = message.from_user.first_name
rpk = "["+user_name+"](tg://user?id="+str(user_id)+")"
query = ''
for i in message.command[1:]:
query += ' ' + str(i)
print(query)
await lel.edit("**__Processing Your Song__**")
ydl_opts = {"format": "bestaudio[ext=m4a]"}
try:
results = YoutubeSearch(query, max_results=1).to_dict()
url = f"https://youtube.com{results[0]['url_suffix']}"
#print(results)
title = results[0]["title"][:40]
thumbnail = results[0]["thumbnails"][0]
thumb_name = f'thumb{title}.jpg'
thumb = requests.get(thumbnail, allow_redirects=True)
open(thumb_name, 'wb').write(thumb.content)
duration = results[0]["duration"]
url_suffix = results[0]["url_suffix"]
views = results[0]["views"]
except Exception as e:
await lel.edit("Song not found.Try another song or maybe spell it properly.")
print(str(e))
return
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📖 Playlist', callback_data='playlist'),
InlineKeyboardButton('Menu ⏯ ', callback_data='menu')
],
[
InlineKeyboardButton(
text="Watch On YouTube 🎬",
url=f"{url}")
],
[
InlineKeyboardButton(
text="❌ Close",
callback_data='cls')
]
]
)
requested_by = message.from_user.first_name
await generate_cover(requested_by, title, views, duration, thumbnail)
file_path = await converter.convert(youtube.download(url))
if message.chat.id in callsmusic.pytgcalls.active_calls:
position = await queues.put(message.chat.id, file=file_path)
qeue = que.get(message.chat.id)
s_name = title
r_by = message.from_user
loc = file_path
appendable = [s_name, r_by, loc]
qeue.append(appendable)
await message.reply_photo(
photo="final.png",
caption=f"#⃣ Your requested song **queued** at position {position}!",
reply_markup=keyboard)
os.remove("final.png")
return await lel.delete()
else:
chat_id = message.chat.id
que[chat_id] = []
qeue = que.get(message.chat.id)
s_name = title
r_by = message.from_user
loc = file_path
appendable = [s_name, r_by, loc]
qeue.append(appendable)
callsmusic.pytgcalls.join_group_call(message.chat.id, file_path)
await message.reply_photo(
photo="final.png",
reply_markup=keyboard,
caption="▶️ **Playing** here the song requested by {} via Gautam'S Music Bot 😜".format(
message.from_user.mention()
),
)
os.remove("final.png")
return await lel.delete()
@Client.on_message(
filters.command("dplay")
& filters.group
& ~ filters.edited
)
async def deezer(client: Client, message_: Message):
try:
await message._client.get_chat_member(int("-1001292906791"), message.from_user.id)
except UserNotParticipant:
await message.reply_text(JOIN_ASAP)
return
global que
lel = await message_.reply("🔄 **Processing**")
administrators = await get_administrators(message_.chat)
chid = message_.chat.id
try:
user = await USER.get_me()
except:
user.first_name = "<NAME>"
usar = user
wew = usar.id
try:
#chatdetails = await USER.get_chat(chid)
lmoa = await client.get_chat_member(chid,wew)
except:
for administrator in administrators:
if administrator == message_.from_user.id:
try:
invitelink = await client.export_chat_invite_link(chid)
except:
await lel.edit(
"<b>Add me as admin of yor group first</b>",
)
return
try:
await USER.join_chat(invitelink)
await USER.send_message(message_.chat.id,"I joined this group for playing music in VC")
await lel.edit(
"<b>helper userbot joined your chat</b>",
)
except UserAlreadyParticipant:
pass
except Exception as e:
#print(e)
await lel.edit(
f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your group due to heavy requests for userbot! Make sure user is not banned in group."
"\n\nOr manually add @Gautam180304 to your Group and try again</b>",
)
pass
try:
chatdetails = await USER.get_chat(chid)
#lmoa = await client.get_chat_member(chid,wew)
except:
await lel.edit(
f"<i> {user.first_name} Userbot not in this chat, Ask admin to send /play command for first time or add {user.first_name} manually</i>"
)
return
requested_by = message_.from_user.first_name
text = message_.text.split(" ", 1)
queryy = text[1]
res = lel
await res.edit(f"Searching 👀👀👀 for `{queryy}` on deezer")
try:
arq = ARQ("https://thearq.tech")
r = await arq.deezer(query=queryy, limit=1)
title = r[0]["title"]
duration = int(r[0]["duration"])
thumbnail = r[0]["thumbnail"]
artist = r[0]["artist"]
url = r[0]["url"]
except:
await res.edit(
"Found Literally Nothing, You Should Work On Your English!"
)
is_playing = False
return
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📖 Playlist', callback_data='playlist'),
InlineKeyboardButton('Menu ⏯ ', callback_data='menu')
],
[
InlineKeyboardButton(
text="Listen On Deezer 🎬",
url=f"{url}")
],
[
InlineKeyboardButton(
text="❌ Close",
callback_data='cls')
]
]
)
file_path= await converter.convert(wget.download(url))
await res.edit("Generating Thumbnail")
await generate_cover(requested_by, title, artist, duration, thumbnail)
if message_.chat.id in callsmusic.pytgcalls.active_calls:
await res.edit("adding in queue")
position = await queues.put(message_.chat.id, file=file_path)
qeue = que.get(message_.chat.id)
s_name = title
r_by = message_.from_user
loc = file_path
appendable = [s_name, r_by, loc]
qeue.append(appendable)
await res.edit_text(f"Music= #️⃣ Queued at position {position}")
else:
await res.edit_text("Music=▶️ Playing.....")
chat_id = message_.chat.id
que[chat_id] = []
qeue = que.get(message_.chat.id)
s_name = title
r_by = message_.from_user
loc = file_path
appendable = [s_name, r_by, loc]
qeue.append(appendable)
callsmusic.pytgcalls.join_group_call(message_.chat.id, file_path)
await res.delete()
m = await client.send_photo(
chat_id=message_.chat.id,
reply_markup=keyboard,
photo="final.png",
caption=f"Playing [{title}]({url}) Via Deezer"
)
os.remove("final.png")
@Client.on_message(
filters.command("splay")
& filters.group
& ~ filters.edited
)
async def jiosaavn(client: Client, message_: Message):
try:
await message._client.get_chat_member(int("-1001292906791"), message.from_user.id)
except UserNotParticipant:
await message.reply_text(JOIN_ASAP)
return
global que
lel = await message_.reply("🔄 **Processing**")
administrators = await get_administrators(message_.chat)
chid = message_.chat.id
try:
user = await USER.get_me()
except:
user.first_name = "Gautam'S Music Bot"
usar = user
wew = usar.id
try:
#chatdetails = await USER.get_chat(chid)
lmoa = await client.get_chat_member(chid,wew)
except:
for administrator in administrators:
if administrator == message_.from_user.id:
try:
invitelink = await client.export_chat_invite_link(chid)
except:
await lel.edit(
"<b>Add me as admin of yor group first</b>",
)
return
try:
await USER.join_chat(invitelink)
await USER.send_message(message_.chat.id,"I joined this group for playing music in VC")
await lel.edit(
"<b>helper userbot joined your chat</b>",
)
except UserAlreadyParticipant:
pass
except Exception as e:
#print(e)
await lel.edit(
f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your group due to heavy requests for userbot! Make sure user is not banned in group."
"\n\nOr manually add @Gautam180304 to your Group and try again</b>",
)
pass
try:
chatdetails = await USER.get_chat(chid)
#lmoa = await client.get_chat_member(chid,wew)
except:
await lel.edit(
"<i> helper Userbot not in this chat, Ask admin to send /play command for first time or add assistant manually</i>"
)
return
requested_by = message_.from_user.first_name
chat_id=message_.chat.id
text = message_.text.split(" ", 1)
query = text[1]
res = lel
await res.edit(f"Searching for `{query}` on jio saavn")
try:
async with aiohttp.ClientSession() as session:
async with session.get(
f"https://jiosaavnapi.bhadoo.uk/result/?query={query}"
) as resp:
r = json.loads(await resp.text())
sname = r[0]["song"]
slink = r[0]["media_url"]
ssingers = r[0]["singers"]
sthumb = r[0]["image"]
sduration = int(r[0]["duration"])
except Exception as e:
await res.edit(
"Found Literally Nothing!, You Should Work On Your English."
)
print(str(e))
is_playing = False
return
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📖 Playlist', callback_data='playlist'),
InlineKeyboardButton('Menu ⏯ ', callback_data='menu')
],
[
InlineKeyboardButton(
text="Join Updates Channel",
url='https://t.me/GautamS_Mirror')
],
[
InlineKeyboardButton(
text="❌ Close",
callback_data='cls')
]
]
)
file_path= await converter.convert(wget.download(slink))
if message_.chat.id in callsmusic.pytgcalls.active_calls:
position = await queues.put(message_.chat.id, file=file_path)
qeue = que.get(message_.chat.id)
s_name = sname
r_by = message_.from_user
loc = file_path
appendable = [s_name, r_by, loc]
qeue.append(appendable)
await res.delete()
m = await client.send_photo(
chat_id=message_.chat.id,
reply_markup=keyboard,
photo="final.png",
caption=f"#️⃣ Queued at position {position}",
)
else:
await res.edit_text("▶️ Playing.....")
chat_id = message_.chat.id
que[chat_id] = []
qeue = que.get(message_.chat.id)
s_name = sname
r_by = message_.from_user
loc = file_path
appendable = [s_name, r_by, loc]
qeue.append(appendable)
callsmusic.pytgcalls.join_group_call(message_.chat.id, file_path)
await res.edit("Generating Thumbnail.")
await generate_cover(requested_by, sname, ssingers, sduration, sthumb)
await res.delete()
m = await client.send_photo(
chat_id=message_.chat.id,
reply_markup=keyboard,
photo="final.png",
caption=f"Playing {sname} Via Jiosaavn",
)
os.remove("final.png")
# Have u read all. If read RESPECT :-)
| [
1,
529,
276,
1112,
420,
29958,
29954,
1300,
314,
771,
29896,
29947,
29941,
29946,
29914,
29911,
6146,
1393,
29918,
29963,
29883,
29918,
29933,
327,
13,
3166,
2897,
1053,
2224,
13,
3166,
19229,
1053,
360,
919,
13,
3166,
11451,
307,
1393,
1053,
12477,
13,
3166,
11451,
307,
1393,
29889,
8768,
1053,
7777,
29892,
4785,
625,
13,
3166,
19229,
1053,
8251,
519,
29892,
2994,
449,
457,
29892,
360,
919,
29892,
2391,
29892,
12603,
552,
29892,
7761,
13,
3166,
1246,
3844,
375,
293,
1053,
1246,
3844,
375,
293,
29892,
712,
1041,
13,
3166,
1371,
414,
29889,
328,
29885,
1144,
1053,
679,
29918,
6406,
2132,
4097,
13,
3166,
2897,
1053,
2224,
13,
5215,
7274,
13,
5215,
263,
601,
1124,
13,
5215,
366,
29873,
4003,
29918,
11671,
13,
3166,
366,
29873,
4003,
29918,
4478,
1053,
612,
15907,
7974,
13,
3166,
11451,
307,
1393,
1053,
18094,
29892,
953,
29877,
2397,
13,
3166,
11451,
307,
1393,
29889,
8768,
1053,
10567,
10572,
25971,
13,
3166,
11451,
307,
1393,
29889,
12523,
29889,
11739,
29879,
29889,
12313,
29918,
3827,
29918,
29946,
29900,
29900,
1053,
678,
271,
12754,
19347,
13,
3166,
11451,
307,
1393,
29889,
12523,
29889,
11739,
29879,
29889,
29888,
417,
397,
29918,
29946,
29906,
29900,
1053,
26043,
397,
15716,
13,
5215,
9637,
1627,
13,
5215,
2897,
13,
5215,
10876,
13,
3166,
1246,
3844,
375,
293,
29889,
4804,
3844,
375,
293,
1053,
3132,
408,
3148,
1001,
13,
3166,
11451,
307,
1393,
29889,
12523,
1053,
4911,
2499,
2040,
7439,
12654,
424,
13,
5215,
29105,
13,
3166,
5142,
414,
1053,
366,
29873,
4003,
13,
13,
3166,
2295,
1053,
350,
2891,
29918,
5813,
408,
289,
29876,
29892,
360,
4574,
8098,
29918,
5265,
26349,
13,
3166,
1371,
414,
29889,
26705,
1053,
1899,
29892,
916,
29918,
26705,
13,
3166,
1371,
414,
29889,
19557,
4097,
1053,
4436,
29892,
4148,
1891,
29918,
7193,
29918,
6194,
13,
3166,
1371,
414,
29889,
12523,
1053,
360,
2633,
24445,
2392,
13,
3166,
1371,
414,
29889,
20078,
1053,
679,
29918,
2271,
29892,
679,
29918,
1445,
29918,
978,
13,
3166,
11451,
307,
1393,
29889,
8768,
1053,
512,
1220,
2558,
3377,
3125,
29892,
512,
1220,
2558,
3377,
9802,
786,
13,
3166,
7090,
29889,
328,
29885,
1144,
1053,
7336,
1144,
408,
263,
13,
5215,
2897,
13,
5215,
263,
601,
1124,
13,
5215,
263,
601,
5325,
13,
5215,
14336,
20856,
13,
3166,
349,
6227,
1053,
7084,
13,
3166,
349,
6227,
1053,
7084,
9824,
13,
3166,
349,
6227,
1053,
7084,
8537,
13,
3166,
2295,
1053,
712,
13,
3166,
5132,
29918,
1718,
29984,
1053,
9033,
29984,
13,
3166,
11451,
307,
1393,
29889,
12523,
1053,
4911,
3664,
7439,
12654,
424,
13,
5215,
4390,
13,
5215,
281,
657,
13,
13496,
29918,
333,
353,
6213,
13,
13,
29967,
6992,
29918,
3289,
3301,
353,
376,
3492,
817,
304,
3650,
262,
732,
29954,
1300,
314,
29903,
29918,
29924,
381,
729,
363,
773,
592,
584,
12975,
9651,
13,
13,
13,
1753,
26324,
29918,
6406,
29918,
3198,
29898,
9891,
29901,
8251,
519,
29897,
1599,
8251,
519,
29901,
13,
1678,
7465,
822,
10200,
1061,
29898,
4645,
29892,
26324,
1125,
13,
4706,
594,
6954,
267,
353,
263,
29889,
657,
29898,
10702,
29889,
4906,
29889,
13496,
29889,
333,
29897,
13,
4706,
565,
26324,
29889,
3166,
29918,
1792,
29889,
333,
297,
594,
6954,
267,
29901,
13,
9651,
736,
7272,
3653,
29898,
4645,
29892,
26324,
29897,
13,
4706,
1683,
29901,
13,
9651,
7272,
26324,
29889,
12011,
877,
3492,
7216,
20333,
29873,
6068,
29991,
742,
1510,
29918,
12888,
29922,
5574,
29897,
13,
9651,
736,
13,
1678,
736,
10200,
1061,
462,
462,
462,
462,
4706,
13,
462,
462,
965,
13,
462,
462,
965,
13,
462,
462,
965,
13,
462,
462,
965,
13,
1753,
1301,
401,
29898,
9507,
1125,
13,
1678,
14336,
20856,
29889,
2080,
29898,
9507,
467,
4905,
703,
2080,
29889,
1610,
613,
3402,
2433,
29879,
29896,
29953,
280,
742,
263,
401,
29883,
2433,
29886,
4912,
29918,
29879,
29896,
29953,
280,
742,
1274,
29922,
29906,
29892,
564,
2433,
29946,
29947,
29895,
2824,
957,
3539,
29918,
4905,
2141,
3389,
580,
29871,
13,
1678,
2897,
29889,
5992,
29898,
9507,
29897,
13,
13,
29937,
14806,
6923,
304,
5654,
29901,
893,
13,
1753,
3588,
29918,
23128,
29898,
23128,
1125,
13,
1678,
6923,
353,
6923,
1273,
313,
29906,
29946,
334,
29871,
29941,
29953,
29900,
29900,
29897,
13,
1678,
6923,
1273,
29922,
29871,
29941,
29953,
29900,
29900,
13,
1678,
6233,
353,
6923,
849,
29871,
29953,
29900,
13,
1678,
6923,
1273,
29922,
29871,
29953,
29900,
13,
1678,
736,
11860,
29900,
29906,
29881,
16664,
29900,
29906,
29881,
29908,
1273,
313,
1195,
2667,
29892,
6923,
29897,
13,
13,
13,
29937,
14806,
298,
29882,
29901,
4317,
29901,
893,
304,
6923,
13,
1753,
931,
29918,
517,
29918,
23128,
29898,
2230,
1125,
13,
1678,
1347,
29873,
353,
851,
29898,
2230,
29897,
13,
1678,
736,
2533,
29898,
524,
29898,
29916,
29897,
334,
29871,
29953,
29900,
3579,
474,
363,
474,
29892,
921,
297,
26985,
29898,
276,
874,
287,
29898,
1807,
29873,
29889,
5451,
877,
29901,
8785,
876,
13,
13,
13,
29937,
10726,
1967,
2159,
13,
1753,
1735,
2940,
3505,
29898,
3317,
6110,
29892,
4236,
7011,
29892,
1967,
1125,
13,
1678,
2920,
29934,
20819,
353,
4236,
6110,
847,
1967,
29889,
2311,
29961,
29900,
29962,
13,
1678,
3171,
29934,
20819,
353,
4236,
7011,
847,
1967,
29889,
2311,
29961,
29896,
29962,
13,
1678,
716,
6110,
353,
938,
29898,
2103,
29934,
20819,
334,
1967,
29889,
2311,
29961,
29900,
2314,
13,
1678,
716,
7011,
353,
938,
29898,
3545,
29934,
20819,
334,
1967,
29889,
2311,
29961,
29896,
2314,
13,
1678,
716,
2940,
353,
1967,
29889,
21476,
3552,
1482,
6110,
29892,
716,
7011,
876,
13,
1678,
736,
716,
2940,
13,
13,
12674,
822,
5706,
29918,
11911,
29898,
3827,
287,
29918,
1609,
29892,
3611,
29892,
8386,
29892,
14385,
29892,
266,
21145,
1125,
13,
1678,
7465,
411,
263,
601,
1124,
29889,
4032,
7317,
580,
408,
4867,
29901,
13,
4706,
7465,
411,
4867,
29889,
657,
29898,
386,
21145,
29897,
408,
4613,
29901,
13,
9651,
565,
4613,
29889,
4882,
1275,
29871,
29906,
29900,
29900,
29901,
13,
18884,
285,
353,
7272,
263,
601,
5325,
29889,
3150,
703,
7042,
29889,
2732,
613,
4464,
543,
29893,
29890,
1159,
13,
18884,
7272,
285,
29889,
3539,
29898,
20675,
4613,
29889,
949,
3101,
13,
18884,
7272,
285,
29889,
5358,
580,
13,
13,
1678,
1967,
29896,
353,
7084,
29889,
3150,
703,
6904,
7042,
29889,
2732,
1159,
13,
1678,
1967,
29906,
353,
7084,
29889,
3150,
703,
7070,
29914,
1454,
18128,
29889,
2732,
1159,
13,
1678,
1967,
29941,
353,
1735,
2940,
3505,
29898,
29896,
29906,
29947,
29900,
29892,
29871,
29955,
29906,
29900,
29892,
1967,
29896,
29897,
13,
1678,
1967,
29946,
353,
1735,
2940,
3505,
29898,
29896,
29906,
29947,
29900,
29892,
29871,
29955,
29906,
29900,
29892,
1967,
29906,
29897,
13,
1678,
1967,
29945,
353,
1967,
29941,
29889,
13441,
703,
29934,
29954,
5688,
1159,
13,
1678,
1967,
29953,
353,
1967,
29946,
29889,
13441,
703,
29934,
29954,
5688,
1159,
13,
1678,
7084,
29889,
2312,
29918,
22410,
568,
29898,
3027,
29945,
29892,
1967,
29953,
467,
7620,
703,
7382,
29889,
2732,
1159,
13,
1678,
10153,
353,
7084,
29889,
3150,
703,
7382,
29889,
2732,
1159,
13,
1678,
4216,
353,
7084,
8537,
29889,
8537,
29898,
2492,
29897,
13,
1678,
4079,
353,
7084,
9824,
29889,
509,
14484,
668,
703,
7070,
29914,
5657,
29889,
327,
29888,
613,
29871,
29941,
29906,
29897,
13,
1678,
4216,
29889,
726,
3552,
29906,
29900,
29945,
29892,
29871,
29945,
29945,
29900,
511,
285,
29908,
7030,
29901,
426,
3257,
17671,
313,
29945,
29896,
29892,
29871,
29906,
29896,
29945,
29892,
29871,
29906,
29945,
29945,
511,
4079,
29922,
5657,
29897,
13,
1678,
4216,
29889,
726,
29898,
13,
4706,
313,
29906,
29900,
29945,
29892,
29871,
29945,
29929,
29900,
511,
285,
29908,
18984,
29901,
426,
19708,
17671,
313,
29906,
29945,
29945,
29892,
29871,
29906,
29945,
29945,
29892,
29871,
29906,
29945,
29945,
511,
4079,
29922,
5657,
13,
1678,
1723,
13,
1678,
4216,
29889,
726,
3552,
29906,
29900,
29945,
29892,
29871,
29953,
29941,
29900,
511,
285,
29908,
23825,
29901,
426,
7406,
17671,
313,
29906,
29945,
29945,
29892,
29871,
29906,
29945,
29945,
29892,
29871,
29906,
29945,
29945,
511,
4079,
29922,
5657,
29897,
13,
1678,
4216,
29889,
726,
3552,
29906,
29900,
29945,
29892,
29871,
29953,
29955,
29900,
511,
13,
4706,
285,
29908,
2528,
287,
2648,
29901,
426,
3827,
287,
29918,
1609,
17671,
13,
4706,
313,
29906,
29945,
29945,
29892,
29871,
29906,
29945,
29945,
29892,
29871,
29906,
29945,
29945,
511,
13,
4706,
4079,
29922,
5657,
29892,
13,
1678,
1723,
13,
1678,
10153,
29889,
7620,
703,
8394,
29889,
2732,
1159,
13,
1678,
2897,
29889,
5992,
703,
7382,
29889,
2732,
1159,
13,
1678,
2897,
29889,
5992,
703,
7042,
29889,
2732,
1159,
13,
13,
13,
29871,
13,
13,
29992,
4032,
29889,
265,
29918,
4906,
29898,
13,
1678,
18094,
29889,
6519,
703,
1456,
1761,
1159,
13,
1678,
669,
18094,
29889,
2972,
13,
1678,
669,
3695,
18094,
29889,
287,
1573,
13,
29897,
13,
12674,
822,
1708,
1761,
29898,
4645,
29892,
2643,
1125,
13,
1678,
1018,
29901,
13,
4706,
7272,
2643,
3032,
4645,
29889,
657,
29918,
13496,
29918,
14242,
29898,
524,
703,
29899,
29896,
29900,
29900,
29896,
29906,
29929,
29906,
29929,
29900,
29953,
29955,
29929,
29896,
4968,
2643,
29889,
3166,
29918,
1792,
29889,
333,
29897,
13,
1678,
5174,
4911,
3664,
7439,
12654,
424,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
726,
29898,
29967,
6992,
29918,
3289,
3301,
29897,
13,
4706,
736,
13,
1678,
5534,
712,
13,
1678,
9521,
353,
712,
29889,
657,
29898,
4906,
29889,
13496,
29889,
333,
29897,
13,
1678,
565,
451,
9521,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
726,
877,
9075,
338,
28132,
1495,
13,
1678,
5694,
353,
5159,
13,
1678,
363,
260,
297,
9521,
29901,
13,
4706,
5694,
29889,
4397,
29898,
29873,
29897,
13,
1678,
1286,
29918,
1456,
292,
353,
5694,
29961,
29900,
3816,
29900,
29962,
13,
1678,
491,
353,
5694,
29961,
29900,
3816,
29896,
1822,
358,
291,
29898,
3293,
2433,
3487,
1495,
13,
1678,
10191,
353,
376,
1068,
10454,
7412,
292,
1068,
297,
6571,
1642,
4830,
29898,
4906,
29889,
13496,
29889,
3257,
29897,
13,
1678,
10191,
4619,
6634,
29876,
17969,
1286,
29918,
1456,
292,
13,
1678,
10191,
4619,
6634,
29876,
29899,
830,
29939,
491,
15691,
1609,
13,
1678,
5694,
29889,
7323,
29898,
29900,
29897,
13,
1678,
565,
5694,
29901,
13,
4706,
10191,
4619,
11297,
29876,
29905,
29876,
29915,
13,
4706,
10191,
4619,
525,
1068,
10620,
1068,
29915,
13,
4706,
363,
4823,
297,
5694,
29901,
13,
9651,
1024,
353,
4823,
29961,
29900,
29962,
13,
9651,
502,
29878,
353,
4823,
29961,
29896,
1822,
358,
291,
29898,
3293,
2433,
3487,
1495,
13,
9651,
10191,
4619,
285,
12764,
29876,
29899,
426,
978,
10162,
13,
9651,
10191,
4619,
285,
12764,
29876,
29899,
830,
29939,
491,
426,
4855,
1012,
29876,
29915,
13,
1678,
7272,
2643,
29889,
3445,
368,
29918,
726,
29898,
7645,
29897,
4706,
13,
268,
13,
29937,
1275,
9166,
4936,
25512,
19215,
1275,
9166,
9166,
2751,
25512,
13,
13,
1753,
4784,
29918,
16202,
29898,
13496,
29892,
9521,
29892,
1700,
29922,
29896,
29900,
29900,
1125,
13,
1678,
565,
13563,
29889,
333,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29901,
13,
1678,
396,
361,
13563,
29889,
333,
297,
6136,
29918,
305,
1446,
29901,
13,
4706,
22663,
353,
525,
9585,
310,
3579,
8875,
1068,
4286,
4830,
29898,
13496,
29889,
3257,
29897,
13,
4706,
565,
7431,
29898,
802,
29897,
1405,
29871,
29900,
29901,
13,
9651,
22663,
4619,
11297,
29876,
29905,
29876,
29915,
13,
9651,
22663,
4619,
525,
24679,
584,
6571,
29995,
29905,
29876,
4286,
4830,
29898,
1555,
29897,
13,
9651,
22663,
4619,
525,
29903,
24733,
297,
9521,
584,
421,
8875,
29952,
29905,
29876,
4286,
4830,
29898,
2435,
29898,
802,
876,
13,
9651,
22663,
4619,
525,
10454,
7412,
292,
584,
3579,
8875,
1068,
29905,
29876,
4286,
4830,
29898,
9990,
29961,
29900,
3816,
29900,
2314,
13,
9651,
22663,
4619,
525,
3089,
287,
491,
584,
6571,
4286,
4830,
29898,
9990,
29961,
29900,
3816,
29896,
1822,
358,
291,
29897,
13,
1678,
1683,
29901,
13,
4706,
22663,
353,
6213,
13,
1678,
736,
22663,
13,
13,
1753,
364,
29918,
17632,
29898,
1853,
29918,
1125,
13,
1678,
565,
1134,
29918,
1275,
525,
1456,
2396,
13,
308,
1417,
353,
525,
30965,
29915,
13,
1678,
1683,
29901,
13,
308,
1417,
353,
525,
229,
146,
187,
29915,
13,
1678,
1766,
353,
512,
1220,
2558,
3377,
9802,
786,
29898,
13,
4706,
518,
13,
9651,
518,
13,
18884,
512,
1220,
2558,
3377,
3125,
877,
229,
146,
188,
742,
525,
280,
1351,
5477,
13,
18884,
512,
1220,
2558,
3377,
3125,
877,
229,
146,
187,
742,
525,
29886,
1509,
5477,
13,
18884,
512,
1220,
2558,
3377,
3125,
877,
30965,
30598,
742,
525,
690,
2017,
5477,
13,
18884,
512,
1220,
2558,
3377,
3125,
877,
229,
146,
176,
742,
525,
11014,
1495,
13,
462,
13,
9651,
21251,
13,
9651,
518,
13,
18884,
512,
1220,
2558,
3377,
3125,
877,
13454,
1761,
29871,
243,
162,
150,
153,
742,
525,
1456,
1761,
5477,
13,
462,
13,
9651,
21251,
13,
9651,
518,
4706,
13,
18884,
512,
1220,
2558,
3377,
3125,
703,
229,
160,
143,
23186,
613,
29915,
25932,
1495,
13,
9651,
4514,
308,
13,
4706,
4514,
13,
1678,
1723,
13,
1678,
736,
1766,
13,
13,
29992,
4032,
29889,
265,
29918,
4906,
29898,
13,
1678,
18094,
29889,
6519,
703,
3784,
1159,
13,
1678,
669,
18094,
29889,
2972,
13,
1678,
669,
3695,
18094,
29889,
287,
1573,
13,
29897,
13,
12674,
822,
321,
29872,
29898,
4645,
29892,
2643,
1125,
13,
1678,
1018,
29901,
13,
4706,
7272,
2643,
3032,
4645,
29889,
657,
29918,
13496,
29918,
14242,
29898,
524,
703,
29899,
29896,
29900,
29900,
29896,
29906,
29929,
29906,
29929,
29900,
29953,
29955,
29929,
29896,
4968,
2643,
29889,
3166,
29918,
1792,
29889,
333,
29897,
13,
1678,
5174,
4911,
3664,
7439,
12654,
424,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
726,
29898,
29967,
6992,
29918,
3289,
3301,
29897,
13,
4706,
736,
13,
1678,
9521,
353,
712,
29889,
657,
29898,
4906,
29889,
13496,
29889,
333,
29897,
13,
1678,
22663,
353,
4784,
29918,
16202,
29898,
4906,
29889,
13496,
29892,
9521,
29897,
13,
1678,
565,
22663,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
29898,
16202,
29897,
1669,
13,
1678,
1683,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
877,
3782,
4785,
625,
1451,
271,
8871,
2734,
297,
445,
13563,
1495,
13,
13,
29992,
4032,
29889,
265,
29918,
4906,
29898,
13,
1678,
18094,
29889,
6519,
703,
9106,
1159,
13,
1678,
669,
18094,
29889,
2972,
13,
1678,
669,
3695,
18094,
29889,
287,
1573,
13,
29897,
13,
29992,
8921,
1891,
29918,
7193,
29918,
6194,
13,
12674,
822,
6055,
29898,
4645,
29892,
2643,
1125,
13,
1678,
1018,
29901,
13,
4706,
7272,
2643,
3032,
4645,
29889,
657,
29918,
13496,
29918,
14242,
29898,
524,
703,
29899,
29896,
29900,
29900,
29896,
29906,
29929,
29906,
29929,
29900,
29953,
29955,
29929,
29896,
4968,
2643,
29889,
3166,
29918,
1792,
29889,
333,
29897,
13,
1678,
5174,
4911,
3664,
7439,
12654,
424,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
726,
29898,
29967,
6992,
29918,
3289,
3301,
29897,
13,
4706,
736,
13,
1678,
8743,
353,
6213,
13,
1678,
565,
2643,
29889,
13496,
29889,
333,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29901,
13,
4706,
8743,
353,
5852,
13,
1678,
9521,
353,
712,
29889,
657,
29898,
4906,
29889,
13496,
29889,
333,
29897,
13,
1678,
22663,
353,
4784,
29918,
16202,
29898,
4906,
29889,
13496,
29892,
9521,
29897,
13,
1678,
565,
22663,
29901,
13,
4706,
565,
8743,
29901,
13,
9651,
7272,
2643,
29889,
3445,
368,
29898,
16202,
29892,
8908,
29918,
3502,
786,
29922,
29878,
29918,
17632,
877,
29886,
1071,
8785,
13,
632,
13,
4706,
1683,
29901,
13,
9651,
7272,
2643,
29889,
3445,
368,
29898,
16202,
29892,
8908,
29918,
3502,
786,
29922,
29878,
29918,
17632,
877,
1456,
8785,
13,
1678,
1683,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
877,
3782,
478,
29907,
8871,
2734,
297,
445,
13563,
1495,
13,
13,
29992,
4032,
29889,
265,
29918,
14035,
29918,
1972,
29898,
26705,
29889,
13087,
29898,
11037,
29922,
29878,
29915,
23733,
1456,
1761,
1262,
8785,
13,
29992,
4032,
29889,
265,
29918,
14035,
29918,
1972,
29898,
26705,
29889,
13087,
29898,
11037,
29922,
29878,
29915,
23733,
1456,
1761,
1262,
8785,
13,
12674,
822,
282,
29918,
10702,
29898,
29890,
29892,
26324,
1125,
13,
1678,
5534,
712,
268,
13,
1678,
3855,
29872,
434,
353,
712,
29889,
657,
29898,
10702,
29889,
4906,
29889,
13496,
29889,
333,
29897,
13,
1678,
1134,
29918,
353,
26324,
29889,
20317,
29961,
29900,
1822,
2972,
29898,
29896,
29897,
13,
1678,
13563,
29918,
333,
353,
26324,
29889,
4906,
29889,
13496,
29889,
333,
13,
1678,
286,
29918,
13496,
353,
26324,
29889,
4906,
29889,
13496,
13,
1678,
278,
29918,
1272,
353,
26324,
29889,
4906,
29889,
3445,
368,
29918,
3502,
786,
29889,
14764,
29918,
1989,
3377,
29961,
29896,
3816,
29900,
1822,
14035,
29918,
1272,
13,
1678,
565,
1134,
29918,
1275,
525,
1456,
1761,
2396,
9651,
13,
4706,
9521,
353,
712,
29889,
657,
29898,
10702,
29889,
4906,
29889,
13496,
29889,
333,
29897,
13,
4706,
565,
451,
9521,
29901,
1678,
13,
9651,
7272,
26324,
29889,
4906,
29889,
5628,
877,
9075,
338,
28132,
1495,
13,
4706,
5694,
353,
5159,
13,
4706,
363,
260,
297,
9521,
29901,
13,
9651,
5694,
29889,
4397,
29898,
29873,
29897,
13,
4706,
1286,
29918,
1456,
292,
353,
5694,
29961,
29900,
3816,
29900,
29962,
13,
4706,
491,
353,
5694,
29961,
29900,
3816,
29896,
1822,
358,
291,
29898,
3293,
2433,
3487,
1495,
13,
4706,
10191,
353,
376,
1068,
10454,
7412,
292,
1068,
297,
6571,
1642,
4830,
29898,
10702,
29889,
4906,
29889,
13496,
29889,
3257,
29897,
13,
4706,
10191,
4619,
6634,
29876,
29899,
15691,
1286,
29918,
1456,
292,
13,
4706,
10191,
4619,
6634,
29876,
29899,
830,
29939,
491,
15691,
1609,
13,
4706,
5694,
29889,
7323,
29898,
29900,
29897,
13,
4706,
565,
5694,
29901,
13,
632,
10191,
4619,
11297,
29876,
29905,
29876,
29915,
13,
632,
10191,
4619,
525,
1068,
10620,
1068,
29915,
13,
632,
363,
4823,
297,
5694,
29901,
13,
462,
1024,
353,
4823,
29961,
29900,
29962,
13,
462,
502,
29878,
353,
4823,
29961,
29896,
1822,
358,
291,
29898,
3293,
2433,
3487,
1495,
13,
462,
10191,
4619,
285,
12764,
29876,
29899,
426,
978,
10162,
13,
462,
10191,
4619,
285,
12764,
29876,
29899,
830,
29939,
491,
426,
4855,
1012,
29876,
29915,
13,
4706,
7272,
26324,
29889,
4906,
29889,
5628,
29898,
7645,
29897,
539,
13,
13,
29992,
4032,
29889,
265,
29918,
14035,
29918,
1972,
29898,
26705,
29889,
13087,
29898,
11037,
29922,
29878,
29915,
23733,
1456,
29989,
29886,
1071,
29989,
11014,
29989,
280,
1351,
29989,
29886,
1509,
29989,
690,
2017,
29989,
6510,
29989,
25932,
1262,
8785,
13,
29992,
10702,
29918,
6406,
29918,
3198,
13,
12674,
822,
286,
29918,
10702,
29898,
29890,
29892,
26324,
1125,
13,
1678,
5534,
712,
268,
13,
1678,
3855,
29872,
434,
353,
712,
29889,
657,
29898,
10702,
29889,
4906,
29889,
13496,
29889,
333,
29897,
13,
1678,
1134,
29918,
353,
26324,
29889,
20317,
29961,
29900,
1822,
2972,
29898,
29896,
29897,
13,
1678,
13563,
29918,
333,
353,
26324,
29889,
4906,
29889,
13496,
29889,
333,
13,
1678,
286,
29918,
13496,
353,
26324,
29889,
4906,
29889,
13496,
13,
13,
1678,
278,
29918,
1272,
353,
26324,
29889,
4906,
29889,
3445,
368,
29918,
3502,
786,
29889,
14764,
29918,
1989,
3377,
29961,
29896,
3816,
29900,
1822,
14035,
29918,
1272,
13,
1678,
565,
1134,
29918,
1275,
525,
29886,
1071,
2396,
13,
4706,
565,
313,
13,
9651,
13563,
29918,
333,
451,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
13,
18884,
1723,
470,
313,
13,
462,
1678,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29961,
13496,
29918,
333,
29962,
1275,
525,
29886,
15244,
29915,
13,
462,
1125,
13,
9651,
7272,
26324,
29889,
12011,
877,
1451,
271,
338,
451,
6631,
29991,
742,
1510,
29918,
12888,
29922,
5574,
29897,
13,
4706,
1683,
29901,
13,
9651,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
29886,
1071,
29918,
5461,
29898,
13496,
29918,
333,
29897,
13,
632,
13,
9651,
7272,
26324,
29889,
12011,
877,
21238,
349,
15244,
29991,
1495,
13,
9651,
7272,
26324,
29889,
4906,
29889,
5628,
29898,
21402,
29918,
16202,
29898,
29885,
29918,
13496,
29892,
3855,
29872,
434,
511,
8908,
29918,
3502,
786,
29922,
29878,
29918,
17632,
877,
1456,
8785,
13,
462,
13,
13,
1678,
25342,
1134,
29918,
1275,
525,
1456,
2396,
4706,
13,
4706,
565,
313,
13,
9651,
13563,
29918,
333,
451,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
13,
9651,
1723,
470,
313,
13,
18884,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29961,
13496,
29918,
333,
29962,
1275,
525,
1456,
292,
29915,
13,
632,
1125,
13,
18884,
7272,
26324,
29889,
12011,
877,
1451,
271,
338,
451,
6631,
29991,
742,
1510,
29918,
12888,
29922,
5574,
29897,
13,
4706,
1683,
29901,
13,
9651,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
690,
2017,
29918,
5461,
29898,
13496,
29918,
333,
29897,
13,
9651,
7272,
26324,
29889,
12011,
877,
21238,
2538,
21571,
29991,
1495,
13,
9651,
7272,
26324,
29889,
4906,
29889,
5628,
29898,
21402,
29918,
16202,
29898,
29885,
29918,
13496,
29892,
3855,
29872,
434,
511,
8908,
29918,
3502,
786,
29922,
29878,
29918,
17632,
877,
29886,
1071,
8785,
13,
462,
418,
13,
13,
1678,
25342,
1134,
29918,
1275,
525,
1456,
1761,
2396,
13,
4706,
9521,
353,
712,
29889,
657,
29898,
10702,
29889,
4906,
29889,
13496,
29889,
333,
29897,
13,
4706,
565,
451,
9521,
29901,
1678,
13,
9651,
7272,
26324,
29889,
4906,
29889,
5628,
877,
9075,
338,
28132,
1495,
13,
4706,
5694,
353,
5159,
13,
4706,
363,
260,
297,
9521,
29901,
13,
9651,
5694,
29889,
4397,
29898,
29873,
29897,
13,
4706,
1286,
29918,
1456,
292,
353,
5694,
29961,
29900,
3816,
29900,
29962,
13,
4706,
491,
353,
5694,
29961,
29900,
3816,
29896,
1822,
358,
291,
29898,
3293,
2433,
3487,
1495,
13,
4706,
10191,
353,
376,
1068,
10454,
7412,
292,
1068,
297,
6571,
1642,
4830,
29898,
10702,
29889,
4906,
29889,
13496,
29889,
3257,
29897,
13,
4706,
10191,
4619,
6634,
29876,
29899,
15691,
1286,
29918,
1456,
292,
13,
4706,
10191,
4619,
6634,
29876,
29899,
830,
29939,
491,
15691,
1609,
13,
4706,
5694,
29889,
7323,
29898,
29900,
29897,
13,
4706,
565,
5694,
29901,
13,
632,
10191,
4619,
11297,
29876,
29905,
29876,
29915,
13,
632,
10191,
4619,
525,
1068,
10620,
1068,
29915,
13,
632,
363,
4823,
297,
5694,
29901,
13,
462,
1024,
353,
4823,
29961,
29900,
29962,
13,
462,
502,
29878,
353,
4823,
29961,
29896,
1822,
358,
291,
29898,
3293,
2433,
3487,
1495,
13,
462,
10191,
4619,
285,
12764,
29876,
29899,
426,
978,
10162,
13,
462,
10191,
4619,
285,
12764,
29876,
29899,
830,
29939,
491,
426,
4855,
1012,
29876,
29915,
13,
4706,
7272,
26324,
29889,
4906,
29889,
5628,
29898,
7645,
29897,
539,
13,
462,
539,
13,
1678,
25342,
1134,
29918,
1275,
525,
690,
2017,
2396,
418,
13,
4706,
565,
313,
13,
9651,
13563,
29918,
333,
451,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
13,
9651,
1723,
470,
313,
13,
18884,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29961,
13496,
29918,
333,
29962,
1275,
525,
1456,
292,
29915,
13,
632,
1125,
13,
18884,
7272,
26324,
29889,
12011,
877,
1451,
271,
338,
451,
6631,
470,
2307,
1708,
865,
742,
1510,
29918,
12888,
29922,
5574,
29897,
13,
4706,
1683,
29901,
13,
9651,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
690,
2017,
29918,
5461,
29898,
13496,
29918,
333,
29897,
13,
9651,
7272,
26324,
29889,
12011,
877,
21238,
2538,
21571,
29991,
1495,
418,
13,
1678,
25342,
1134,
29918,
1275,
525,
29886,
1509,
2396,
3986,
13,
4706,
565,
313,
13,
9651,
13563,
29918,
333,
451,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
13,
18884,
1723,
470,
313,
13,
462,
1678,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29961,
13496,
29918,
333,
29962,
1275,
525,
29886,
15244,
29915,
13,
462,
1125,
13,
9651,
7272,
26324,
29889,
12011,
877,
1451,
271,
338,
451,
6631,
470,
2307,
28454,
742,
1510,
29918,
12888,
29922,
5574,
29897,
13,
4706,
1683,
29901,
13,
9651,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
29886,
1071,
29918,
5461,
29898,
13496,
29918,
333,
29897,
13,
632,
13,
9651,
7272,
26324,
29889,
12011,
877,
21238,
349,
15244,
29991,
1495,
13,
1678,
25342,
1134,
29918,
1275,
525,
25932,
2396,
965,
13,
4706,
7272,
26324,
29889,
12011,
877,
6821,
2662,
6143,
1495,
13,
4706,
7272,
26324,
29889,
4906,
29889,
8143,
580,
4706,
13,
13,
1678,
25342,
1134,
29918,
1275,
525,
6510,
2396,
259,
13,
4706,
22663,
353,
4784,
29918,
16202,
29898,
10702,
29889,
4906,
29889,
13496,
29892,
3855,
29872,
434,
29897,
259,
13,
4706,
7272,
26324,
29889,
12011,
877,
6823,
6496,
1495,
13,
4706,
1766,
29878,
353,
512,
1220,
2558,
3377,
9802,
786,
29898,
13,
9651,
518,
13,
18884,
518,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
877,
229,
146,
188,
742,
525,
280,
1351,
5477,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
877,
229,
146,
187,
742,
525,
29886,
1509,
5477,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
877,
30965,
30598,
742,
525,
690,
2017,
5477,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
877,
229,
146,
176,
742,
525,
11014,
1495,
13,
462,
13,
18884,
21251,
13,
18884,
518,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
877,
13454,
1761,
29871,
243,
162,
150,
153,
742,
525,
1456,
1761,
5477,
13,
462,
13,
18884,
21251,
13,
18884,
518,
4706,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
703,
229,
160,
143,
23186,
613,
29915,
25932,
1495,
13,
18884,
4514,
308,
13,
9651,
4514,
13,
4706,
1723,
13,
4706,
7272,
26324,
29889,
4906,
29889,
5628,
29898,
16202,
29892,
8908,
29918,
3502,
786,
29922,
29885,
2749,
29897,
29871,
13,
1678,
25342,
1134,
29918,
1275,
525,
11014,
2396,
308,
13,
4706,
565,
3855,
29872,
434,
29901,
13,
9651,
14383,
353,
3855,
29872,
434,
29889,
7323,
29898,
29900,
29897,
13,
4706,
565,
13563,
29918,
333,
451,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29901,
13,
9651,
7272,
26324,
29889,
12011,
877,
1451,
271,
338,
451,
6631,
29991,
742,
1510,
29918,
12888,
29922,
5574,
29897,
13,
4706,
1683,
29901,
13,
9651,
1246,
3844,
375,
293,
29889,
802,
1041,
29889,
7662,
29918,
15091,
29898,
13496,
29918,
333,
29897,
13,
13,
9651,
565,
1246,
3844,
375,
293,
29889,
802,
1041,
29889,
275,
29918,
6310,
29898,
13496,
29918,
333,
1125,
13,
18884,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
280,
1351,
29918,
2972,
29918,
4804,
29898,
13496,
29918,
333,
29897,
13,
462,
13,
18884,
7272,
26324,
29889,
4906,
29889,
5628,
877,
29899,
1939,
5853,
7412,
1761,
636,
29905,
29876,
29899,
951,
5555,
478,
29907,
29991,
1495,
13,
9651,
1683,
29901,
13,
18884,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
3167,
29918,
5461,
29898,
13,
462,
1678,
13563,
29918,
333,
29892,
13,
462,
1678,
1246,
3844,
375,
293,
29889,
802,
1041,
29889,
657,
29898,
13496,
29918,
333,
29897,
3366,
1445,
3108,
13,
18884,
1723,
13,
18884,
7272,
26324,
29889,
12011,
877,
29903,
1984,
2986,
1495,
13,
18884,
7272,
26324,
29889,
4906,
29889,
5628,
3552,
29885,
29918,
13496,
29892,
3855,
29872,
434,
511,
8908,
29918,
3502,
786,
29922,
29878,
29918,
17632,
29898,
1552,
29918,
1272,
876,
13,
18884,
7272,
26324,
29889,
4906,
29889,
3445,
368,
29918,
726,
29898,
29888,
28560,
28551,
2986,
5702,
29905,
29876,
29899,
2567,
7412,
292,
3579,
29912,
29939,
29872,
434,
29961,
29900,
3816,
29900,
12258,
1068,
1495,
13,
13,
1678,
1683,
29901,
539,
13,
4706,
565,
13563,
29918,
333,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29901,
13,
9651,
1018,
29901,
13,
18884,
1246,
3844,
375,
293,
29889,
802,
1041,
29889,
8551,
29898,
13496,
29918,
333,
29897,
13,
9651,
5174,
5462,
434,
8915,
29901,
13,
18884,
1209,
13,
13,
9651,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
280,
1351,
29918,
2972,
29918,
4804,
29898,
13496,
29918,
333,
29897,
13,
9651,
7272,
26324,
29889,
4906,
29889,
5628,
877,
14191,
3730,
19941,
278,
678,
271,
29991,
1495,
13,
4706,
1683,
29901,
13,
9651,
7272,
26324,
29889,
12011,
877,
1451,
271,
338,
451,
6631,
29991,
742,
1510,
29918,
12888,
29922,
5574,
29897,
13,
13,
29992,
4032,
29889,
265,
29918,
4906,
29898,
6519,
703,
1456,
1159,
669,
916,
29918,
26705,
29897,
13,
12674,
822,
1708,
29898,
3383,
2643,
29901,
7777,
1125,
13,
1678,
1018,
29901,
13,
4706,
7272,
2643,
3032,
4645,
29889,
657,
29918,
13496,
29918,
14242,
29898,
524,
703,
29899,
29896,
29900,
29900,
29896,
29906,
29929,
29906,
29929,
29900,
29953,
29955,
29929,
29896,
4968,
2643,
29889,
3166,
29918,
1792,
29889,
333,
29897,
13,
1678,
5174,
4911,
3664,
7439,
12654,
424,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
726,
29898,
29967,
6992,
29918,
3289,
3301,
29897,
13,
4706,
736,
13,
1678,
5534,
712,
13,
1678,
454,
29880,
353,
7272,
2643,
29889,
3445,
368,
703,
243,
162,
151,
135,
3579,
7032,
292,
1068,
1159,
13,
1678,
6343,
4097,
353,
7272,
679,
29918,
6406,
2132,
4097,
29898,
4906,
29889,
13496,
29897,
13,
1678,
521,
333,
353,
2643,
29889,
13496,
29889,
333,
13,
13,
1678,
1018,
29901,
13,
4706,
1404,
353,
7272,
3148,
1001,
29889,
657,
29918,
1004,
580,
13,
1678,
5174,
29901,
13,
4706,
1404,
29889,
4102,
29918,
978,
353,
29871,
376,
20907,
29908,
13,
1678,
28336,
353,
1404,
13,
1678,
591,
29893,
353,
28336,
29889,
333,
13,
1678,
1018,
29901,
13,
4706,
396,
13496,
14144,
353,
7272,
3148,
1001,
29889,
657,
29918,
13496,
29898,
305,
333,
29897,
13,
4706,
301,
4346,
29874,
353,
7272,
903,
29889,
657,
29918,
13496,
29918,
14242,
29898,
305,
333,
29892,
705,
29893,
29897,
13,
1678,
5174,
29901,
13,
965,
363,
27443,
297,
6343,
4097,
29901,
13,
462,
418,
565,
27443,
1275,
2643,
29889,
3166,
29918,
1792,
29889,
333,
29901,
259,
13,
462,
3986,
1018,
29901,
13,
462,
795,
2437,
7454,
682,
353,
7272,
903,
29889,
15843,
29918,
13496,
29918,
11569,
568,
29918,
2324,
29898,
305,
333,
29897,
13,
462,
3986,
5174,
29901,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
9872,
29890,
29958,
2528,
592,
408,
4113,
310,
343,
272,
2318,
937,
829,
29890,
28341,
13,
462,
795,
1723,
13,
462,
795,
736,
13,
13,
462,
3986,
1018,
29901,
13,
462,
795,
7272,
3148,
1001,
29889,
7122,
29918,
13496,
29898,
11569,
7454,
682,
29897,
13,
462,
795,
7272,
3148,
1001,
29889,
6717,
29918,
4906,
29898,
4906,
29889,
13496,
29889,
333,
1699,
29902,
8772,
445,
2318,
363,
8743,
4696,
297,
478,
29907,
1159,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
9872,
29890,
29958,
20907,
1404,
7451,
8772,
596,
13563,
829,
29890,
28341,
13,
462,
795,
1723,
13,
13,
462,
3986,
5174,
4911,
2499,
2040,
7439,
12654,
424,
29901,
13,
462,
795,
1209,
13,
462,
3986,
5174,
8960,
408,
321,
29901,
13,
462,
795,
396,
2158,
29898,
29872,
29897,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
285,
29908,
29966,
29890,
29958,
243,
162,
151,
183,
26043,
397,
20340,
4829,
29871,
243,
162,
151,
183,
320,
29876,
2659,
426,
1792,
29889,
4102,
29918,
978,
29913,
8496,
29915,
29873,
5988,
596,
2318,
2861,
304,
9416,
7274,
363,
1404,
7451,
29991,
8561,
1854,
1404,
338,
451,
289,
11310,
297,
2318,
1213,
13,
462,
462,
29871,
6634,
29876,
29905,
29876,
2816,
7522,
2244,
732,
29954,
1300,
314,
29896,
29947,
29900,
29941,
29900,
29946,
304,
596,
6431,
322,
1018,
1449,
829,
29890,
28341,
13,
462,
795,
1723,
13,
462,
795,
1209,
13,
1678,
1018,
29901,
13,
4706,
13563,
14144,
353,
7272,
3148,
1001,
29889,
657,
29918,
13496,
29898,
305,
333,
29897,
13,
4706,
396,
29880,
4346,
29874,
353,
7272,
3132,
29889,
657,
29918,
13496,
29918,
14242,
29898,
305,
333,
29892,
705,
29893,
29897,
13,
1678,
5174,
29901,
13,
4706,
7272,
454,
29880,
29889,
5628,
29898,
13,
9651,
285,
29908,
29966,
29875,
29958,
426,
1792,
29889,
4102,
29918,
978,
29913,
4911,
7451,
451,
297,
445,
13563,
29892,
26579,
4113,
304,
3638,
847,
1456,
1899,
363,
937,
931,
470,
788,
426,
1792,
29889,
4102,
29918,
978,
29913,
7522,
829,
29875,
11903,
13,
4706,
1723,
13,
4706,
736,
418,
13,
1678,
10004,
29918,
333,
353,
2643,
29889,
3166,
29918,
1792,
29889,
333,
13,
1678,
10004,
29918,
978,
353,
2643,
29889,
3166,
29918,
1792,
29889,
4102,
29918,
978,
13,
1678,
7272,
454,
29880,
29889,
5628,
703,
1068,
1649,
7974,
292,
3575,
9362,
1649,
1068,
1159,
13,
1678,
10004,
29918,
333,
353,
2643,
29889,
3166,
29918,
1792,
29889,
333,
13,
1678,
1404,
29918,
333,
353,
2643,
29889,
3166,
29918,
1792,
29889,
333,
13,
1678,
10004,
29918,
978,
353,
2643,
29889,
3166,
29918,
1792,
29889,
4102,
29918,
978,
13,
1678,
1404,
29918,
978,
353,
2643,
29889,
3166,
29918,
1792,
29889,
4102,
29918,
978,
13,
1678,
364,
20571,
353,
376,
3366,
29974,
1792,
29918,
978,
13578,
850,
29873,
29887,
597,
1792,
29973,
333,
543,
29974,
710,
29898,
1792,
29918,
333,
7240,
1159,
29908,
13,
13,
1678,
2346,
353,
6629,
13,
1678,
363,
474,
297,
2643,
29889,
6519,
29961,
29896,
29901,
5387,
13,
4706,
2346,
4619,
525,
525,
718,
851,
29898,
29875,
29897,
13,
1678,
1596,
29898,
1972,
29897,
13,
1678,
7272,
454,
29880,
29889,
5628,
703,
1068,
1649,
7032,
292,
3575,
9362,
1649,
1068,
1159,
13,
1678,
343,
11671,
29918,
25707,
353,
8853,
4830,
1115,
376,
29890,
4405,
2881,
29961,
1062,
29922,
29885,
29946,
29874,
29962,
9092,
13,
1678,
1018,
29901,
13,
4706,
2582,
353,
612,
15907,
7974,
29898,
1972,
29892,
4236,
29918,
9902,
29922,
29896,
467,
517,
29918,
8977,
580,
13,
4706,
3142,
353,
285,
29908,
991,
597,
19567,
29889,
510,
29912,
9902,
29961,
29900,
22322,
2271,
29918,
2146,
600,
861,
2033,
5038,
13,
4706,
396,
2158,
29898,
9902,
29897,
13,
4706,
3611,
353,
2582,
29961,
29900,
29962,
3366,
3257,
3108,
7503,
29946,
29900,
29962,
4706,
13,
4706,
266,
21145,
353,
2582,
29961,
29900,
29962,
3366,
386,
17771,
2234,
3108,
29961,
29900,
29962,
13,
4706,
28968,
29918,
978,
353,
285,
29915,
386,
3774,
29912,
3257,
1836,
6173,
29915,
13,
4706,
28968,
353,
7274,
29889,
657,
29898,
386,
21145,
29892,
2758,
29918,
17886,
29879,
29922,
5574,
29897,
13,
4706,
1722,
29898,
386,
3774,
29918,
978,
29892,
525,
29893,
29890,
2824,
3539,
29898,
386,
3774,
29889,
3051,
29897,
13,
4706,
14385,
353,
2582,
29961,
29900,
29962,
3366,
19708,
3108,
13,
4706,
3142,
29918,
2146,
600,
861,
353,
2582,
29961,
29900,
29962,
3366,
2271,
29918,
2146,
600,
861,
3108,
13,
4706,
8386,
353,
2582,
29961,
29900,
29962,
3366,
7406,
3108,
13,
13,
1678,
5174,
8960,
408,
321,
29901,
13,
4706,
7272,
454,
29880,
29889,
5628,
703,
29903,
549,
451,
1476,
29889,
15870,
1790,
4823,
470,
5505,
24779,
372,
6284,
23157,
13,
4706,
1596,
29898,
710,
29898,
29872,
876,
13,
4706,
736,
13,
13,
1678,
12247,
353,
512,
1220,
2558,
3377,
9802,
786,
29898,
13,
9651,
518,
1678,
13,
18884,
518,
13,
462,
18884,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
877,
243,
162,
150,
153,
7412,
1761,
742,
6939,
29918,
1272,
2433,
1456,
1761,
5477,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
877,
6823,
29871,
229,
146,
178,
13420,
6939,
29918,
1272,
2433,
6510,
1495,
13,
462,
13,
18884,
21251,
462,
418,
13,
18884,
518,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
29898,
13,
462,
4706,
1426,
543,
24709,
1551,
14711,
29871,
243,
162,
145,
175,
613,
13,
462,
4706,
3142,
29922,
29888,
29908,
29912,
2271,
27195,
13,
13,
18884,
21251,
13,
18884,
518,
4706,
13,
462,
1678,
512,
1220,
2558,
3377,
3125,
29898,
13,
462,
4706,
1426,
543,
229,
160,
143,
23186,
613,
13,
462,
4706,
6939,
29918,
1272,
2433,
25932,
1495,
13,
13,
18884,
4514,
462,
795,
13,
9651,
4514,
13,
4706,
1723,
13,
1678,
13877,
29918,
1609,
353,
2643,
29889,
3166,
29918,
1792,
29889,
4102,
29918,
978,
13,
1678,
7272,
5706,
29918,
11911,
29898,
3827,
287,
29918,
1609,
29892,
3611,
29892,
8386,
29892,
14385,
29892,
266,
21145,
29897,
259,
13,
1678,
934,
29918,
2084,
353,
7272,
29105,
29889,
13441,
29898,
19567,
29889,
10382,
29898,
2271,
876,
13,
259,
13,
1678,
565,
2643,
29889,
13496,
29889,
333,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29901,
13,
4706,
2602,
353,
7272,
712,
1041,
29889,
649,
29898,
4906,
29889,
13496,
29889,
333,
29892,
934,
29922,
1445,
29918,
2084,
29897,
13,
4706,
3855,
29872,
434,
353,
712,
29889,
657,
29898,
4906,
29889,
13496,
29889,
333,
29897,
13,
4706,
269,
29918,
978,
353,
3611,
13,
4706,
364,
29918,
1609,
353,
2643,
29889,
3166,
29918,
1792,
13,
4706,
1180,
353,
934,
29918,
2084,
13,
4706,
9773,
519,
353,
518,
29879,
29918,
978,
29892,
364,
29918,
1609,
29892,
1180,
29962,
13,
4706,
3855,
29872,
434,
29889,
4397,
29898,
4397,
519,
29897,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
21596,
29898,
13,
4706,
15373,
543,
8394,
29889,
2732,
613,
29871,
13,
4706,
5777,
683,
29922,
29888,
29908,
29937,
229,
134,
166,
3575,
13877,
4823,
3579,
802,
6742,
1068,
472,
2602,
426,
3283,
29913,
29991,
613,
13,
4706,
8908,
29918,
3502,
786,
29922,
1989,
3377,
29897,
13,
4706,
2897,
29889,
5992,
703,
8394,
29889,
2732,
1159,
13,
4706,
736,
7272,
454,
29880,
29889,
8143,
580,
13,
1678,
1683,
29901,
13,
4706,
13563,
29918,
333,
353,
2643,
29889,
13496,
29889,
333,
13,
4706,
712,
29961,
13496,
29918,
333,
29962,
353,
5159,
13,
4706,
3855,
29872,
434,
353,
712,
29889,
657,
29898,
4906,
29889,
13496,
29889,
333,
29897,
13,
4706,
269,
29918,
978,
353,
3611,
632,
13,
4706,
364,
29918,
1609,
353,
2643,
29889,
3166,
29918,
1792,
13,
4706,
1180,
353,
934,
29918,
2084,
13,
4706,
9773,
519,
353,
518,
29879,
29918,
978,
29892,
364,
29918,
1609,
29892,
1180,
29962,
539,
13,
4706,
3855,
29872,
434,
29889,
4397,
29898,
4397,
519,
29897,
13,
4706,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
7122,
29918,
2972,
29918,
4804,
29898,
4906,
29889,
13496,
29889,
333,
29892,
934,
29918,
2084,
29897,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
21596,
29898,
13,
4706,
15373,
543,
8394,
29889,
2732,
613,
13,
4706,
8908,
29918,
3502,
786,
29922,
1989,
3377,
29892,
13,
4706,
5777,
683,
543,
30965,
30598,
3579,
13454,
292,
1068,
1244,
278,
4823,
13877,
491,
6571,
3025,
402,
1300,
314,
29915,
29903,
6125,
11273,
29871,
243,
162,
155,
159,
1642,
4830,
29898,
13,
4706,
2643,
29889,
3166,
29918,
1792,
29889,
358,
291,
580,
13,
4706,
10353,
13,
1678,
1723,
13,
4706,
2897,
29889,
5992,
703,
8394,
29889,
2732,
1159,
13,
4706,
736,
7272,
454,
29880,
29889,
8143,
580,
13,
13,
13,
29992,
4032,
29889,
265,
29918,
4906,
29898,
13,
1678,
18094,
29889,
6519,
703,
29881,
1456,
1159,
13,
1678,
669,
18094,
29889,
2972,
13,
1678,
669,
3695,
18094,
29889,
287,
1573,
13,
29897,
13,
12674,
822,
316,
29872,
3298,
29898,
4645,
29901,
12477,
29892,
2643,
29918,
29901,
7777,
1125,
13,
1678,
1018,
29901,
13,
4706,
7272,
2643,
3032,
4645,
29889,
657,
29918,
13496,
29918,
14242,
29898,
524,
703,
29899,
29896,
29900,
29900,
29896,
29906,
29929,
29906,
29929,
29900,
29953,
29955,
29929,
29896,
4968,
2643,
29889,
3166,
29918,
1792,
29889,
333,
29897,
13,
1678,
5174,
4911,
3664,
7439,
12654,
424,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
726,
29898,
29967,
6992,
29918,
3289,
3301,
29897,
13,
4706,
736,
13,
1678,
5534,
712,
13,
1678,
454,
29880,
353,
7272,
2643,
5396,
3445,
368,
703,
243,
162,
151,
135,
3579,
7032,
292,
1068,
1159,
13,
1678,
6343,
4097,
353,
7272,
679,
29918,
6406,
2132,
4097,
29898,
4906,
5396,
13496,
29897,
13,
1678,
521,
333,
353,
2643,
5396,
13496,
29889,
333,
13,
1678,
1018,
29901,
13,
4706,
1404,
353,
7272,
3148,
1001,
29889,
657,
29918,
1004,
580,
13,
1678,
5174,
29901,
13,
4706,
1404,
29889,
4102,
29918,
978,
353,
29871,
9872,
5813,
11903,
13,
1678,
28336,
353,
1404,
13,
1678,
591,
29893,
353,
28336,
29889,
333,
13,
1678,
1018,
29901,
13,
4706,
396,
13496,
14144,
353,
7272,
3148,
1001,
29889,
657,
29918,
13496,
29898,
305,
333,
29897,
13,
4706,
301,
4346,
29874,
353,
7272,
3132,
29889,
657,
29918,
13496,
29918,
14242,
29898,
305,
333,
29892,
705,
29893,
29897,
13,
1678,
5174,
29901,
13,
965,
363,
27443,
297,
6343,
4097,
29901,
13,
462,
418,
565,
27443,
1275,
2643,
5396,
3166,
29918,
1792,
29889,
333,
29901,
259,
13,
462,
3986,
1018,
29901,
13,
462,
795,
2437,
7454,
682,
353,
7272,
3132,
29889,
15843,
29918,
13496,
29918,
11569,
568,
29918,
2324,
29898,
305,
333,
29897,
13,
462,
3986,
5174,
29901,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
9872,
29890,
29958,
2528,
592,
408,
4113,
310,
343,
272,
2318,
937,
829,
29890,
28341,
13,
462,
795,
1723,
13,
462,
795,
736,
13,
13,
462,
3986,
1018,
29901,
13,
462,
795,
7272,
3148,
1001,
29889,
7122,
29918,
13496,
29898,
11569,
7454,
682,
29897,
13,
462,
795,
7272,
3148,
1001,
29889,
6717,
29918,
4906,
29898,
4906,
5396,
13496,
29889,
333,
1699,
29902,
8772,
445,
2318,
363,
8743,
4696,
297,
478,
29907,
1159,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
9872,
29890,
29958,
20907,
1404,
7451,
8772,
596,
13563,
829,
29890,
28341,
13,
462,
795,
1723,
13,
13,
462,
3986,
5174,
4911,
2499,
2040,
7439,
12654,
424,
29901,
13,
462,
795,
1209,
13,
462,
3986,
5174,
8960,
408,
321,
29901,
13,
462,
795,
396,
2158,
29898,
29872,
29897,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
285,
29908,
29966,
29890,
29958,
243,
162,
151,
183,
26043,
397,
20340,
4829,
29871,
243,
162,
151,
183,
320,
29876,
2659,
426,
1792,
29889,
4102,
29918,
978,
29913,
8496,
29915,
29873,
5988,
596,
2318,
2861,
304,
9416,
7274,
363,
1404,
7451,
29991,
8561,
1854,
1404,
338,
451,
289,
11310,
297,
2318,
1213,
13,
462,
462,
29871,
6634,
29876,
29905,
29876,
2816,
7522,
788,
732,
29954,
1300,
314,
29896,
29947,
29900,
29941,
29900,
29946,
304,
596,
6431,
322,
1018,
1449,
829,
29890,
28341,
13,
462,
795,
1723,
13,
462,
795,
1209,
13,
1678,
1018,
29901,
13,
4706,
13563,
14144,
353,
7272,
3148,
1001,
29889,
657,
29918,
13496,
29898,
305,
333,
29897,
13,
4706,
396,
29880,
4346,
29874,
353,
7272,
3132,
29889,
657,
29918,
13496,
29918,
14242,
29898,
305,
333,
29892,
705,
29893,
29897,
13,
1678,
5174,
29901,
13,
4706,
7272,
454,
29880,
29889,
5628,
29898,
13,
9651,
285,
29908,
29966,
29875,
29958,
426,
1792,
29889,
4102,
29918,
978,
29913,
4911,
7451,
451,
297,
445,
13563,
29892,
26579,
4113,
304,
3638,
847,
1456,
1899,
363,
937,
931,
470,
788,
426,
1792,
29889,
4102,
29918,
978,
29913,
7522,
829,
29875,
11903,
13,
4706,
1723,
13,
4706,
736,
462,
632,
13,
1678,
13877,
29918,
1609,
353,
2643,
5396,
3166,
29918,
1792,
29889,
4102,
29918,
978,
1678,
13,
13,
1678,
1426,
353,
2643,
5396,
726,
29889,
5451,
703,
9162,
29871,
29896,
29897,
13,
1678,
2346,
29891,
353,
1426,
29961,
29896,
29962,
13,
1678,
620,
353,
454,
29880,
13,
1678,
7272,
620,
29889,
5628,
29898,
29888,
29908,
7974,
292,
29871,
243,
162,
148,
131,
243,
162,
148,
131,
243,
162,
148,
131,
363,
23230,
1972,
29891,
10114,
373,
316,
29872,
3298,
1159,
13,
1678,
1018,
29901,
13,
4706,
564,
29939,
353,
9033,
29984,
703,
991,
597,
1552,
279,
29939,
29889,
11345,
1159,
13,
4706,
364,
353,
7272,
564,
29939,
29889,
311,
29872,
3298,
29898,
1972,
29922,
1972,
29891,
29892,
4046,
29922,
29896,
29897,
13,
4706,
3611,
353,
364,
29961,
29900,
29962,
3366,
3257,
3108,
13,
4706,
14385,
353,
938,
29898,
29878,
29961,
29900,
29962,
3366,
19708,
20068,
13,
4706,
266,
21145,
353,
364,
29961,
29900,
29962,
3366,
386,
21145,
3108,
13,
4706,
7664,
353,
364,
29961,
29900,
29962,
3366,
442,
391,
3108,
13,
4706,
3142,
353,
364,
29961,
29900,
29962,
3366,
2271,
3108,
13,
1678,
5174,
29901,
13,
4706,
7272,
620,
29889,
5628,
29898,
13,
9651,
376,
9692,
5449,
635,
9531,
29892,
887,
10575,
5244,
1551,
3575,
4223,
3850,
13,
4706,
1723,
13,
4706,
338,
29918,
1456,
292,
353,
7700,
13,
4706,
736,
13,
1678,
12247,
353,
512,
1220,
2558,
3377,
9802,
786,
29898,
13,
308,
518,
1678,
13,
632,
518,
13,
462,
512,
1220,
2558,
3377,
3125,
877,
243,
162,
150,
153,
7412,
1761,
742,
6939,
29918,
1272,
2433,
1456,
1761,
5477,
13,
462,
512,
1220,
2558,
3377,
3125,
877,
6823,
29871,
229,
146,
178,
13420,
6939,
29918,
1272,
2433,
6510,
1495,
418,
13,
632,
21251,
462,
418,
13,
632,
518,
13,
462,
512,
1220,
2558,
3377,
3125,
29898,
13,
462,
268,
1426,
543,
1293,
264,
1551,
897,
29872,
3298,
29871,
243,
162,
145,
175,
613,
13,
462,
268,
3142,
29922,
29888,
29908,
29912,
2271,
27195,
13,
13,
632,
21251,
13,
632,
518,
4706,
13,
462,
512,
1220,
2558,
3377,
3125,
29898,
13,
462,
268,
1426,
543,
229,
160,
143,
23186,
613,
13,
462,
268,
6939,
29918,
1272,
2433,
25932,
1495,
13,
13,
9651,
4514,
462,
539,
13,
308,
4514,
13,
268,
1723,
13,
1678,
934,
29918,
2084,
29922,
7272,
29105,
29889,
13441,
29898,
29893,
657,
29889,
10382,
29898,
2271,
876,
13,
1678,
7272,
620,
29889,
5628,
703,
5631,
1218,
498,
21145,
1159,
13,
1678,
7272,
5706,
29918,
11911,
29898,
3827,
287,
29918,
1609,
29892,
3611,
29892,
7664,
29892,
14385,
29892,
266,
21145,
29897,
13,
1678,
565,
2643,
5396,
13496,
29889,
333,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29901,
13,
4706,
7272,
620,
29889,
5628,
703,
4676,
297,
9521,
1159,
13,
4706,
2602,
353,
7272,
712,
1041,
29889,
649,
29898,
4906,
5396,
13496,
29889,
333,
29892,
934,
29922,
1445,
29918,
2084,
29897,
4706,
13,
4706,
3855,
29872,
434,
353,
712,
29889,
657,
29898,
4906,
5396,
13496,
29889,
333,
29897,
13,
4706,
269,
29918,
978,
353,
3611,
13,
4706,
364,
29918,
1609,
353,
2643,
5396,
3166,
29918,
1792,
13,
4706,
1180,
353,
934,
29918,
2084,
13,
4706,
9773,
519,
353,
518,
29879,
29918,
978,
29892,
364,
29918,
1609,
29892,
1180,
29962,
13,
4706,
3855,
29872,
434,
29889,
4397,
29898,
4397,
519,
29897,
13,
4706,
7272,
620,
29889,
5628,
29918,
726,
29898,
29888,
29908,
21238,
29922,
396,
30598,
229,
134,
166,
5462,
6742,
472,
2602,
426,
3283,
27195,
13,
1678,
1683,
29901,
13,
4706,
7272,
620,
29889,
5628,
29918,
726,
703,
21238,
29922,
30965,
30598,
7412,
292,
18598,
1159,
13,
4706,
13563,
29918,
333,
353,
2643,
5396,
13496,
29889,
333,
13,
4706,
712,
29961,
13496,
29918,
333,
29962,
353,
5159,
13,
4706,
3855,
29872,
434,
353,
712,
29889,
657,
29898,
4906,
5396,
13496,
29889,
333,
29897,
13,
4706,
269,
29918,
978,
353,
3611,
13,
4706,
364,
29918,
1609,
353,
2643,
5396,
3166,
29918,
1792,
13,
4706,
1180,
353,
934,
29918,
2084,
13,
4706,
9773,
519,
353,
518,
29879,
29918,
978,
29892,
364,
29918,
1609,
29892,
1180,
29962,
13,
4706,
3855,
29872,
434,
29889,
4397,
29898,
4397,
519,
29897,
13,
4706,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
7122,
29918,
2972,
29918,
4804,
29898,
4906,
5396,
13496,
29889,
333,
29892,
934,
29918,
2084,
29897,
13,
13,
1678,
7272,
620,
29889,
8143,
580,
13,
13,
1678,
286,
353,
7272,
3132,
29889,
6717,
29918,
21596,
29898,
13,
4706,
13563,
29918,
333,
29922,
4906,
5396,
13496,
29889,
333,
29892,
13,
4706,
8908,
29918,
3502,
786,
29922,
1989,
3377,
29892,
13,
4706,
15373,
543,
8394,
29889,
2732,
613,
13,
4706,
5777,
683,
29922,
29888,
29908,
13454,
292,
15974,
3257,
18456,
29912,
2271,
1800,
23306,
897,
29872,
3298,
29908,
13,
1678,
1723,
29871,
13,
1678,
2897,
29889,
5992,
703,
8394,
29889,
2732,
1159,
13,
13,
13,
29992,
4032,
29889,
265,
29918,
4906,
29898,
13,
1678,
18094,
29889,
6519,
703,
29879,
1456,
1159,
13,
1678,
669,
18094,
29889,
2972,
13,
1678,
669,
3695,
18094,
29889,
287,
1573,
13,
29897,
13,
12674,
822,
432,
2363,
29874,
485,
29876,
29898,
4645,
29901,
12477,
29892,
2643,
29918,
29901,
7777,
1125,
13,
1678,
1018,
29901,
13,
4706,
7272,
2643,
3032,
4645,
29889,
657,
29918,
13496,
29918,
14242,
29898,
524,
703,
29899,
29896,
29900,
29900,
29896,
29906,
29929,
29906,
29929,
29900,
29953,
29955,
29929,
29896,
4968,
2643,
29889,
3166,
29918,
1792,
29889,
333,
29897,
13,
1678,
5174,
4911,
3664,
7439,
12654,
424,
29901,
13,
4706,
7272,
2643,
29889,
3445,
368,
29918,
726,
29898,
29967,
6992,
29918,
3289,
3301,
29897,
13,
4706,
736,
13,
1678,
5534,
712,
13,
1678,
454,
29880,
353,
7272,
2643,
5396,
3445,
368,
703,
243,
162,
151,
135,
3579,
7032,
292,
1068,
1159,
13,
1678,
6343,
4097,
353,
7272,
679,
29918,
6406,
2132,
4097,
29898,
4906,
5396,
13496,
29897,
13,
1678,
521,
333,
353,
2643,
5396,
13496,
29889,
333,
13,
1678,
1018,
29901,
13,
4706,
1404,
353,
7272,
3148,
1001,
29889,
657,
29918,
1004,
580,
13,
1678,
5174,
29901,
13,
4706,
1404,
29889,
4102,
29918,
978,
353,
29871,
376,
29954,
1300,
314,
29915,
29903,
6125,
11273,
29908,
13,
1678,
28336,
353,
1404,
13,
1678,
591,
29893,
353,
28336,
29889,
333,
13,
1678,
1018,
29901,
13,
4706,
396,
13496,
14144,
353,
7272,
3148,
1001,
29889,
657,
29918,
13496,
29898,
305,
333,
29897,
13,
4706,
301,
4346,
29874,
353,
7272,
3132,
29889,
657,
29918,
13496,
29918,
14242,
29898,
305,
333,
29892,
705,
29893,
29897,
13,
1678,
5174,
29901,
13,
965,
363,
27443,
297,
6343,
4097,
29901,
13,
462,
418,
565,
27443,
1275,
2643,
5396,
3166,
29918,
1792,
29889,
333,
29901,
259,
13,
462,
3986,
1018,
29901,
13,
462,
795,
2437,
7454,
682,
353,
7272,
3132,
29889,
15843,
29918,
13496,
29918,
11569,
568,
29918,
2324,
29898,
305,
333,
29897,
13,
462,
3986,
5174,
29901,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
9872,
29890,
29958,
2528,
592,
408,
4113,
310,
343,
272,
2318,
937,
829,
29890,
28341,
13,
462,
795,
1723,
13,
462,
795,
736,
13,
13,
462,
3986,
1018,
29901,
13,
462,
795,
7272,
3148,
1001,
29889,
7122,
29918,
13496,
29898,
11569,
7454,
682,
29897,
13,
462,
795,
7272,
3148,
1001,
29889,
6717,
29918,
4906,
29898,
4906,
5396,
13496,
29889,
333,
1699,
29902,
8772,
445,
2318,
363,
8743,
4696,
297,
478,
29907,
1159,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
9872,
29890,
29958,
20907,
1404,
7451,
8772,
596,
13563,
829,
29890,
28341,
13,
462,
795,
1723,
13,
13,
462,
3986,
5174,
4911,
2499,
2040,
7439,
12654,
424,
29901,
13,
462,
795,
1209,
13,
462,
3986,
5174,
8960,
408,
321,
29901,
13,
462,
795,
396,
2158,
29898,
29872,
29897,
13,
462,
795,
7272,
454,
29880,
29889,
5628,
29898,
13,
462,
462,
29871,
285,
29908,
29966,
29890,
29958,
243,
162,
151,
183,
26043,
397,
20340,
4829,
29871,
243,
162,
151,
183,
320,
29876,
2659,
426,
1792,
29889,
4102,
29918,
978,
29913,
8496,
29915,
29873,
5988,
596,
2318,
2861,
304,
9416,
7274,
363,
1404,
7451,
29991,
8561,
1854,
1404,
338,
451,
289,
11310,
297,
2318,
1213,
13,
462,
462,
29871,
6634,
29876,
29905,
29876,
2816,
7522,
788,
732,
29954,
1300,
314,
29896,
29947,
29900,
29941,
29900,
29946,
304,
596,
6431,
322,
1018,
1449,
829,
29890,
28341,
13,
462,
795,
1723,
13,
462,
795,
1209,
13,
1678,
1018,
29901,
13,
4706,
13563,
14144,
353,
7272,
3148,
1001,
29889,
657,
29918,
13496,
29898,
305,
333,
29897,
13,
4706,
396,
29880,
4346,
29874,
353,
7272,
3132,
29889,
657,
29918,
13496,
29918,
14242,
29898,
305,
333,
29892,
705,
29893,
29897,
13,
1678,
5174,
29901,
13,
4706,
7272,
454,
29880,
29889,
5628,
29898,
13,
9651,
9872,
29875,
29958,
16876,
4911,
7451,
451,
297,
445,
13563,
29892,
26579,
4113,
304,
3638,
847,
1456,
1899,
363,
937,
931,
470,
788,
20255,
7522,
829,
29875,
11903,
13,
4706,
1723,
13,
4706,
736,
418,
13,
1678,
13877,
29918,
1609,
353,
2643,
5396,
3166,
29918,
1792,
29889,
4102,
29918,
978,
13,
1678,
13563,
29918,
333,
29922,
4906,
5396,
13496,
29889,
333,
13,
1678,
1426,
353,
2643,
5396,
726,
29889,
5451,
703,
9162,
29871,
29896,
29897,
13,
1678,
2346,
353,
1426,
29961,
29896,
29962,
13,
1678,
620,
353,
454,
29880,
13,
1678,
7272,
620,
29889,
5628,
29898,
29888,
29908,
7974,
292,
363,
23230,
1972,
10114,
373,
432,
601,
872,
485,
29876,
1159,
13,
1678,
1018,
29901,
13,
4706,
7465,
411,
263,
601,
1124,
29889,
4032,
7317,
580,
408,
4867,
29901,
13,
9651,
7465,
411,
4867,
29889,
657,
29898,
13,
18884,
285,
29908,
991,
597,
29926,
2363,
29874,
485,
29876,
2754,
29889,
29890,
29882,
912,
29877,
29889,
2679,
29914,
2914,
13401,
1972,
3790,
1972,
5038,
13,
9651,
1723,
408,
4613,
29901,
13,
18884,
364,
353,
4390,
29889,
18132,
29898,
20675,
4613,
29889,
726,
3101,
13,
4706,
269,
978,
353,
364,
29961,
29900,
29962,
3366,
21453,
3108,
13,
4706,
2243,
682,
353,
364,
29961,
29900,
29962,
3366,
9799,
29918,
2271,
3108,
13,
4706,
269,
2976,
414,
353,
364,
29961,
29900,
29962,
3366,
2976,
414,
3108,
13,
4706,
380,
29882,
3774,
353,
364,
29961,
29900,
29962,
3366,
3027,
3108,
13,
4706,
269,
19708,
353,
938,
29898,
29878,
29961,
29900,
29962,
3366,
19708,
20068,
13,
1678,
5174,
8960,
408,
321,
29901,
13,
4706,
7272,
620,
29889,
5628,
29898,
13,
9651,
376,
9692,
5449,
635,
9531,
18565,
887,
10575,
5244,
1551,
3575,
4223,
1213,
13,
4706,
1723,
13,
4706,
1596,
29898,
710,
29898,
29872,
876,
13,
4706,
338,
29918,
1456,
292,
353,
7700,
13,
4706,
736,
13,
1678,
12247,
353,
512,
1220,
2558,
3377,
9802,
786,
29898,
13,
308,
518,
1678,
13,
632,
518,
13,
1669,
512,
1220,
2558,
3377,
3125,
877,
243,
162,
150,
153,
7412,
1761,
742,
6939,
29918,
1272,
2433,
1456,
1761,
5477,
13,
1669,
512,
1220,
2558,
3377,
3125,
877,
6823,
29871,
229,
146,
178,
13420,
6939,
29918,
1272,
2433,
6510,
1495,
1678,
13,
632,
21251,
462,
418,
13,
632,
518,
13,
1669,
512,
1220,
2558,
3377,
3125,
29898,
13,
462,
259,
1426,
543,
17242,
5020,
15190,
17368,
613,
13,
462,
259,
3142,
2433,
991,
597,
29873,
29889,
1004,
29914,
29954,
1300,
314,
29903,
29918,
29924,
381,
729,
1495,
13,
632,
21251,
13,
632,
518,
4706,
13,
1669,
512,
1220,
2558,
3377,
3125,
29898,
13,
462,
259,
1426,
543,
229,
160,
143,
23186,
613,
13,
462,
259,
6939,
29918,
1272,
2433,
25932,
1495,
13,
13,
9651,
4514,
462,
965,
13,
308,
4514,
13,
268,
1723,
13,
1678,
934,
29918,
2084,
29922,
7272,
29105,
29889,
13441,
29898,
29893,
657,
29889,
10382,
29898,
29879,
2324,
876,
13,
1678,
565,
2643,
5396,
13496,
29889,
333,
297,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
4925,
29918,
29883,
4293,
29901,
13,
4706,
2602,
353,
7272,
712,
1041,
29889,
649,
29898,
4906,
5396,
13496,
29889,
333,
29892,
934,
29922,
1445,
29918,
2084,
29897,
13,
4706,
3855,
29872,
434,
353,
712,
29889,
657,
29898,
4906,
5396,
13496,
29889,
333,
29897,
13,
4706,
269,
29918,
978,
353,
269,
978,
13,
4706,
364,
29918,
1609,
353,
2643,
5396,
3166,
29918,
1792,
13,
4706,
1180,
353,
934,
29918,
2084,
13,
4706,
9773,
519,
353,
518,
29879,
29918,
978,
29892,
364,
29918,
1609,
29892,
1180,
29962,
13,
4706,
3855,
29872,
434,
29889,
4397,
29898,
4397,
519,
29897,
13,
4706,
7272,
620,
29889,
8143,
580,
13,
4706,
286,
353,
7272,
3132,
29889,
6717,
29918,
21596,
29898,
13,
9651,
13563,
29918,
333,
29922,
4906,
5396,
13496,
29889,
333,
29892,
13,
9651,
8908,
29918,
3502,
786,
29922,
1989,
3377,
29892,
13,
9651,
15373,
543,
8394,
29889,
2732,
613,
13,
9651,
5777,
683,
29922,
29888,
29908,
29937,
30598,
229,
134,
166,
5462,
6742,
472,
2602,
426,
3283,
17671,
13,
308,
13,
4706,
1723,
9651,
13,
9651,
13,
1678,
1683,
29901,
13,
4706,
7272,
620,
29889,
5628,
29918,
726,
703,
30965,
30598,
7412,
292,
18598,
1159,
13,
4706,
13563,
29918,
333,
353,
2643,
5396,
13496,
29889,
333,
13,
4706,
712,
29961,
13496,
29918,
333,
29962,
353,
5159,
13,
4706,
3855,
29872,
434,
353,
712,
29889,
657,
29898,
4906,
5396,
13496,
29889,
333,
29897,
13,
4706,
269,
29918,
978,
353,
269,
978,
13,
4706,
364,
29918,
1609,
353,
2643,
5396,
3166,
29918,
1792,
13,
4706,
1180,
353,
934,
29918,
2084,
13,
4706,
9773,
519,
353,
518,
29879,
29918,
978,
29892,
364,
29918,
1609,
29892,
1180,
29962,
13,
4706,
3855,
29872,
434,
29889,
4397,
29898,
4397,
519,
29897,
13,
4706,
1246,
3844,
375,
293,
29889,
2272,
29873,
27354,
4293,
29889,
7122,
29918,
2972,
29918,
4804,
29898,
4906,
5396,
13496,
29889,
333,
29892,
934,
29918,
2084,
29897,
13,
1678,
7272,
620,
29889,
5628,
703,
5631,
1218,
498,
21145,
23157,
13,
1678,
7272,
5706,
29918,
11911,
29898,
3827,
287,
29918,
1609,
29892,
269,
978,
29892,
269,
2976,
414,
29892,
269,
19708,
29892,
380,
29882,
3774,
29897,
13,
1678,
7272,
620,
29889,
8143,
580,
13,
1678,
286,
353,
7272,
3132,
29889,
6717,
29918,
21596,
29898,
13,
4706,
13563,
29918,
333,
29922,
4906,
5396,
13496,
29889,
333,
29892,
13,
4706,
8908,
29918,
3502,
786,
29922,
1989,
3377,
29892,
13,
4706,
15373,
543,
8394,
29889,
2732,
613,
13,
4706,
5777,
683,
29922,
29888,
29908,
13454,
292,
426,
29879,
978,
29913,
23306,
435,
2363,
29874,
485,
29876,
613,
13,
308,
13,
1678,
1723,
13,
1678,
2897,
29889,
5992,
703,
8394,
29889,
2732,
1159,
13,
13,
29937,
6975,
318,
1303,
599,
29889,
960,
1303,
390,
2890,
4162,
1783,
15626,
13,
2
] |
codesignal/arcade/python/intro_51_delete_digit.py | tinesife94/random | 0 | 104224 | <reponame>tinesife94/random
def solution(n):
s = str(n)
return max(int('{}{}'.format(s[:i], s[i+1:])) for i in range(len(s)))
| [
1,
529,
276,
1112,
420,
29958,
29873,
1475,
1607,
29929,
29946,
29914,
8172,
13,
1753,
1650,
29898,
29876,
1125,
13,
1678,
269,
353,
851,
29898,
29876,
29897,
13,
1678,
736,
4236,
29898,
524,
877,
29912,
1157,
29913,
4286,
4830,
29898,
29879,
7503,
29875,
1402,
269,
29961,
29875,
29974,
29896,
29901,
12622,
363,
474,
297,
3464,
29898,
2435,
29898,
29879,
4961,
13,
2
] |
elasticapm/contrib/starlette/__init__.py | lavr/apm-agent-python | 0 | 195435 | # BSD 3-Clause License
#
# Copyright (c) 2012, the Sentry Team, see AUTHORS for more details
# Copyright (c) 2019, Elasticsearch BV
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
from __future__ import absolute_import
import starlette
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
from starlette.requests import Request
from starlette.responses import Response
from starlette.types import ASGIApp
import elasticapm
import elasticapm.instrumentation.control
from elasticapm.base import Client
from elasticapm.conf import constants
from elasticapm.contrib.asyncio.traces import set_context
from elasticapm.contrib.starlette.utils import get_data_from_request, get_data_from_response
from elasticapm.utils.disttracing import TraceParent
from elasticapm.utils.logging import get_logger
logger = get_logger("elasticapm.errors.client")
def make_apm_client(config: dict, client_cls=Client, **defaults) -> Client:
"""Builds ElasticAPM client.
Args:
config (dict): Dictionary of Client configuration. All keys must be uppercase. See `elasticapm.conf.Config`.
client_cls (Client): Must be Client or its child.
**defaults: Additional parameters for Client. See `elasticapm.base.Client`
Returns:
Client
"""
if "framework_name" not in defaults:
defaults["framework_name"] = "starlette"
defaults["framework_version"] = starlette.__version__
return client_cls(config, **defaults)
class ElasticAPM(BaseHTTPMiddleware):
"""
Starlette / FastAPI middleware for Elastic APM capturing.
>>> elasticapm = make_apm_client({
>>> 'SERVICE_NAME': 'myapp',
>>> 'DEBUG': True,
>>> 'SERVER_URL': 'http://localhost:8200',
>>> 'CAPTURE_HEADERS': True,
>>> 'CAPTURE_BODY': 'all'
>>> })
>>> app.add_middleware(ElasticAPM, client=elasticapm)
Pass an arbitrary APP_NAME and SECRET_TOKEN::
>>> elasticapm = ElasticAPM(app, service_name='myapp', secret_token='<PASSWORD>')
Pass an explicit client::
>>> elasticapm = ElasticAPM(app, client=client)
Automatically configure logging::
>>> elasticapm = ElasticAPM(app, logging=True)
Capture an exception::
>>> try:
>>> 1 / 0
>>> except ZeroDivisionError:
>>> elasticapm.capture_exception()
Capture a message::
>>> elasticapm.capture_message('hello, world!')
"""
def __init__(self, app: ASGIApp, client: Client):
"""
Args:
app (ASGIApp): Starlette app
client (Client): ElasticAPM Client
"""
self.client = client
if self.client.config.instrument:
elasticapm.instrumentation.control.instrument()
super().__init__(app)
async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response:
"""Processes the whole request APM capturing.
Args:
request (Request)
call_next (RequestResponseEndpoint): Next request process in Starlette.
Returns:
Response
"""
await self._request_started(request)
try:
response = await call_next(request)
except Exception:
await self.capture_exception(
context={"request": await get_data_from_request(request, self.client.config, constants.ERROR)}
)
elasticapm.set_transaction_result("HTTP 5xx", override=False)
elasticapm.set_context({"status_code": 500}, "response")
raise
else:
await self._request_finished(response)
finally:
self.client.end_transaction()
return response
async def capture_exception(self, *args, **kwargs):
"""Captures your exception.
Args:
*args:
**kwargs:
"""
self.client.capture_exception(*args, **kwargs)
async def capture_message(self, *args, **kwargs):
"""Captures your message.
Args:
*args: Whatever
**kwargs: Whatever
"""
self.client.capture_message(*args, **kwargs)
async def _request_started(self, request: Request):
"""Captures the begin of the request processing to APM.
Args:
request (Request)
"""
trace_parent = TraceParent.from_headers(dict(request.headers))
self.client.begin_transaction("request", trace_parent=trace_parent)
await set_context(lambda: get_data_from_request(request, self.client.config, constants.TRANSACTION), "request")
elasticapm.set_transaction_name("{} {}".format(request.method, request.url.path), override=False)
async def _request_finished(self, response: Response):
"""Captures the end of the request processing to APM.
Args:
response (Response)
"""
await set_context(
lambda: get_data_from_response(response, self.client.config, constants.TRANSACTION), "response"
)
result = "HTTP {}xx".format(response.status_code // 100)
elasticapm.set_transaction_result(result, override=False)
| [
1,
396,
29871,
350,
7230,
29871,
29941,
29899,
20216,
1509,
19245,
13,
29937,
13,
29937,
29871,
14187,
1266,
313,
29883,
29897,
29871,
29906,
29900,
29896,
29906,
29892,
278,
317,
8269,
8583,
29892,
1074,
26524,
29950,
24125,
363,
901,
4902,
13,
29937,
29871,
14187,
1266,
313,
29883,
29897,
29871,
29906,
29900,
29896,
29929,
29892,
1260,
20291,
350,
29963,
13,
29937,
29871,
2178,
10462,
21676,
29889,
13,
29937,
13,
29937,
29871,
4367,
391,
3224,
322,
671,
297,
2752,
322,
7581,
7190,
29892,
411,
470,
1728,
13,
29937,
29871,
21733,
29892,
526,
21905,
4944,
393,
278,
1494,
5855,
526,
1539,
29901,
13,
29937,
13,
29937,
29871,
334,
4367,
391,
3224,
29879,
310,
2752,
775,
1818,
11551,
278,
2038,
3509,
1266,
8369,
29892,
445,
13,
29937,
1678,
1051,
310,
5855,
322,
278,
1494,
2313,
433,
4193,
29889,
13,
29937,
13,
29937,
29871,
334,
4367,
391,
3224,
29879,
297,
7581,
883,
1818,
18532,
278,
2038,
3509,
1266,
8369,
29892,
13,
29937,
1678,
445,
1051,
310,
5855,
322,
278,
1494,
2313,
433,
4193,
297,
278,
5106,
13,
29937,
1678,
322,
29914,
272,
916,
17279,
4944,
411,
278,
4978,
29889,
13,
29937,
13,
29937,
29871,
334,
2448,
2121,
278,
1024,
310,
278,
3509,
1266,
19464,
3643,
278,
2983,
310,
967,
13,
29937,
1678,
17737,
29560,
1122,
367,
1304,
304,
1095,
272,
344,
470,
27391,
9316,
10723,
515,
13,
29937,
1678,
445,
7047,
1728,
2702,
7536,
3971,
10751,
29889,
13,
29937,
13,
29937,
29871,
3446,
3235,
7791,
7818,
12982,
1525,
8519,
13756,
13044,
3352,
6770,
6093,
315,
4590,
29979,
22789,
3912,
379,
5607,
8032,
29903,
5300,
8707,
29911,
3960,
29933,
2692,
24125,
376,
3289,
8519,
29908,
13,
29937,
29871,
5300,
13764,
29979,
8528,
15094,
1799,
6323,
306,
3580,
5265,
3352,
399,
1718,
29934,
13566,
29059,
29892,
2672,
6154,
15789,
4214,
29892,
350,
2692,
6058,
27848,
3352,
7495,
29892,
6093,
13,
29937,
29871,
306,
3580,
5265,
3352,
399,
1718,
29934,
13566,
29059,
8079,
341,
1001,
3210,
13566,
2882,
6227,
11937,
5300,
383,
1806,
8186,
1799,
15842,
319,
349,
8322,
2965,
13309,
1718,
349,
4574,
13152,
1660,
319,
1525,
13,
29937,
29871,
28657,
13875,
8890,
29928,
29889,
2672,
11698,
382,
29963,
3919,
24972,
9818,
6093,
315,
4590,
29979,
22789,
3912,
379,
5607,
8032,
6323,
8707,
29911,
3960,
29933,
2692,
24125,
20700,
17705,
6181,
13,
29937,
29871,
15842,
13764,
29979,
22471,
26282,
29892,
2672,
4571,
26282,
29892,
2672,
29907,
1367,
3919,
1964,
29892,
317,
4162,
8426,
1964,
29892,
8528,
29923,
3580,
29931,
19926,
29892,
6323,
8707,
1660,
13356,
3919,
25758,
13,
29937,
29871,
21330,
1529,
1692,
29903,
313,
1177,
6154,
15789,
4214,
29892,
350,
2692,
6058,
27848,
3352,
7495,
29892,
13756,
29907,
11499,
13780,
8079,
27092,
1254,
1806,
26027,
21947,
29949,
8452,
6323,
13,
29937,
29871,
26996,
29963,
2965,
2890,
29936,
11247,
1799,
8079,
501,
1660,
29892,
360,
8254,
29892,
6323,
13756,
29943,
1806,
29903,
29936,
6323,
350,
3308,
8895,
1799,
2672,
4945,
29934,
4897,
29911,
2725,
29897,
29832,
8851,
5348,
13,
29937,
29871,
12766,
17171,
29928,
5300,
6732,
13764,
29979,
6093,
18929,
8079,
17705,
2882,
6227,
11937,
29892,
12317,
2544,
4448,
2672,
8707,
29911,
4717,
1783,
29892,
6850,
3960,
1783,
17705,
2882,
6227,
11937,
29892,
13,
29937,
29871,
6323,
323,
8476,
313,
1177,
6154,
15789,
4214,
405,
11787,
5265,
24647,
4741,
6323,
438,
29911,
4448,
22119,
1660,
29897,
9033,
3235,
4214,
2672,
13764,
29979,
399,
29909,
29979,
19474,
8079,
6093,
501,
1660,
13,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
13,
13,
5215,
5810,
20200,
13,
3166,
5810,
20200,
29889,
17662,
2519,
29889,
3188,
1053,
7399,
10493,
25411,
2519,
29892,
10729,
5103,
25602,
13,
3166,
5810,
20200,
29889,
24830,
1053,
10729,
13,
3166,
5810,
20200,
29889,
26679,
267,
1053,
13291,
13,
3166,
5810,
20200,
29889,
8768,
1053,
3339,
29954,
29902,
2052,
13,
13,
5215,
560,
6288,
481,
29885,
13,
5215,
560,
6288,
481,
29885,
29889,
2611,
15461,
362,
29889,
6451,
13,
3166,
560,
6288,
481,
29885,
29889,
3188,
1053,
12477,
13,
3166,
560,
6288,
481,
29885,
29889,
5527,
1053,
17727,
13,
3166,
560,
6288,
481,
29885,
29889,
21570,
29889,
294,
948,
3934,
29889,
3018,
778,
1053,
731,
29918,
4703,
13,
3166,
560,
6288,
481,
29885,
29889,
21570,
29889,
8508,
20200,
29889,
13239,
1053,
679,
29918,
1272,
29918,
3166,
29918,
3827,
29892,
679,
29918,
1272,
29918,
3166,
29918,
5327,
13,
3166,
560,
6288,
481,
29885,
29889,
13239,
29889,
5721,
29873,
945,
292,
1053,
20597,
9780,
13,
3166,
560,
6288,
481,
29885,
29889,
13239,
29889,
21027,
1053,
679,
29918,
21707,
13,
13,
21707,
353,
679,
29918,
21707,
703,
295,
6288,
481,
29885,
29889,
12523,
29889,
4645,
1159,
13,
13,
13,
1753,
1207,
29918,
481,
29885,
29918,
4645,
29898,
2917,
29901,
9657,
29892,
3132,
29918,
25932,
29922,
4032,
29892,
3579,
4381,
29879,
29897,
1599,
12477,
29901,
13,
1678,
9995,
8893,
29879,
1260,
6288,
3301,
29924,
3132,
29889,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
2295,
313,
8977,
1125,
13343,
310,
12477,
5285,
29889,
2178,
6611,
1818,
367,
7568,
4878,
29889,
2823,
421,
295,
6288,
481,
29885,
29889,
5527,
29889,
3991,
1412,
13,
4706,
3132,
29918,
25932,
313,
4032,
1125,
19928,
367,
12477,
470,
967,
2278,
29889,
13,
4706,
3579,
4381,
29879,
29901,
3462,
3245,
4128,
363,
12477,
29889,
2823,
421,
295,
6288,
481,
29885,
29889,
3188,
29889,
4032,
29952,
13,
13,
1678,
16969,
29901,
13,
4706,
12477,
13,
1678,
9995,
13,
1678,
565,
376,
4468,
29918,
978,
29908,
451,
297,
21274,
29901,
13,
4706,
21274,
3366,
4468,
29918,
978,
3108,
353,
376,
8508,
20200,
29908,
13,
4706,
21274,
3366,
4468,
29918,
3259,
3108,
353,
5810,
20200,
17255,
3259,
1649,
13,
13,
1678,
736,
3132,
29918,
25932,
29898,
2917,
29892,
3579,
4381,
29879,
29897,
13,
13,
13,
1990,
1260,
6288,
3301,
29924,
29898,
5160,
10493,
25411,
2519,
1125,
13,
1678,
9995,
13,
1678,
7828,
20200,
847,
23786,
8787,
7256,
2519,
363,
1260,
6288,
12279,
29924,
4332,
3864,
29889,
13,
13,
1678,
8653,
560,
6288,
481,
29885,
353,
1207,
29918,
481,
29885,
29918,
4645,
3319,
13,
4706,
8653,
525,
6304,
19059,
29918,
5813,
2396,
525,
1357,
932,
742,
13,
4706,
8653,
525,
18525,
2396,
5852,
29892,
13,
4706,
8653,
525,
18603,
29918,
4219,
2396,
525,
1124,
597,
7640,
29901,
29947,
29906,
29900,
29900,
742,
13,
4706,
8653,
525,
29907,
3301,
29911,
11499,
29918,
23252,
23598,
2396,
5852,
29892,
13,
4706,
8653,
525,
29907,
3301,
29911,
11499,
29918,
8456,
29928,
29979,
2396,
525,
497,
29915,
13,
1678,
8653,
5615,
13,
13,
1678,
8653,
623,
29889,
1202,
29918,
17662,
2519,
29898,
29923,
4230,
293,
3301,
29924,
29892,
3132,
29922,
295,
6288,
481,
29885,
29897,
13,
13,
1678,
6978,
385,
11472,
12279,
29925,
29918,
5813,
322,
3725,
22245,
29911,
29918,
4986,
29968,
1430,
1057,
13,
13,
1678,
8653,
560,
6288,
481,
29885,
353,
1260,
6288,
3301,
29924,
29898,
932,
29892,
2669,
29918,
978,
2433,
1357,
932,
742,
7035,
29918,
6979,
2433,
29966,
25711,
17013,
29958,
1495,
13,
13,
1678,
6978,
385,
6261,
3132,
1057,
13,
13,
1678,
8653,
560,
6288,
481,
29885,
353,
1260,
6288,
3301,
29924,
29898,
932,
29892,
3132,
29922,
4645,
29897,
13,
13,
1678,
15854,
19574,
10822,
12183,
1057,
13,
13,
1678,
8653,
560,
6288,
481,
29885,
353,
1260,
6288,
3301,
29924,
29898,
932,
29892,
12183,
29922,
5574,
29897,
13,
13,
1678,
8868,
545,
385,
3682,
1057,
13,
13,
1678,
8653,
1018,
29901,
13,
1678,
8653,
418,
29896,
847,
29871,
29900,
13,
1678,
8653,
5174,
28933,
12596,
2459,
2392,
29901,
13,
1678,
8653,
268,
560,
6288,
481,
29885,
29889,
17885,
545,
29918,
11739,
580,
13,
13,
1678,
8868,
545,
263,
2643,
1057,
13,
13,
1678,
8653,
560,
6288,
481,
29885,
29889,
17885,
545,
29918,
4906,
877,
12199,
29892,
3186,
29991,
1495,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
623,
29901,
3339,
29954,
29902,
2052,
29892,
3132,
29901,
12477,
1125,
13,
4706,
9995,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
623,
313,
3289,
29954,
29902,
2052,
1125,
7828,
20200,
623,
13,
9651,
3132,
313,
4032,
1125,
1260,
6288,
3301,
29924,
12477,
13,
4706,
9995,
13,
4706,
1583,
29889,
4645,
353,
3132,
13,
13,
4706,
565,
1583,
29889,
4645,
29889,
2917,
29889,
2611,
15461,
29901,
13,
9651,
560,
6288,
481,
29885,
29889,
2611,
15461,
362,
29889,
6451,
29889,
2611,
15461,
580,
13,
13,
4706,
2428,
2141,
1649,
2344,
12035,
932,
29897,
13,
13,
1678,
7465,
822,
13916,
29898,
1311,
29892,
2009,
29901,
10729,
29892,
1246,
29918,
4622,
29901,
10729,
5103,
25602,
29897,
1599,
13291,
29901,
13,
4706,
9995,
7032,
267,
278,
3353,
2009,
12279,
29924,
4332,
3864,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
2009,
313,
3089,
29897,
13,
9651,
1246,
29918,
4622,
313,
3089,
5103,
25602,
1125,
8084,
2009,
1889,
297,
7828,
20200,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
13291,
13,
4706,
9995,
13,
4706,
7272,
1583,
3032,
3827,
29918,
2962,
287,
29898,
3827,
29897,
13,
13,
4706,
1018,
29901,
13,
9651,
2933,
353,
7272,
1246,
29918,
4622,
29898,
3827,
29897,
13,
4706,
5174,
8960,
29901,
13,
9651,
7272,
1583,
29889,
17885,
545,
29918,
11739,
29898,
13,
18884,
3030,
3790,
29908,
3827,
1115,
7272,
679,
29918,
1272,
29918,
3166,
29918,
3827,
29898,
3827,
29892,
1583,
29889,
4645,
29889,
2917,
29892,
17727,
29889,
11432,
2915,
13,
9651,
1723,
13,
9651,
560,
6288,
481,
29885,
29889,
842,
29918,
20736,
29918,
2914,
703,
10493,
29871,
29945,
4419,
613,
5712,
29922,
8824,
29897,
13,
9651,
560,
6288,
481,
29885,
29889,
842,
29918,
4703,
3319,
29908,
4882,
29918,
401,
1115,
29871,
29945,
29900,
29900,
1118,
376,
5327,
1159,
13,
13,
9651,
12020,
13,
4706,
1683,
29901,
13,
9651,
7272,
1583,
3032,
3827,
29918,
4951,
3276,
29898,
5327,
29897,
13,
4706,
7146,
29901,
13,
9651,
1583,
29889,
4645,
29889,
355,
29918,
20736,
580,
13,
13,
4706,
736,
2933,
13,
13,
1678,
7465,
822,
10446,
29918,
11739,
29898,
1311,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
9995,
21133,
1973,
596,
3682,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
334,
5085,
29901,
13,
9651,
3579,
19290,
29901,
13,
4706,
9995,
13,
4706,
1583,
29889,
4645,
29889,
17885,
545,
29918,
11739,
10456,
5085,
29892,
3579,
19290,
29897,
13,
13,
1678,
7465,
822,
10446,
29918,
4906,
29898,
1311,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
9995,
21133,
1973,
596,
2643,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
334,
5085,
29901,
806,
5564,
13,
9651,
3579,
19290,
29901,
806,
5564,
13,
4706,
9995,
13,
4706,
1583,
29889,
4645,
29889,
17885,
545,
29918,
4906,
10456,
5085,
29892,
3579,
19290,
29897,
13,
13,
1678,
7465,
822,
903,
3827,
29918,
2962,
287,
29898,
1311,
29892,
2009,
29901,
10729,
1125,
13,
4706,
9995,
21133,
1973,
278,
3380,
310,
278,
2009,
9068,
304,
12279,
29924,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
2009,
313,
3089,
29897,
13,
4706,
9995,
13,
4706,
9637,
29918,
3560,
353,
20597,
9780,
29889,
3166,
29918,
13662,
29898,
8977,
29898,
3827,
29889,
13662,
876,
13,
4706,
1583,
29889,
4645,
29889,
463,
29918,
20736,
703,
3827,
613,
9637,
29918,
3560,
29922,
15003,
29918,
3560,
29897,
13,
13,
4706,
7272,
731,
29918,
4703,
29898,
2892,
29901,
679,
29918,
1272,
29918,
3166,
29918,
3827,
29898,
3827,
29892,
1583,
29889,
4645,
29889,
2917,
29892,
17727,
29889,
26813,
8132,
9838,
511,
376,
3827,
1159,
13,
4706,
560,
6288,
481,
29885,
29889,
842,
29918,
20736,
29918,
978,
703,
8875,
6571,
1642,
4830,
29898,
3827,
29889,
5696,
29892,
2009,
29889,
2271,
29889,
2084,
511,
5712,
29922,
8824,
29897,
13,
13,
1678,
7465,
822,
903,
3827,
29918,
4951,
3276,
29898,
1311,
29892,
2933,
29901,
13291,
1125,
13,
4706,
9995,
21133,
1973,
278,
1095,
310,
278,
2009,
9068,
304,
12279,
29924,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
2933,
313,
5103,
29897,
13,
4706,
9995,
13,
4706,
7272,
731,
29918,
4703,
29898,
13,
9651,
14013,
29901,
679,
29918,
1272,
29918,
3166,
29918,
5327,
29898,
5327,
29892,
1583,
29889,
4645,
29889,
2917,
29892,
17727,
29889,
26813,
8132,
9838,
511,
376,
5327,
29908,
13,
4706,
1723,
13,
13,
4706,
1121,
353,
376,
10493,
6571,
4419,
1642,
4830,
29898,
5327,
29889,
4882,
29918,
401,
849,
29871,
29896,
29900,
29900,
29897,
13,
4706,
560,
6288,
481,
29885,
29889,
842,
29918,
20736,
29918,
2914,
29898,
2914,
29892,
5712,
29922,
8824,
29897,
13,
2
] |
tests/integration/commands/test_transfer.py | real-digital/esque | 29 | 113808 | <gh_stars>10-100
import time
from typing import Tuple
import pytest
from click.testing import CliRunner
from confluent_kafka.avro import AvroConsumer, AvroProducer
from confluent_kafka.cimpl import Consumer
from confluent_kafka.cimpl import Producer as ConfluentProducer
from confluent_kafka.cimpl import TopicPartition
from pytest_cases import fixture
from esque.cli.commands import esque
from esque.config import Config
from tests.utils import (
produce_avro_test_messages,
produce_binary_test_messages,
produce_text_test_messages,
produce_text_test_messages_with_headers,
)
@fixture
def target_topic_consumer(unittest_config: Config, target_topic: Tuple[str, int]) -> Consumer:
consumer = Consumer(
{
"group.id": "asdf",
"enable.auto.commit": False,
"enable.partition.eof": False,
**unittest_config.create_confluent_config(),
}
)
consumer.assign([TopicPartition(topic=target_topic[0], partition=i, offset=0) for i in range(target_topic[1])])
yield consumer
consumer.close()
@fixture
def target_topic_avro_consumer(unittest_config: Config, target_topic: Tuple[str, int]) -> AvroConsumer:
consumer = AvroConsumer(
{
"group.id": "asdf",
"enable.auto.commit": False,
"enable.partition.eof": False,
**unittest_config.create_confluent_config(include_schema_registry=True),
}
)
consumer.assign([TopicPartition(topic=target_topic[0], partition=i, offset=0) for i in range(target_topic[1])])
yield consumer
consumer.close()
@pytest.mark.integration
def test_transfer_plain_text_message_using_cli_pipe(
producer: ConfluentProducer,
target_topic_consumer: Consumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
):
expected_messages = produce_text_test_messages(topic_name=source_topic[0], producer=producer)
result1 = non_interactive_cli_runner.invoke(
esque, args=["consume", "--stdout", "--number", "10", source_topic[0]], catch_exceptions=False
)
non_interactive_cli_runner.invoke(
esque, args=["produce", "--stdin", target_topic[0]], input=result1.output, catch_exceptions=False
)
actual_messages = {
(msg.key().decode(), msg.value().decode(), msg.partition())
for msg in target_topic_consumer.consume(10, timeout=20)
}
expected_messages = {(msg.key, msg.value, msg.partition) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_plain_text_message_with_headers_using_cli_pipe(
producer: ConfluentProducer,
target_topic_consumer: Consumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
):
expected_messages = produce_text_test_messages_with_headers(topic_name=source_topic[0], producer=producer)
result1 = non_interactive_cli_runner.invoke(
esque, args=["consume", "--stdout", "--number", "10", source_topic[0]], catch_exceptions=False
)
non_interactive_cli_runner.invoke(
esque, args=["produce", "--stdin", target_topic[0]], input=result1.output, catch_exceptions=False
)
actual_messages = {
(msg.key().decode(), msg.value().decode(), msg.partition(), tuple(msg.headers() or []))
for msg in target_topic_consumer.consume(10, timeout=20)
}
expected_messages = {(msg.key, msg.value, msg.partition, tuple(msg.headers)) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_binary_message_using_cli_pipe(
producer: ConfluentProducer,
target_topic_consumer: Consumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner,
):
expected_messages = produce_binary_test_messages(topic_name=source_topic[0], producer=producer)
result1 = non_interactive_cli_runner.invoke(
esque, args=["consume", "--stdout", "--binary", "--number", "10", source_topic[0]], catch_exceptions=False
)
non_interactive_cli_runner.invoke(
esque, args=["produce", "--stdin", "--binary", target_topic[0]], input=result1.output, catch_exceptions=False
)
actual_messages = {
(msg.key(), msg.value(), msg.partition()) for msg in target_topic_consumer.consume(10, timeout=20)
}
expected_messages = {(msg.key, msg.value, msg.partition) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_plain_text_message_using_file(
producer: ConfluentProducer,
target_topic_consumer: Consumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
tmpdir_factory,
):
output_directory = tmpdir_factory.mktemp("output_directory")
expected_messages = produce_text_test_messages(topic_name=source_topic[0], producer=producer)
non_interactive_cli_runner.invoke(
esque, args=["consume", "-d", str(output_directory), "--number", "10", source_topic[0]], catch_exceptions=False
)
non_interactive_cli_runner.invoke(
esque, args=["produce", "-d", str(output_directory), target_topic[0]], catch_exceptions=False
)
actual_messages = {
(msg.key().decode(), msg.value().decode(), msg.partition())
for msg in target_topic_consumer.consume(10, timeout=20)
}
expected_messages = {(msg.key, msg.value, msg.partition) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_plain_text_message_with_headers_using_file(
producer: ConfluentProducer,
target_topic_consumer: Consumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
tmpdir_factory,
):
output_directory = tmpdir_factory.mktemp("output_directory")
expected_messages = produce_text_test_messages_with_headers(topic_name=source_topic[0], producer=producer)
non_interactive_cli_runner.invoke(
esque, args=["consume", "-d", str(output_directory), "--number", "10", source_topic[0]], catch_exceptions=False
)
non_interactive_cli_runner.invoke(
esque, args=["produce", "-d", str(output_directory), target_topic[0]], catch_exceptions=False
)
actual_messages = {
(msg.key().decode(), msg.value().decode(), msg.partition(), tuple((msg.headers() or [])))
for msg in target_topic_consumer.consume(10, timeout=20)
}
expected_messages = {(msg.key, msg.value, msg.partition, tuple(msg.headers)) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_binary_message_using_file(
producer: ConfluentProducer,
target_topic_consumer: Consumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
tmpdir_factory,
):
output_directory = tmpdir_factory.mktemp("output_directory")
expected_messages = produce_binary_test_messages(topic_name=source_topic[0], producer=producer)
non_interactive_cli_runner.invoke(
esque,
args=["consume", "-d", str(output_directory), "--binary", "--number", "10", source_topic[0]],
catch_exceptions=False,
)
non_interactive_cli_runner.invoke(
esque, args=["produce", "-d", str(output_directory), "--binary", target_topic[0]], catch_exceptions=False
)
actual_messages = {
(msg.key(), msg.value(), msg.partition()) for msg in target_topic_consumer.consume(10, timeout=20)
}
expected_messages = {(msg.key, msg.value, msg.partition) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_avro_message_using_file(
avro_producer: AvroProducer,
target_topic_avro_consumer: AvroConsumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
tmpdir_factory,
):
output_directory = tmpdir_factory.mktemp("output_directory")
expected_messages = produce_avro_test_messages(topic_name=source_topic[0], avro_producer=avro_producer)
non_interactive_cli_runner.invoke(
esque,
args=["consume", "-d", str(output_directory), "--avro", "--number", "10", source_topic[0]],
catch_exceptions=False,
)
non_interactive_cli_runner.invoke(
esque, args=["produce", "-d", str(output_directory), "--avro", target_topic[0]], catch_exceptions=False
)
actual_messages = set()
start = time.monotonic()
while len(actual_messages) < 10:
msg = target_topic_avro_consumer.poll(timeout=2)
if msg is not None:
actual_messages.add((msg.key()["key"], msg.value()["value"], msg.partition()))
elif time.monotonic() - start >= 20:
raise TimeoutError("Timeout reading data from topic")
expected_messages = {(msg.key["key"], msg.value["value"], msg.partition) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_avro_with_single_command(
avro_producer: AvroProducer,
target_topic_avro_consumer: AvroConsumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
):
expected_messages = produce_avro_test_messages(topic_name=source_topic[0], avro_producer=avro_producer)
non_interactive_cli_runner.invoke(
esque,
args=[
"transfer",
"--from-topic",
source_topic[0],
"--to-topic",
target_topic[0],
"--avro",
"--number",
"10",
"--first",
],
catch_exceptions=False,
)
actual_messages = set()
start = time.monotonic()
while len(actual_messages) < 10:
msg = target_topic_avro_consumer.poll(timeout=2)
if msg is not None:
actual_messages.add((msg.key()["key"], msg.value()["value"], msg.partition()))
elif time.monotonic() - start >= 20:
raise TimeoutError("Timeout reading data from topic")
expected_messages = {(msg.key["key"], msg.value["value"], msg.partition) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_binary_with_single_command(
producer: ConfluentProducer,
target_topic_consumer: Consumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
):
expected_messages = produce_binary_test_messages(topic_name=source_topic[0], producer=producer)
non_interactive_cli_runner.invoke(
esque,
args=[
"transfer",
"--from-topic",
source_topic[0],
"--to-topic",
target_topic[0],
"--binary",
"--number",
"10",
"--first",
],
catch_exceptions=False,
)
actual_messages = {
(msg.key(), msg.value(), msg.partition()) for msg in target_topic_consumer.consume(10, timeout=20)
}
expected_messages = {(msg.key, msg.value, msg.partition) for msg in expected_messages}
assert expected_messages == actual_messages
@pytest.mark.integration
def test_transfer_plain_with_single_command(
producer: ConfluentProducer,
target_topic_consumer: Consumer,
source_topic: Tuple[str, int],
target_topic: Tuple[str, int],
non_interactive_cli_runner: CliRunner,
):
expected_messages = produce_text_test_messages_with_headers(topic_name=source_topic[0], producer=producer)
non_interactive_cli_runner.invoke(
esque,
args=["transfer", "--from-topic", source_topic[0], "--to-topic", target_topic[0], "--number", "10", "--first"],
catch_exceptions=False,
)
actual_messages = {
(msg.key().decode(), msg.value().decode(), msg.partition())
for msg in target_topic_consumer.consume(10, timeout=20)
}
expected_messages = {(msg.key, msg.value, msg.partition) for msg in expected_messages}
assert expected_messages == actual_messages
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29899,
29896,
29900,
29900,
13,
5215,
931,
13,
3166,
19229,
1053,
12603,
552,
13,
13,
5215,
11451,
1688,
13,
3166,
2828,
29889,
13424,
1053,
315,
492,
16802,
13,
3166,
18669,
8122,
29918,
28510,
29889,
485,
307,
1053,
7740,
307,
13696,
4680,
29892,
7740,
307,
23665,
2265,
13,
3166,
18669,
8122,
29918,
28510,
29889,
29883,
13699,
1053,
2138,
4680,
13,
3166,
18669,
8122,
29918,
28510,
29889,
29883,
13699,
1053,
7138,
2265,
408,
1281,
1579,
8122,
23665,
2265,
13,
3166,
18669,
8122,
29918,
28510,
29889,
29883,
13699,
1053,
7488,
293,
7439,
654,
13,
3166,
11451,
1688,
29918,
11436,
1053,
5713,
15546,
13,
13,
3166,
831,
802,
29889,
11303,
29889,
26381,
1053,
831,
802,
13,
3166,
831,
802,
29889,
2917,
1053,
12782,
13,
3166,
6987,
29889,
13239,
1053,
313,
13,
1678,
7738,
29918,
485,
307,
29918,
1688,
29918,
19158,
29892,
13,
1678,
7738,
29918,
19541,
29918,
1688,
29918,
19158,
29892,
13,
1678,
7738,
29918,
726,
29918,
1688,
29918,
19158,
29892,
13,
1678,
7738,
29918,
726,
29918,
1688,
29918,
19158,
29918,
2541,
29918,
13662,
29892,
13,
29897,
13,
13,
13,
29992,
7241,
15546,
13,
1753,
3646,
29918,
13010,
29918,
25978,
261,
29898,
348,
27958,
29918,
2917,
29901,
12782,
29892,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
2314,
1599,
2138,
4680,
29901,
13,
1678,
21691,
353,
2138,
4680,
29898,
13,
4706,
426,
13,
9651,
376,
2972,
29889,
333,
1115,
376,
294,
2176,
613,
13,
9651,
376,
12007,
29889,
6921,
29889,
15060,
1115,
7700,
29892,
13,
9651,
376,
12007,
29889,
16707,
29889,
29872,
974,
1115,
7700,
29892,
13,
9651,
3579,
348,
27958,
29918,
2917,
29889,
3258,
29918,
535,
1579,
8122,
29918,
2917,
3285,
13,
4706,
500,
13,
1678,
1723,
13,
1678,
21691,
29889,
16645,
4197,
7031,
293,
7439,
654,
29898,
13010,
29922,
5182,
29918,
13010,
29961,
29900,
1402,
8877,
29922,
29875,
29892,
9210,
29922,
29900,
29897,
363,
474,
297,
3464,
29898,
5182,
29918,
13010,
29961,
29896,
2314,
2314,
13,
1678,
7709,
21691,
13,
1678,
21691,
29889,
5358,
580,
13,
13,
13,
29992,
7241,
15546,
13,
1753,
3646,
29918,
13010,
29918,
485,
307,
29918,
25978,
261,
29898,
348,
27958,
29918,
2917,
29901,
12782,
29892,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
2314,
1599,
7740,
307,
13696,
4680,
29901,
13,
1678,
21691,
353,
7740,
307,
13696,
4680,
29898,
13,
4706,
426,
13,
9651,
376,
2972,
29889,
333,
1115,
376,
294,
2176,
613,
13,
9651,
376,
12007,
29889,
6921,
29889,
15060,
1115,
7700,
29892,
13,
9651,
376,
12007,
29889,
16707,
29889,
29872,
974,
1115,
7700,
29892,
13,
9651,
3579,
348,
27958,
29918,
2917,
29889,
3258,
29918,
535,
1579,
8122,
29918,
2917,
29898,
2856,
29918,
11010,
29918,
1727,
6020,
29922,
5574,
511,
13,
4706,
500,
13,
1678,
1723,
13,
1678,
21691,
29889,
16645,
4197,
7031,
293,
7439,
654,
29898,
13010,
29922,
5182,
29918,
13010,
29961,
29900,
1402,
8877,
29922,
29875,
29892,
9210,
29922,
29900,
29897,
363,
474,
297,
3464,
29898,
5182,
29918,
13010,
29961,
29896,
2314,
2314,
13,
1678,
7709,
21691,
13,
1678,
21691,
29889,
5358,
580,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
24595,
29918,
726,
29918,
4906,
29918,
4746,
29918,
11303,
29918,
17760,
29898,
13,
1678,
14297,
29901,
1281,
1579,
8122,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
25978,
261,
29901,
2138,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1125,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
726,
29918,
1688,
29918,
19158,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
14297,
29922,
5498,
2265,
29897,
13,
13,
1678,
1121,
29896,
353,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
3200,
2017,
613,
376,
489,
25393,
613,
376,
489,
4537,
613,
376,
29896,
29900,
613,
2752,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
5498,
346,
613,
376,
489,
4172,
262,
613,
3646,
29918,
13010,
29961,
29900,
20526,
1881,
29922,
2914,
29896,
29889,
4905,
29892,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
426,
13,
4706,
313,
7645,
29889,
1989,
2141,
13808,
3285,
10191,
29889,
1767,
2141,
13808,
3285,
10191,
29889,
16707,
3101,
13,
4706,
363,
10191,
297,
3646,
29918,
13010,
29918,
25978,
261,
29889,
3200,
2017,
29898,
29896,
29900,
29892,
11815,
29922,
29906,
29900,
29897,
13,
1678,
500,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
29892,
10191,
29889,
1767,
29892,
10191,
29889,
16707,
29897,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
24595,
29918,
726,
29918,
4906,
29918,
2541,
29918,
13662,
29918,
4746,
29918,
11303,
29918,
17760,
29898,
13,
1678,
14297,
29901,
1281,
1579,
8122,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
25978,
261,
29901,
2138,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1125,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
726,
29918,
1688,
29918,
19158,
29918,
2541,
29918,
13662,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
14297,
29922,
5498,
2265,
29897,
13,
13,
1678,
1121,
29896,
353,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
3200,
2017,
613,
376,
489,
25393,
613,
376,
489,
4537,
613,
376,
29896,
29900,
613,
2752,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
5498,
346,
613,
376,
489,
4172,
262,
613,
3646,
29918,
13010,
29961,
29900,
20526,
1881,
29922,
2914,
29896,
29889,
4905,
29892,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
426,
13,
4706,
313,
7645,
29889,
1989,
2141,
13808,
3285,
10191,
29889,
1767,
2141,
13808,
3285,
10191,
29889,
16707,
3285,
18761,
29898,
7645,
29889,
13662,
580,
470,
5159,
876,
13,
4706,
363,
10191,
297,
3646,
29918,
13010,
29918,
25978,
261,
29889,
3200,
2017,
29898,
29896,
29900,
29892,
11815,
29922,
29906,
29900,
29897,
13,
1678,
500,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
29892,
10191,
29889,
1767,
29892,
10191,
29889,
16707,
29892,
18761,
29898,
7645,
29889,
13662,
876,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
19541,
29918,
4906,
29918,
4746,
29918,
11303,
29918,
17760,
29898,
13,
1678,
14297,
29901,
1281,
1579,
8122,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
25978,
261,
29901,
2138,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29892,
13,
1125,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
19541,
29918,
1688,
29918,
19158,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
14297,
29922,
5498,
2265,
29897,
13,
13,
1678,
1121,
29896,
353,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
3200,
2017,
613,
376,
489,
25393,
613,
376,
489,
19541,
613,
376,
489,
4537,
613,
376,
29896,
29900,
613,
2752,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
5498,
346,
613,
376,
489,
4172,
262,
613,
376,
489,
19541,
613,
3646,
29918,
13010,
29961,
29900,
20526,
1881,
29922,
2914,
29896,
29889,
4905,
29892,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
426,
13,
4706,
313,
7645,
29889,
1989,
3285,
10191,
29889,
1767,
3285,
10191,
29889,
16707,
3101,
363,
10191,
297,
3646,
29918,
13010,
29918,
25978,
261,
29889,
3200,
2017,
29898,
29896,
29900,
29892,
11815,
29922,
29906,
29900,
29897,
13,
1678,
500,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
29892,
10191,
29889,
1767,
29892,
10191,
29889,
16707,
29897,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
24595,
29918,
726,
29918,
4906,
29918,
4746,
29918,
1445,
29898,
13,
1678,
14297,
29901,
1281,
1579,
8122,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
25978,
261,
29901,
2138,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1678,
13128,
3972,
29918,
14399,
29892,
13,
1125,
13,
1678,
1962,
29918,
12322,
353,
13128,
3972,
29918,
14399,
29889,
29885,
1193,
3451,
703,
4905,
29918,
12322,
1159,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
726,
29918,
1688,
29918,
19158,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
14297,
29922,
5498,
2265,
29897,
13,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
3200,
2017,
613,
11663,
29881,
613,
851,
29898,
4905,
29918,
12322,
511,
376,
489,
4537,
613,
376,
29896,
29900,
613,
2752,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
5498,
346,
613,
11663,
29881,
613,
851,
29898,
4905,
29918,
12322,
511,
3646,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
426,
13,
4706,
313,
7645,
29889,
1989,
2141,
13808,
3285,
10191,
29889,
1767,
2141,
13808,
3285,
10191,
29889,
16707,
3101,
13,
4706,
363,
10191,
297,
3646,
29918,
13010,
29918,
25978,
261,
29889,
3200,
2017,
29898,
29896,
29900,
29892,
11815,
29922,
29906,
29900,
29897,
13,
1678,
500,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
29892,
10191,
29889,
1767,
29892,
10191,
29889,
16707,
29897,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
24595,
29918,
726,
29918,
4906,
29918,
2541,
29918,
13662,
29918,
4746,
29918,
1445,
29898,
13,
1678,
14297,
29901,
1281,
1579,
8122,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
25978,
261,
29901,
2138,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1678,
13128,
3972,
29918,
14399,
29892,
13,
1125,
13,
1678,
1962,
29918,
12322,
353,
13128,
3972,
29918,
14399,
29889,
29885,
1193,
3451,
703,
4905,
29918,
12322,
1159,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
726,
29918,
1688,
29918,
19158,
29918,
2541,
29918,
13662,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
14297,
29922,
5498,
2265,
29897,
13,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
3200,
2017,
613,
11663,
29881,
613,
851,
29898,
4905,
29918,
12322,
511,
376,
489,
4537,
613,
376,
29896,
29900,
613,
2752,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
5498,
346,
613,
11663,
29881,
613,
851,
29898,
4905,
29918,
12322,
511,
3646,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
426,
13,
4706,
313,
7645,
29889,
1989,
2141,
13808,
3285,
10191,
29889,
1767,
2141,
13808,
3285,
10191,
29889,
16707,
3285,
18761,
3552,
7645,
29889,
13662,
580,
470,
5159,
4961,
13,
4706,
363,
10191,
297,
3646,
29918,
13010,
29918,
25978,
261,
29889,
3200,
2017,
29898,
29896,
29900,
29892,
11815,
29922,
29906,
29900,
29897,
13,
1678,
500,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
29892,
10191,
29889,
1767,
29892,
10191,
29889,
16707,
29892,
18761,
29898,
7645,
29889,
13662,
876,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
19541,
29918,
4906,
29918,
4746,
29918,
1445,
29898,
13,
1678,
14297,
29901,
1281,
1579,
8122,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
25978,
261,
29901,
2138,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1678,
13128,
3972,
29918,
14399,
29892,
13,
1125,
13,
1678,
1962,
29918,
12322,
353,
13128,
3972,
29918,
14399,
29889,
29885,
1193,
3451,
703,
4905,
29918,
12322,
1159,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
19541,
29918,
1688,
29918,
19158,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
14297,
29922,
5498,
2265,
29897,
13,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
13,
4706,
6389,
29922,
3366,
3200,
2017,
613,
11663,
29881,
613,
851,
29898,
4905,
29918,
12322,
511,
376,
489,
19541,
613,
376,
489,
4537,
613,
376,
29896,
29900,
613,
2752,
29918,
13010,
29961,
29900,
20526,
13,
4706,
4380,
29918,
11739,
29879,
29922,
8824,
29892,
13,
1678,
1723,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
5498,
346,
613,
11663,
29881,
613,
851,
29898,
4905,
29918,
12322,
511,
376,
489,
19541,
613,
3646,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
426,
13,
4706,
313,
7645,
29889,
1989,
3285,
10191,
29889,
1767,
3285,
10191,
29889,
16707,
3101,
363,
10191,
297,
3646,
29918,
13010,
29918,
25978,
261,
29889,
3200,
2017,
29898,
29896,
29900,
29892,
11815,
29922,
29906,
29900,
29897,
13,
1678,
500,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
29892,
10191,
29889,
1767,
29892,
10191,
29889,
16707,
29897,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
485,
307,
29918,
4906,
29918,
4746,
29918,
1445,
29898,
13,
1678,
1029,
307,
29918,
5498,
2265,
29901,
7740,
307,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
485,
307,
29918,
25978,
261,
29901,
7740,
307,
13696,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1678,
13128,
3972,
29918,
14399,
29892,
13,
1125,
13,
1678,
1962,
29918,
12322,
353,
13128,
3972,
29918,
14399,
29889,
29885,
1193,
3451,
703,
4905,
29918,
12322,
1159,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
485,
307,
29918,
1688,
29918,
19158,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
1029,
307,
29918,
5498,
2265,
29922,
485,
307,
29918,
5498,
2265,
29897,
13,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
13,
4706,
6389,
29922,
3366,
3200,
2017,
613,
11663,
29881,
613,
851,
29898,
4905,
29918,
12322,
511,
376,
489,
485,
307,
613,
376,
489,
4537,
613,
376,
29896,
29900,
613,
2752,
29918,
13010,
29961,
29900,
20526,
13,
4706,
4380,
29918,
11739,
29879,
29922,
8824,
29892,
13,
1678,
1723,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
6389,
29922,
3366,
5498,
346,
613,
11663,
29881,
613,
851,
29898,
4905,
29918,
12322,
511,
376,
489,
485,
307,
613,
3646,
29918,
13010,
29961,
29900,
20526,
4380,
29918,
11739,
29879,
29922,
8824,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
731,
580,
13,
1678,
1369,
353,
931,
29889,
3712,
327,
8927,
580,
13,
1678,
1550,
7431,
29898,
19304,
29918,
19158,
29897,
529,
29871,
29896,
29900,
29901,
13,
4706,
10191,
353,
3646,
29918,
13010,
29918,
485,
307,
29918,
25978,
261,
29889,
29886,
3028,
29898,
15619,
29922,
29906,
29897,
13,
4706,
565,
10191,
338,
451,
6213,
29901,
13,
9651,
3935,
29918,
19158,
29889,
1202,
3552,
7645,
29889,
1989,
580,
3366,
1989,
12436,
10191,
29889,
1767,
580,
3366,
1767,
12436,
10191,
29889,
16707,
22130,
13,
4706,
25342,
931,
29889,
3712,
327,
8927,
580,
448,
1369,
6736,
29871,
29906,
29900,
29901,
13,
9651,
12020,
5974,
449,
2392,
703,
10851,
5183,
848,
515,
11261,
1159,
13,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
3366,
1989,
12436,
10191,
29889,
1767,
3366,
1767,
12436,
10191,
29889,
16707,
29897,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
485,
307,
29918,
2541,
29918,
14369,
29918,
6519,
29898,
13,
1678,
1029,
307,
29918,
5498,
2265,
29901,
7740,
307,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
485,
307,
29918,
25978,
261,
29901,
7740,
307,
13696,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1125,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
485,
307,
29918,
1688,
29918,
19158,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
1029,
307,
29918,
5498,
2265,
29922,
485,
307,
29918,
5498,
2265,
29897,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
13,
4706,
6389,
11759,
13,
9651,
376,
3286,
571,
613,
13,
9651,
376,
489,
3166,
29899,
13010,
613,
13,
9651,
2752,
29918,
13010,
29961,
29900,
1402,
13,
9651,
376,
489,
517,
29899,
13010,
613,
13,
9651,
3646,
29918,
13010,
29961,
29900,
1402,
13,
9651,
376,
489,
485,
307,
613,
13,
9651,
376,
489,
4537,
613,
13,
9651,
376,
29896,
29900,
613,
13,
9651,
376,
489,
4102,
613,
13,
4706,
21251,
13,
4706,
4380,
29918,
11739,
29879,
29922,
8824,
29892,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
731,
580,
13,
1678,
1369,
353,
931,
29889,
3712,
327,
8927,
580,
13,
1678,
1550,
7431,
29898,
19304,
29918,
19158,
29897,
529,
29871,
29896,
29900,
29901,
13,
4706,
10191,
353,
3646,
29918,
13010,
29918,
485,
307,
29918,
25978,
261,
29889,
29886,
3028,
29898,
15619,
29922,
29906,
29897,
13,
4706,
565,
10191,
338,
451,
6213,
29901,
13,
9651,
3935,
29918,
19158,
29889,
1202,
3552,
7645,
29889,
1989,
580,
3366,
1989,
12436,
10191,
29889,
1767,
580,
3366,
1767,
12436,
10191,
29889,
16707,
22130,
13,
4706,
25342,
931,
29889,
3712,
327,
8927,
580,
448,
1369,
6736,
29871,
29906,
29900,
29901,
13,
9651,
12020,
5974,
449,
2392,
703,
10851,
5183,
848,
515,
11261,
1159,
13,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
3366,
1989,
12436,
10191,
29889,
1767,
3366,
1767,
12436,
10191,
29889,
16707,
29897,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
19541,
29918,
2541,
29918,
14369,
29918,
6519,
29898,
13,
1678,
14297,
29901,
1281,
1579,
8122,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
25978,
261,
29901,
2138,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1125,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
19541,
29918,
1688,
29918,
19158,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
14297,
29922,
5498,
2265,
29897,
13,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
13,
4706,
6389,
11759,
13,
9651,
376,
3286,
571,
613,
13,
9651,
376,
489,
3166,
29899,
13010,
613,
13,
9651,
2752,
29918,
13010,
29961,
29900,
1402,
13,
9651,
376,
489,
517,
29899,
13010,
613,
13,
9651,
3646,
29918,
13010,
29961,
29900,
1402,
13,
9651,
376,
489,
19541,
613,
13,
9651,
376,
489,
4537,
613,
13,
9651,
376,
29896,
29900,
613,
13,
9651,
376,
489,
4102,
613,
13,
4706,
21251,
13,
4706,
4380,
29918,
11739,
29879,
29922,
8824,
29892,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
426,
13,
4706,
313,
7645,
29889,
1989,
3285,
10191,
29889,
1767,
3285,
10191,
29889,
16707,
3101,
363,
10191,
297,
3646,
29918,
13010,
29918,
25978,
261,
29889,
3200,
2017,
29898,
29896,
29900,
29892,
11815,
29922,
29906,
29900,
29897,
13,
1678,
500,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
29892,
10191,
29889,
1767,
29892,
10191,
29889,
16707,
29897,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
27925,
13,
1753,
1243,
29918,
3286,
571,
29918,
24595,
29918,
2541,
29918,
14369,
29918,
6519,
29898,
13,
1678,
14297,
29901,
1281,
1579,
8122,
23665,
2265,
29892,
13,
1678,
3646,
29918,
13010,
29918,
25978,
261,
29901,
2138,
4680,
29892,
13,
1678,
2752,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
3646,
29918,
13010,
29901,
12603,
552,
29961,
710,
29892,
938,
1402,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29901,
315,
492,
16802,
29892,
13,
1125,
13,
1678,
3806,
29918,
19158,
353,
7738,
29918,
726,
29918,
1688,
29918,
19158,
29918,
2541,
29918,
13662,
29898,
13010,
29918,
978,
29922,
4993,
29918,
13010,
29961,
29900,
1402,
14297,
29922,
5498,
2265,
29897,
13,
13,
1678,
1661,
29918,
1639,
4925,
29918,
11303,
29918,
27492,
29889,
9772,
29898,
13,
4706,
831,
802,
29892,
13,
4706,
6389,
29922,
3366,
3286,
571,
613,
376,
489,
3166,
29899,
13010,
613,
2752,
29918,
13010,
29961,
29900,
1402,
376,
489,
517,
29899,
13010,
613,
3646,
29918,
13010,
29961,
29900,
1402,
376,
489,
4537,
613,
376,
29896,
29900,
613,
376,
489,
4102,
12436,
13,
4706,
4380,
29918,
11739,
29879,
29922,
8824,
29892,
13,
1678,
1723,
13,
13,
1678,
3935,
29918,
19158,
353,
426,
13,
4706,
313,
7645,
29889,
1989,
2141,
13808,
3285,
10191,
29889,
1767,
2141,
13808,
3285,
10191,
29889,
16707,
3101,
13,
4706,
363,
10191,
297,
3646,
29918,
13010,
29918,
25978,
261,
29889,
3200,
2017,
29898,
29896,
29900,
29892,
11815,
29922,
29906,
29900,
29897,
13,
1678,
500,
13,
1678,
3806,
29918,
19158,
353,
426,
29898,
7645,
29889,
1989,
29892,
10191,
29889,
1767,
29892,
10191,
29889,
16707,
29897,
363,
10191,
297,
3806,
29918,
19158,
29913,
13,
1678,
4974,
3806,
29918,
19158,
1275,
3935,
29918,
19158,
13,
2
] |
World 03/Class 17/ex079.py | DanielRios549/PythonExcercises | 6 | 127765 | <reponame>DanielRios549/PythonExcercises
'''
Get an undefined numbers of values and put them in a list.
In the end, show all the unique values in ascendent order.
'''
values = []
while True:
number = int(input('Choose a number: '))
if number not in values:
print(f'\033[32mAdd the number {number} to the list.\033[m')
values.append(number)
else:
print(f'\033[31mThe number {number} already exists in the list. Not added.\033[m')
again = input('Do you want to continue? [Y/N]').upper()
if again == 'N':
break
values.sort()
print(f'You choose the values {values}')
| [
1,
529,
276,
1112,
420,
29958,
29866,
29934,
2363,
29945,
29946,
29929,
29914,
11980,
1252,
2265,
3476,
267,
13,
12008,
13,
1678,
3617,
385,
7580,
3694,
310,
1819,
322,
1925,
963,
297,
263,
1051,
29889,
13,
1678,
512,
278,
1095,
29892,
1510,
599,
278,
5412,
1819,
297,
12066,
3906,
1797,
29889,
13,
12008,
13,
5975,
353,
5159,
13,
13,
8000,
5852,
29901,
13,
1678,
1353,
353,
938,
29898,
2080,
877,
15954,
852,
263,
1353,
29901,
525,
876,
13,
13,
1678,
565,
1353,
451,
297,
1819,
29901,
13,
4706,
1596,
29898,
29888,
12764,
29900,
29941,
29941,
29961,
29941,
29906,
29885,
2528,
278,
1353,
426,
4537,
29913,
304,
278,
1051,
7790,
29900,
29941,
29941,
29961,
29885,
1495,
13,
4706,
1819,
29889,
4397,
29898,
4537,
29897,
13,
1678,
1683,
29901,
13,
4706,
1596,
29898,
29888,
12764,
29900,
29941,
29941,
29961,
29941,
29896,
29885,
1576,
1353,
426,
4537,
29913,
2307,
4864,
297,
278,
1051,
29889,
2216,
2715,
7790,
29900,
29941,
29941,
29961,
29885,
1495,
13,
13,
1678,
1449,
353,
1881,
877,
6132,
366,
864,
304,
6773,
29973,
518,
29979,
29914,
29940,
29962,
2824,
21064,
580,
13,
13,
1678,
565,
1449,
1275,
525,
29940,
2396,
13,
4706,
2867,
13,
13,
5975,
29889,
6605,
580,
13,
2158,
29898,
29888,
29915,
3492,
6755,
278,
1819,
426,
5975,
29913,
1495,
13,
2
] |
sorting/bubbleSort.py | rp581998/data-structures | 0 | 185692 | <reponame>rp581998/data-structures<gh_stars>0
'''def bubbleSort(arr):
n = len(arr)
for i in range(n):
for j in range(0,n-i-1):
if arr[j] > arr[j+1]:
temp = arr[j]
arr[j] = arr[j+1]
arr[j+1] = temp
arr = [10,9,15,1,5,2,6,3]
bubbleSort(arr)
print('Sorted array: ')
for i in range(len(arr)):
print(arr[i])
'''
# OR use this
'''
def bubbleSort(arr):
n = len(arr)
for i in range(n):
for j in range(0,n-i-1):
if arr[j] > arr[j+1]:
swap(arr, j, j+1)
def swap(arr, x, y):
temp = arr[x]
arr[x] = arr[y]
arr[y] = temp
'''
# OR use this,swap from last
def bubbleSort(arr):
n = len(arr)
for i in range(n):
for j in range(n-1,i,-1):
if arr[j] < arr[j-1]:
swap(arr, j, j-1)
def swap(arr, x, y):
temp = arr[x]
arr[x] = arr[y]
arr[y] = temp
arr = [10,9,15,1,5,2,6,3]
bubbleSort(arr)
print('Sorted array: ')
print(arr) | [
1,
529,
276,
1112,
420,
29958,
19080,
29945,
29947,
29896,
29929,
29929,
29947,
29914,
1272,
29899,
4984,
1973,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
12008,
1753,
289,
23232,
13685,
29898,
2749,
1125,
13,
1678,
302,
353,
7431,
29898,
2749,
29897,
13,
1678,
363,
474,
297,
3464,
29898,
29876,
1125,
13,
4706,
363,
432,
297,
3464,
29898,
29900,
29892,
29876,
29899,
29875,
29899,
29896,
1125,
13,
9651,
565,
3948,
29961,
29926,
29962,
1405,
3948,
29961,
29926,
29974,
29896,
5387,
13,
18884,
5694,
353,
3948,
29961,
29926,
29962,
13,
18884,
3948,
29961,
29926,
29962,
353,
3948,
29961,
29926,
29974,
29896,
29962,
13,
18884,
3948,
29961,
29926,
29974,
29896,
29962,
353,
5694,
13,
13,
2749,
353,
518,
29896,
29900,
29892,
29929,
29892,
29896,
29945,
29892,
29896,
29892,
29945,
29892,
29906,
29892,
29953,
29892,
29941,
29962,
13,
29890,
23232,
13685,
29898,
2749,
29897,
13,
2158,
877,
13685,
287,
1409,
29901,
25710,
13,
1454,
474,
297,
3464,
29898,
2435,
29898,
2749,
22164,
13,
1678,
1596,
29898,
2749,
29961,
29875,
2314,
13,
12008,
13,
29937,
462,
539,
6323,
671,
445,
9651,
13,
12008,
13,
1753,
289,
23232,
13685,
29898,
2749,
1125,
13,
1678,
302,
353,
7431,
29898,
2749,
29897,
13,
1678,
363,
474,
297,
3464,
29898,
29876,
1125,
13,
4706,
363,
432,
297,
3464,
29898,
29900,
29892,
29876,
29899,
29875,
29899,
29896,
1125,
13,
9651,
565,
3948,
29961,
29926,
29962,
1405,
3948,
29961,
29926,
29974,
29896,
5387,
13,
18884,
17945,
29898,
2749,
29892,
432,
29892,
432,
29974,
29896,
29897,
13,
1753,
17945,
29898,
2749,
29892,
921,
29892,
343,
1125,
13,
1678,
5694,
353,
3948,
29961,
29916,
29962,
13,
1678,
3948,
29961,
29916,
29962,
353,
3948,
29961,
29891,
29962,
13,
1678,
3948,
29961,
29891,
29962,
353,
5694,
13,
12008,
13,
29937,
462,
539,
6323,
671,
445,
29892,
26276,
515,
1833,
13,
13,
1753,
289,
23232,
13685,
29898,
2749,
1125,
13,
1678,
302,
353,
7431,
29898,
2749,
29897,
13,
1678,
363,
474,
297,
3464,
29898,
29876,
1125,
13,
4706,
363,
432,
297,
3464,
29898,
29876,
29899,
29896,
29892,
29875,
6653,
29896,
1125,
13,
9651,
565,
3948,
29961,
29926,
29962,
529,
3948,
29961,
29926,
29899,
29896,
5387,
13,
18884,
17945,
29898,
2749,
29892,
432,
29892,
432,
29899,
29896,
29897,
13,
1753,
17945,
29898,
2749,
29892,
921,
29892,
343,
1125,
13,
1678,
5694,
353,
3948,
29961,
29916,
29962,
13,
1678,
3948,
29961,
29916,
29962,
353,
3948,
29961,
29891,
29962,
13,
1678,
3948,
29961,
29891,
29962,
353,
5694,
13,
2749,
353,
518,
29896,
29900,
29892,
29929,
29892,
29896,
29945,
29892,
29896,
29892,
29945,
29892,
29906,
29892,
29953,
29892,
29941,
29962,
13,
29890,
23232,
13685,
29898,
2749,
29897,
13,
2158,
877,
13685,
287,
1409,
29901,
25710,
13,
2158,
29898,
2749,
29897,
2
] |
hard-gists/1191457/snippet.py | jjhenkel/dockerizeme | 21 | 21081 | #!/usr/bin/env python
import urllib
import sys
import json
from mwlib import parser
from mwlib.refine import compat
if __name__ == "__main__":
params = urllib.urlencode({
"format": "json",
"action": "query",
"prop": "revisions",
"rvprop": "content",
"titles": "ISO_3166-1",
"rvsection": "4",
})
wc = urllib.urlopen("http://en.wikipedia.org/w/api.php?%s" % params)
if wc.getcode() != 200:
print "Fail!"
sys.exit(2)
raw = wc.read()
rdata = json.loads(raw)
wc.close()
page = rdata['query']['pages'].itervalues().next()
if not page:
print "NO page found"
sys.exit(3)
revision = page['revisions'][0]
if not revision:
print "NO revision found"
sys.exit(4)
content = revision[str(revision.keys()[0])]
parsed = compat.parse_txt(content)
table = parsed.find(parser.Table)[0]
if not table:
print "Table not found"
sys.exit(5)
for row in table.children:
cells = row.find(parser.Cell)
print cells[0].asText().replace("}}", "").replace("{{", "").strip() + \
" || " + cells[1].asText().strip() + " || " + cells[2].asText().strip() \
+ " || " + cells[3].asText().strip()
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
5215,
3142,
1982,
13,
5215,
10876,
13,
5215,
4390,
13,
3166,
286,
29893,
1982,
1053,
13812,
13,
3166,
286,
29893,
1982,
29889,
999,
457,
1053,
10007,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
12,
7529,
353,
3142,
1982,
29889,
2271,
12508,
3319,
13,
12,
12,
29908,
4830,
1115,
376,
3126,
613,
13,
12,
12,
29908,
2467,
1115,
376,
1972,
613,
13,
12,
12,
29908,
7728,
1115,
376,
276,
1730,
1080,
613,
13,
12,
12,
29908,
15291,
7728,
1115,
376,
3051,
613,
13,
12,
12,
29908,
23545,
793,
1115,
376,
29096,
29918,
29941,
29896,
29953,
29953,
29899,
29896,
613,
13,
12,
12,
29908,
15291,
2042,
1115,
376,
29946,
613,
13,
12,
1800,
13,
12,
29893,
29883,
353,
3142,
1982,
29889,
332,
417,
2238,
703,
1124,
597,
264,
29889,
6011,
29889,
990,
29914,
29893,
29914,
2754,
29889,
1961,
29973,
29995,
29879,
29908,
1273,
8636,
29897,
13,
12,
361,
28678,
29889,
657,
401,
580,
2804,
29871,
29906,
29900,
29900,
29901,
13,
12,
12,
2158,
376,
16243,
3850,
13,
12,
12,
9675,
29889,
13322,
29898,
29906,
29897,
13,
13,
12,
1610,
353,
28678,
29889,
949,
580,
13,
12,
29878,
1272,
353,
4390,
29889,
18132,
29898,
1610,
29897,
13,
12,
29893,
29883,
29889,
5358,
580,
13,
13,
12,
3488,
353,
364,
1272,
1839,
1972,
16215,
12292,
13359,
1524,
5975,
2141,
4622,
580,
13,
12,
361,
451,
1813,
29901,
13,
12,
12,
2158,
376,
6632,
1813,
1476,
29908,
13,
12,
12,
9675,
29889,
13322,
29898,
29941,
29897,
13,
13,
12,
276,
4924,
353,
1813,
1839,
276,
1730,
1080,
2033,
29961,
29900,
29962,
13,
12,
361,
451,
26554,
29901,
13,
12,
12,
2158,
376,
6632,
26554,
1476,
29908,
13,
12,
12,
9675,
29889,
13322,
29898,
29946,
29897,
13,
13,
12,
3051,
353,
26554,
29961,
710,
29898,
276,
4924,
29889,
8149,
580,
29961,
29900,
2314,
29962,
13,
12,
862,
8485,
353,
10007,
29889,
5510,
29918,
3945,
29898,
3051,
29897,
13,
12,
2371,
353,
21213,
29889,
2886,
29898,
16680,
29889,
3562,
9601,
29900,
29962,
13,
13,
12,
361,
451,
1591,
29901,
13,
12,
12,
2158,
376,
3562,
451,
1476,
29908,
13,
12,
12,
9675,
29889,
13322,
29898,
29945,
29897,
13,
13,
12,
1454,
1948,
297,
1591,
29889,
11991,
29901,
13,
12,
12,
3729,
29879,
353,
1948,
29889,
2886,
29898,
16680,
29889,
4617,
29897,
13,
12,
12,
2158,
9101,
29961,
29900,
1822,
294,
1626,
2141,
6506,
703,
930,
613,
376,
2564,
6506,
703,
6224,
613,
376,
2564,
17010,
580,
718,
320,
13,
12,
12,
29908,
3830,
376,
718,
9101,
29961,
29896,
1822,
294,
1626,
2141,
17010,
580,
718,
376,
3830,
376,
718,
9101,
29961,
29906,
1822,
294,
1626,
2141,
17010,
580,
320,
13,
12,
12,
29974,
376,
3830,
376,
718,
9101,
29961,
29941,
1822,
294,
1626,
2141,
17010,
580,
13,
2
] |
exercises/fit_gaussian_estimators.py | talazulay27/IML.HUJI | 0 | 170652 | <gh_stars>0
import numpy
from plotly.subplots import make_subplots
from IMLearn.learners import UnivariateGaussian, MultivariateGaussian
import numpy as np
import plotly.graph_objects as go
import plotly.io as pio
pio.templates.default = "simple_white"
def test_univariate_gaussian():
# Question 1 - Draw samples and print fitted model
samples = np.random.normal(10, 1, 1000)
univariate_gaussian = UnivariateGaussian()
univariate_gaussian.fit(samples)
print((univariate_gaussian.mu_, univariate_gaussian.var_))
# Question 2 - Empirically showing sample mean is consistent
axis_x = np.linspace(10, 1000, 100)
results = numpy.zeros(100)
counter = 0
for i in range(10, 1001, 10):
results[counter] = np.abs(np.mean(samples[:i]) - 10)
counter = counter + 1
fig = make_subplots(rows=1, cols=1) \
.add_traces([go.Scatter(x=axis_x, y=results, mode='lines', marker=dict(color="black"),
showlegend=False)]) \
.update_layout(title_text=r"$\text{Univariate Gaussian Estimation - Question 2}$",
height=800)
fig.update_xaxes(title_text="Sample size", row=1, col=1)
fig.update_yaxes(title_text="Absolute distance", row=1, col=1)
fig.show()
# Question 3 - Plotting Empirical PDF of fitted model
np.sort(samples)
pdf_results = univariate_gaussian.pdf(samples)
fig = make_subplots(rows=1, cols=1) \
.add_traces([go.Scatter(x=samples, y=pdf_results, mode='markers',
marker=dict(color="red"), showlegend=False)])
fig.update_xaxes(title_text="Sample value", row=1, col=1)
fig.update_yaxes(title_text="PDF Value", row=1, col=1)
fig.update_layout(title_text=r"$\text{Empirical PDF Function- Question 3}$", height=800)
fig.show()
def test_multivariate_gaussian():
# Question 4 - Draw samples and print fitted model
multivariate_gaussian = MultivariateGaussian()
mu = np.array([0, 0, 4, 0])
sigma = np.array([[1, 0.2, 0, 0.5], [0.2, 2, 0, 0], [0, 0, 1, 0], [0.5, 0, 0, 1]])
samples = np.random.multivariate_normal(mu, sigma, 1000)
multivariate_gaussian.fit(samples)
print(multivariate_gaussian.mu_)
print(multivariate_gaussian.cov_)
# Question 5 - Likelihood evaluation
f1 = np.linspace(-10, 10, 200)
f3 = np.linspace(-10, 10, 200)
results = np.zeros([200, 200])
for i in range(0, 200):
for j in range(0, 200):
mu = np.array([f1[i], 0, f3[j], 0])
results[i][j] = multivariate_gaussian.log_likelihood(mu, sigma, samples)
fig = make_subplots(rows=1, cols=1).add_traces(go.Heatmap(x=f1, y=f3, z=results))
fig.update_xaxes(title_text="f1 values", row=1, col=1)
fig.update_yaxes(title_text="f3 values", row=1, col=1)
fig.update_layout(title_text=r"$\text{HeatMap - Question 5}$", height=800)
fig.show()
# Question 6 - Maximum likelihood
indices = np.unravel_index(np.argmax(results, axis=None), results.shape)
print("The model achieved the maximum log-likelihood value is:")
print("f1 = " + str(f1[indices[0]]))
print("f3 = " + str(f1[indices[1]]))
if __name__ == '__main__':
np.random.seed(0)
test_univariate_gaussian()
test_multivariate_gaussian()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
12655,
13,
3166,
6492,
368,
29889,
1491,
26762,
1053,
1207,
29918,
1491,
26762,
13,
3166,
306,
1988,
799,
29876,
29889,
1945,
8397,
1053,
853,
27432,
403,
29954,
17019,
29892,
9683,
27432,
403,
29954,
17019,
13,
5215,
12655,
408,
7442,
13,
5215,
6492,
368,
29889,
4262,
29918,
12650,
408,
748,
13,
5215,
6492,
368,
29889,
601,
408,
282,
601,
13,
13,
16168,
29889,
20943,
29889,
4381,
353,
376,
12857,
29918,
10921,
29908,
13,
13,
13,
1753,
1243,
29918,
348,
27432,
403,
29918,
29887,
17019,
7295,
13,
13,
1678,
396,
894,
29871,
29896,
448,
18492,
11916,
322,
1596,
25890,
1904,
13,
1678,
11916,
353,
7442,
29889,
8172,
29889,
8945,
29898,
29896,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29900,
29900,
29900,
29897,
13,
1678,
443,
27432,
403,
29918,
29887,
17019,
353,
853,
27432,
403,
29954,
17019,
580,
13,
1678,
443,
27432,
403,
29918,
29887,
17019,
29889,
9202,
29898,
27736,
29897,
13,
1678,
1596,
3552,
348,
27432,
403,
29918,
29887,
17019,
29889,
2589,
3383,
443,
27432,
403,
29918,
29887,
17019,
29889,
1707,
29918,
876,
13,
13,
1678,
396,
894,
29871,
29906,
448,
7361,
381,
1711,
6445,
4559,
2099,
338,
13747,
13,
1678,
9685,
29918,
29916,
353,
7442,
29889,
1915,
3493,
29898,
29896,
29900,
29892,
29871,
29896,
29900,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29897,
13,
1678,
2582,
353,
12655,
29889,
3298,
359,
29898,
29896,
29900,
29900,
29897,
13,
1678,
6795,
353,
29871,
29900,
13,
1678,
363,
474,
297,
3464,
29898,
29896,
29900,
29892,
29871,
29896,
29900,
29900,
29896,
29892,
29871,
29896,
29900,
1125,
13,
4706,
2582,
29961,
11808,
29962,
353,
7442,
29889,
6897,
29898,
9302,
29889,
12676,
29898,
27736,
7503,
29875,
2314,
448,
29871,
29896,
29900,
29897,
13,
4706,
6795,
353,
6795,
718,
29871,
29896,
13,
13,
1678,
2537,
353,
1207,
29918,
1491,
26762,
29898,
5727,
29922,
29896,
29892,
28730,
29922,
29896,
29897,
320,
13,
4706,
869,
1202,
29918,
3018,
778,
4197,
1484,
29889,
4421,
2620,
29898,
29916,
29922,
8990,
29918,
29916,
29892,
343,
29922,
9902,
29892,
4464,
2433,
9012,
742,
17456,
29922,
8977,
29898,
2780,
543,
8517,
4968,
13,
462,
18884,
1510,
26172,
29922,
8824,
29897,
2314,
320,
13,
4706,
869,
5504,
29918,
2680,
29898,
3257,
29918,
726,
29922,
29878,
29908,
4535,
726,
29912,
2525,
27432,
403,
22477,
2661,
7715,
448,
894,
29871,
29906,
1042,
613,
13,
462,
539,
3171,
29922,
29947,
29900,
29900,
29897,
13,
1678,
2537,
29889,
5504,
29918,
29916,
1165,
267,
29898,
3257,
29918,
726,
543,
17708,
2159,
613,
1948,
29922,
29896,
29892,
784,
29922,
29896,
29897,
13,
1678,
2537,
29889,
5504,
29918,
29891,
1165,
267,
29898,
3257,
29918,
726,
543,
4920,
14977,
5418,
613,
1948,
29922,
29896,
29892,
784,
29922,
29896,
29897,
13,
1678,
2537,
29889,
4294,
580,
13,
13,
1678,
396,
894,
29871,
29941,
448,
18399,
1259,
7361,
381,
936,
11328,
310,
25890,
1904,
13,
1678,
7442,
29889,
6605,
29898,
27736,
29897,
13,
1678,
13552,
29918,
9902,
353,
443,
27432,
403,
29918,
29887,
17019,
29889,
5140,
29898,
27736,
29897,
13,
1678,
2537,
353,
1207,
29918,
1491,
26762,
29898,
5727,
29922,
29896,
29892,
28730,
29922,
29896,
29897,
320,
13,
4706,
869,
1202,
29918,
3018,
778,
4197,
1484,
29889,
4421,
2620,
29898,
29916,
29922,
27736,
29892,
343,
29922,
5140,
29918,
9902,
29892,
4464,
2433,
3502,
414,
742,
13,
462,
18884,
17456,
29922,
8977,
29898,
2780,
543,
1127,
4968,
1510,
26172,
29922,
8824,
29897,
2314,
13,
1678,
2537,
29889,
5504,
29918,
29916,
1165,
267,
29898,
3257,
29918,
726,
543,
17708,
995,
613,
1948,
29922,
29896,
29892,
784,
29922,
29896,
29897,
13,
1678,
2537,
29889,
5504,
29918,
29891,
1165,
267,
29898,
3257,
29918,
726,
543,
8493,
7865,
613,
1948,
29922,
29896,
29892,
784,
29922,
29896,
29897,
13,
1678,
2537,
29889,
5504,
29918,
2680,
29898,
3257,
29918,
726,
29922,
29878,
29908,
4535,
726,
29912,
10495,
381,
936,
11328,
6680,
29899,
894,
29871,
29941,
1042,
613,
3171,
29922,
29947,
29900,
29900,
29897,
13,
1678,
2537,
29889,
4294,
580,
13,
13,
13,
1753,
1243,
29918,
4713,
27432,
403,
29918,
29887,
17019,
7295,
13,
13,
1678,
396,
894,
29871,
29946,
448,
18492,
11916,
322,
1596,
25890,
1904,
13,
1678,
1773,
27432,
403,
29918,
29887,
17019,
353,
9683,
27432,
403,
29954,
17019,
580,
13,
1678,
3887,
353,
7442,
29889,
2378,
4197,
29900,
29892,
29871,
29900,
29892,
29871,
29946,
29892,
29871,
29900,
2314,
13,
1678,
269,
2934,
353,
7442,
29889,
2378,
4197,
29961,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29892,
29871,
29900,
29889,
29945,
1402,
518,
29900,
29889,
29906,
29892,
29871,
29906,
29892,
29871,
29900,
29892,
29871,
29900,
1402,
518,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
1402,
518,
29900,
29889,
29945,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
24960,
13,
1678,
11916,
353,
7442,
29889,
8172,
29889,
4713,
27432,
403,
29918,
8945,
29898,
2589,
29892,
269,
2934,
29892,
29871,
29896,
29900,
29900,
29900,
29897,
13,
1678,
1773,
27432,
403,
29918,
29887,
17019,
29889,
9202,
29898,
27736,
29897,
13,
1678,
1596,
29898,
4713,
27432,
403,
29918,
29887,
17019,
29889,
2589,
19925,
13,
1678,
1596,
29898,
4713,
27432,
403,
29918,
29887,
17019,
29889,
24542,
19925,
13,
13,
1678,
396,
894,
29871,
29945,
448,
365,
638,
22342,
17983,
13,
1678,
285,
29896,
353,
7442,
29889,
1915,
3493,
6278,
29896,
29900,
29892,
29871,
29896,
29900,
29892,
29871,
29906,
29900,
29900,
29897,
13,
1678,
285,
29941,
353,
7442,
29889,
1915,
3493,
6278,
29896,
29900,
29892,
29871,
29896,
29900,
29892,
29871,
29906,
29900,
29900,
29897,
13,
1678,
2582,
353,
7442,
29889,
3298,
359,
4197,
29906,
29900,
29900,
29892,
29871,
29906,
29900,
29900,
2314,
13,
1678,
363,
474,
297,
3464,
29898,
29900,
29892,
29871,
29906,
29900,
29900,
1125,
13,
4706,
363,
432,
297,
3464,
29898,
29900,
29892,
29871,
29906,
29900,
29900,
1125,
13,
9651,
3887,
353,
7442,
29889,
2378,
4197,
29888,
29896,
29961,
29875,
1402,
29871,
29900,
29892,
285,
29941,
29961,
29926,
1402,
29871,
29900,
2314,
13,
9651,
2582,
29961,
29875,
3816,
29926,
29962,
353,
1773,
27432,
403,
29918,
29887,
17019,
29889,
1188,
29918,
5081,
22342,
29898,
2589,
29892,
269,
2934,
29892,
11916,
29897,
13,
13,
1678,
2537,
353,
1207,
29918,
1491,
26762,
29898,
5727,
29922,
29896,
29892,
28730,
29922,
29896,
467,
1202,
29918,
3018,
778,
29898,
1484,
29889,
3868,
271,
1958,
29898,
29916,
29922,
29888,
29896,
29892,
343,
29922,
29888,
29941,
29892,
503,
29922,
9902,
876,
13,
1678,
2537,
29889,
5504,
29918,
29916,
1165,
267,
29898,
3257,
29918,
726,
543,
29888,
29896,
1819,
613,
1948,
29922,
29896,
29892,
784,
29922,
29896,
29897,
13,
1678,
2537,
29889,
5504,
29918,
29891,
1165,
267,
29898,
3257,
29918,
726,
543,
29888,
29941,
1819,
613,
1948,
29922,
29896,
29892,
784,
29922,
29896,
29897,
13,
1678,
2537,
29889,
5504,
29918,
2680,
29898,
3257,
29918,
726,
29922,
29878,
29908,
4535,
726,
29912,
3868,
271,
3388,
448,
894,
29871,
29945,
1042,
613,
3171,
29922,
29947,
29900,
29900,
29897,
13,
1678,
2537,
29889,
4294,
580,
13,
13,
1678,
396,
894,
29871,
29953,
448,
5918,
12539,
4188,
22342,
13,
13,
1678,
16285,
353,
7442,
29889,
348,
336,
955,
29918,
2248,
29898,
9302,
29889,
1191,
3317,
29898,
9902,
29892,
9685,
29922,
8516,
511,
2582,
29889,
12181,
29897,
13,
1678,
1596,
703,
1576,
1904,
14363,
278,
7472,
1480,
29899,
5081,
22342,
995,
338,
29901,
1159,
13,
1678,
1596,
703,
29888,
29896,
353,
376,
718,
851,
29898,
29888,
29896,
29961,
513,
1575,
29961,
29900,
5262,
876,
13,
1678,
1596,
703,
29888,
29941,
353,
376,
718,
851,
29898,
29888,
29896,
29961,
513,
1575,
29961,
29896,
5262,
876,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
7442,
29889,
8172,
29889,
26776,
29898,
29900,
29897,
13,
1678,
1243,
29918,
348,
27432,
403,
29918,
29887,
17019,
580,
13,
1678,
1243,
29918,
4713,
27432,
403,
29918,
29887,
17019,
580,
13,
2
] |
tests/artificial/test_memory.py | anrddh/memsight | 1 | 1614889 | import angr
import claripy
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
from memory import factory
def check(state, obj, exp_values, conditions=()):
r = state.se.eval_upto(obj, len(exp_values) + 1, extra_constraints=conditions)
if len(r) != len(exp_values) or set(r) != set(exp_values):
print("Mismatch:")
print("\tobtained: " + str(r))
print("\texpected: " + str(exp_values))
assert len(r) == len(exp_values) and set(r) == set(exp_values)
def test_store_with_symbolic_size(state):
val = 0x01020304
state.memory.store(0x0, claripy.BVV(val, 32))
res = state.memory.load(0x0, 4)
assert not state.se.symbolic(res) and state.se.eval(res) == val
val_2 = 0x0506
s_size = claripy.BVS('size', 32)
state.se.add(s_size <= 2)
state.memory.store(0x1, claripy.BVV(val_2, 16), s_size)
res = state.se.eval_upto(state.memory.load(0x0, 4), 10)
# print ' '.join([hex(x) for x in res])
assert len(state.se.eval_upto(state.memory.load(0x0, 4), 10)) == 3
s0 = state.copy()
assert len(s0.se.eval_upto(s0.memory.load(0x0, 4), 10)) == 3
s1 = state.copy()
s1.se.add(s_size == 0)
res = s1.se.eval_upto(s1.memory.load(0x0, 4), 2)
assert len(res) == 1 and res[0] == val
s2 = state.copy()
s2.se.add(s_size == 1)
res = s2.se.eval_upto(s2.memory.load(0x0, 4), 2)
assert len(res) == 1 and res[0] == 0x01050304
s3 = state.copy()
s3.se.add(s_size == 2)
res = s3.se.eval_upto(s3.memory.load(0x0, 4), 2)
assert len(res) == 1 and res[0] == 0x01050604
def test_store_with_symbolic_addr_and_symbolic_size(state):
#state.memory.set_verbose(True)
val = 0x01020304
addr = claripy.BVS('addr', 64)
state.se.add(addr < 8)
state.memory.store(addr, claripy.BVV(val, 32), 4)
res = state.memory.load(addr, 4)
res = state.se.eval_upto(res, 20)
assert len(res) == 1 and res[0] == val
val_2 = 0x0506
s_size = claripy.BVS('size', 32)
state.se.add(s_size <= 2)
state.memory.store(addr + 1, claripy.BVV(val_2, 16), s_size)
s0 = state.copy()
assert len(s0.se.eval_upto(s0.memory.load(addr, 4), 10)) == 3
s1 = state.copy()
s1.se.add(s_size == 0)
res = s1.se.eval_upto(s1.memory.load(addr, 4), 2)
assert len(res) == 1 and res[0] == val
s2 = state.copy()
s2.se.add(s_size == 1)
res = s2.se.eval_upto(s2.memory.load(addr, 4), 2)
assert len(res) == 1 and res[0] == 0x01050304
s3 = state.copy()
s3.se.add(s_size == 2)
res = s3.se.eval_upto(s3.memory.load(addr, 4), 2)
assert len(res) == 1 and res[0] == 0x01050604
def test_concrete_merge(state):
val = 0x01020304
state.memory.store(0x0, claripy.BVV(val, 32))
s1 = state.copy()
s2 = state.copy()
s1.memory.store(0x1, claripy.BVV(0x05, 8))
s2.memory.store(0x1, claripy.BVV(0x06, 8))
s3 = s1.copy()
guard = claripy.BVS('branch', 32)
s3.memory.merge([s2.memory], [guard > 0, guard <= 0], state.memory)
res = s3.memory.load(0x0, 4)
r1 = s3.se.eval_upto(res, 2, extra_constraints=(guard > 0,))
assert len(r1) == 1 and r1[0] == 0x01050304
r2 = s3.se.eval_upto(res, 2, extra_constraints=(guard <= 0,))
assert len(r2) == 1 and r2[0] == 0x01060304
def test_concrete_merge_with_condition(state):
val = 0x01020304
state.memory.store(0x0, claripy.BVV(val, 32))
s1 = state.copy()
s2 = state.copy()
s1.memory.store(0x1, claripy.BVV(0x05, 8))
cond = claripy.BVS('cond', 32)
s2.memory.store(0x1, claripy.BVV(0x06, 8), condition=cond != 0)
s3 = s1.copy()
guard = claripy.BVS('guard', 32)
s3.memory.merge([s2.memory], [guard > 1, guard <= 1], s1.memory)
res = s3.memory.load(0x0, 4)
r1 = s3.se.eval_upto(res, 2, extra_constraints=(guard > 1,))
assert len(r1) == 1 and r1[0] == 0x01050304
r2 = s3.se.eval_upto(res, 3, extra_constraints=(guard <= 1,))
assert len(r2) == 2 and set(r2) == set([0x01020304, 0x01060304])
s4 = s3.copy()
s4.se.add(guard == 1)
s4.se.add(cond != 0)
res = s4.memory.load(0x0, 4)
r3 = s4.se.eval_upto(res, 2)
assert len(r3) == 1 and r3[0] == 0x01060304
def test_symbolic_merge(state):
val = 0x01020304
state.memory.store(0x0, claripy.BVV(val, 32))
a = claripy.BVS('a0', 64)
state.se.add(a <= 1)
state.memory.store(a, claripy.BVV(0x5, 8))
res = state.memory.load(0x0, 1)
check(state, res, [5, 1])
s1 = state.copy()
s1.memory.store(0x1, claripy.BVV(0x6, 8))
a1 = claripy.BVS('a1', 64)
s1.se.add(a1 >= 1)
s1.se.add(a1 <= 2)
s1.memory.store(a1, claripy.BVV(0x7, 8))
s2 = state.copy()
s2.memory.store(0x1, claripy.BVV(0x8, 8))
a2 = claripy.BVS('a2', 64)
s2.se.add(a2 >= 1)
s2.se.add(a2 <= 2)
s2.memory.store(a2, claripy.BVV(0x9, 8))
s3 = s1.copy()
guard = claripy.BVS('guard', 32)
s3.memory.merge([s2.memory], [guard > 1, guard <= 1], s1.memory)
res = s3.memory.load(0x0, 1)
check(s3, res, [5], (a == 0,))
check(s3, res, [1], (a == 1,))
res = s3.memory.load(0x1, 1)
check(s3, res, [7], (guard > 1, a1 == 1, ))
check(s3, res, [6], (guard > 1, a1 == 2,))
check(s3, res, [9], (guard <= 1, a2 == 1,))
check(s3, res, [8], (guard <= 1, a2 == 2,))
res = s3.memory.load(0x2, 1)
check(s3, res, [7], (guard > 1, a1 == 2,))
check(s3, res, [3], (guard > 1, a1 == 1,))
check(s3, res, [9], (guard <= 1, a2 == 2,))
check(s3, res, [3], (guard <= 1, a2 == 1,))
res = s3.memory.load(0x3, 1)
check(s3, res, [4], set())
def test_symbolic_access(state):
# an address which is in a valid region
start_addr = state.heap.allocate(32)
#assert state.se.any_int(state.memory.permissions(start_addr)) == 0x3
#assert state.se.any_int(state.memory.permissions(start_addr + 1)) == 0x3
#assert state.se.any_int(state.memory.permissions(start_addr + 2)) == 0x3
# init memory 3 bytes starting at start_addr
state.memory.store(start_addr, claripy.BVV(0x0, 24), 3)
# a symbolic pointer that can be equal to [start_addr, start_addr + 1]
addr = claripy.BVS('addr', 64)
state.se.add(addr >= start_addr)
state.se.add(addr <= start_addr + 1)
addrs = state.se.eval_upto(addr, 10)
assert len(addrs) == 2 and set(addrs) == set([start_addr, start_addr + 1])
val = 0xABCD
# symbolic store at addr
state.memory.store(addr, claripy.BVV(val, 16), 2)
# symbolic load at addr
res = state.memory.load(addr, 2)
res = state.se.eval_upto(res, 20)
assert len(res) == 1 and res[0] == val
def test_same_operator(state):
a = claripy.BVS('a', 8)
b = claripy.BVS('b', 8)
assert not state.memory.same(a, b)
state.se.add(a == b)
assert state.memory.same(a, b)
state.se.add(a < 5)
assert state.memory.same(a, b)
zero = claripy.BVV(0x0, 8)
assert not state.memory.same(a, zero)
state.se.add(a < 1)
assert state.memory.same(a, zero)
if __name__ == '__main__':
t = 0
angr_project = angr.Project("/bin/ls", load_options={'auto_load_libs': False})
if t == 0:
mem_memory, reg_memory = None, None
elif t == 1:
mem_memory, reg_memory = factory.get_range_fully_symbolic_memory(angr_project)
#mem_memory.set_verbose(True)
plugins = {}
if mem_memory is not None:
plugins['memory'] = mem_memory
if reg_memory is not None:
plugins['registers'] = reg_memory
add_options = {None}
#add_options = {simuvex.o.STRICT_PAGE_ACCESS}
# add_options = {simuvex.o.CGC_ZERO_FILL_UNCONSTRAINED_MEMORY}
state = angr_project.factory.entry_state(remove_options={angr.options.LAZY_SOLVES},
add_options=add_options, plugins=plugins)
if t == 0:
# store: add new concretization strategy
state.memory.write_strategies.insert(0, angr.concretization_strategies.SimConcretizationStrategyRange(2048))
state.memory.read_strategies.insert(0, angr.concretization_strategies.SimConcretizationStrategyRange(2048))
pass
test_symbolic_access(state.copy())
test_store_with_symbolic_size(state.copy())
test_store_with_symbolic_addr_and_symbolic_size(state.copy())
test_concrete_merge(state.copy())
test_concrete_merge_with_condition(state.copy())
test_symbolic_merge(state.copy())
if t == 1:
test_same_operator(state.copy())
| [
1,
1053,
385,
629,
13,
5215,
7542,
666,
29891,
13,
5215,
2897,
13,
5215,
10876,
13,
13,
9675,
29889,
2084,
29889,
4397,
29898,
359,
29889,
2084,
29889,
7122,
29898,
359,
29889,
2084,
29889,
25721,
22168,
1445,
1649,
511,
525,
6995,
636,
8785,
13,
13,
3166,
3370,
1053,
12529,
13,
13,
13,
1753,
1423,
29898,
3859,
29892,
5446,
29892,
1518,
29918,
5975,
29892,
5855,
29922,
580,
1125,
13,
1678,
364,
353,
2106,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
5415,
29892,
7431,
29898,
4548,
29918,
5975,
29897,
718,
29871,
29896,
29892,
4805,
29918,
13646,
29879,
29922,
1116,
2187,
29897,
13,
1678,
565,
7431,
29898,
29878,
29897,
2804,
7431,
29898,
4548,
29918,
5975,
29897,
470,
731,
29898,
29878,
29897,
2804,
731,
29898,
4548,
29918,
5975,
1125,
13,
4706,
1596,
703,
29924,
1608,
905,
29901,
1159,
13,
4706,
1596,
14182,
517,
29890,
2408,
287,
29901,
376,
718,
851,
29898,
29878,
876,
13,
4706,
1596,
14182,
4776,
6021,
29901,
376,
718,
851,
29898,
4548,
29918,
5975,
876,
13,
1678,
4974,
7431,
29898,
29878,
29897,
1275,
7431,
29898,
4548,
29918,
5975,
29897,
322,
731,
29898,
29878,
29897,
1275,
731,
29898,
4548,
29918,
5975,
29897,
13,
13,
1753,
1243,
29918,
8899,
29918,
2541,
29918,
18098,
293,
29918,
2311,
29898,
3859,
1125,
13,
13,
1678,
659,
353,
29871,
29900,
29916,
29900,
29896,
29900,
29906,
29900,
29941,
29900,
29946,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29900,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
791,
29892,
29871,
29941,
29906,
876,
13,
1678,
620,
353,
2106,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
29897,
13,
1678,
4974,
451,
2106,
29889,
344,
29889,
18098,
293,
29898,
690,
29897,
322,
2106,
29889,
344,
29889,
14513,
29898,
690,
29897,
1275,
659,
13,
13,
1678,
659,
29918,
29906,
353,
29871,
29900,
29916,
29900,
29945,
29900,
29953,
13,
1678,
269,
29918,
2311,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
2311,
742,
29871,
29941,
29906,
29897,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
29879,
29918,
2311,
5277,
29871,
29906,
29897,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
791,
29918,
29906,
29892,
29871,
29896,
29953,
511,
269,
29918,
2311,
29897,
13,
1678,
620,
353,
2106,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
3859,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
511,
29871,
29896,
29900,
29897,
13,
1678,
396,
1596,
525,
15300,
7122,
4197,
20970,
29898,
29916,
29897,
363,
921,
297,
620,
2314,
13,
1678,
4974,
7431,
29898,
3859,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
3859,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
511,
29871,
29896,
29900,
876,
1275,
29871,
29941,
13,
13,
1678,
269,
29900,
353,
2106,
29889,
8552,
580,
13,
1678,
4974,
7431,
29898,
29879,
29900,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
29879,
29900,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
511,
29871,
29896,
29900,
876,
1275,
29871,
29941,
13,
13,
1678,
269,
29896,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29896,
29889,
344,
29889,
1202,
29898,
29879,
29918,
2311,
1275,
29871,
29900,
29897,
13,
1678,
620,
353,
269,
29896,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
29879,
29896,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
511,
29871,
29906,
29897,
13,
1678,
4974,
7431,
29898,
690,
29897,
1275,
29871,
29896,
322,
620,
29961,
29900,
29962,
1275,
659,
13,
13,
1678,
269,
29906,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29906,
29889,
344,
29889,
1202,
29898,
29879,
29918,
2311,
1275,
29871,
29896,
29897,
13,
1678,
620,
353,
269,
29906,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
29879,
29906,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
511,
29871,
29906,
29897,
13,
1678,
4974,
7431,
29898,
690,
29897,
1275,
29871,
29896,
322,
620,
29961,
29900,
29962,
1275,
29871,
29900,
29916,
29900,
29896,
29900,
29945,
29900,
29941,
29900,
29946,
13,
13,
1678,
269,
29941,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29941,
29889,
344,
29889,
1202,
29898,
29879,
29918,
2311,
1275,
29871,
29906,
29897,
13,
1678,
620,
353,
269,
29941,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
29879,
29941,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
511,
29871,
29906,
29897,
13,
1678,
4974,
7431,
29898,
690,
29897,
1275,
29871,
29896,
322,
620,
29961,
29900,
29962,
1275,
29871,
29900,
29916,
29900,
29896,
29900,
29945,
29900,
29953,
29900,
29946,
13,
13,
13,
1753,
1243,
29918,
8899,
29918,
2541,
29918,
18098,
293,
29918,
10030,
29918,
392,
29918,
18098,
293,
29918,
2311,
29898,
3859,
1125,
13,
13,
1678,
396,
3859,
29889,
14834,
29889,
842,
29918,
369,
15828,
29898,
5574,
29897,
13,
13,
1678,
659,
353,
29871,
29900,
29916,
29900,
29896,
29900,
29906,
29900,
29941,
29900,
29946,
13,
1678,
28915,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
10030,
742,
29871,
29953,
29946,
29897,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
10030,
529,
29871,
29947,
29897,
13,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
10030,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
791,
29892,
29871,
29941,
29906,
511,
29871,
29946,
29897,
13,
13,
1678,
620,
353,
2106,
29889,
14834,
29889,
1359,
29898,
10030,
29892,
29871,
29946,
29897,
13,
13,
1678,
620,
353,
2106,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
690,
29892,
29871,
29906,
29900,
29897,
13,
1678,
4974,
7431,
29898,
690,
29897,
1275,
29871,
29896,
322,
620,
29961,
29900,
29962,
1275,
659,
13,
13,
1678,
659,
29918,
29906,
353,
29871,
29900,
29916,
29900,
29945,
29900,
29953,
13,
1678,
269,
29918,
2311,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
2311,
742,
29871,
29941,
29906,
29897,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
29879,
29918,
2311,
5277,
29871,
29906,
29897,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
10030,
718,
29871,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
791,
29918,
29906,
29892,
29871,
29896,
29953,
511,
269,
29918,
2311,
29897,
13,
13,
1678,
269,
29900,
353,
2106,
29889,
8552,
580,
13,
1678,
4974,
7431,
29898,
29879,
29900,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
29879,
29900,
29889,
14834,
29889,
1359,
29898,
10030,
29892,
29871,
29946,
511,
29871,
29896,
29900,
876,
1275,
29871,
29941,
13,
13,
1678,
269,
29896,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29896,
29889,
344,
29889,
1202,
29898,
29879,
29918,
2311,
1275,
29871,
29900,
29897,
13,
1678,
620,
353,
269,
29896,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
29879,
29896,
29889,
14834,
29889,
1359,
29898,
10030,
29892,
29871,
29946,
511,
29871,
29906,
29897,
13,
1678,
4974,
7431,
29898,
690,
29897,
1275,
29871,
29896,
322,
620,
29961,
29900,
29962,
1275,
659,
13,
13,
1678,
269,
29906,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29906,
29889,
344,
29889,
1202,
29898,
29879,
29918,
2311,
1275,
29871,
29896,
29897,
13,
1678,
620,
353,
269,
29906,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
29879,
29906,
29889,
14834,
29889,
1359,
29898,
10030,
29892,
29871,
29946,
511,
29871,
29906,
29897,
13,
1678,
4974,
7431,
29898,
690,
29897,
1275,
29871,
29896,
322,
620,
29961,
29900,
29962,
1275,
29871,
29900,
29916,
29900,
29896,
29900,
29945,
29900,
29941,
29900,
29946,
13,
13,
1678,
269,
29941,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29941,
29889,
344,
29889,
1202,
29898,
29879,
29918,
2311,
1275,
29871,
29906,
29897,
13,
1678,
620,
353,
269,
29941,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
29879,
29941,
29889,
14834,
29889,
1359,
29898,
10030,
29892,
29871,
29946,
511,
29871,
29906,
29897,
13,
1678,
4974,
7431,
29898,
690,
29897,
1275,
29871,
29896,
322,
620,
29961,
29900,
29962,
1275,
29871,
29900,
29916,
29900,
29896,
29900,
29945,
29900,
29953,
29900,
29946,
13,
13,
1753,
1243,
29918,
535,
9084,
29918,
14634,
29898,
3859,
1125,
13,
13,
1678,
659,
353,
29871,
29900,
29916,
29900,
29896,
29900,
29906,
29900,
29941,
29900,
29946,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29900,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
791,
29892,
29871,
29941,
29906,
876,
13,
13,
1678,
269,
29896,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29906,
353,
2106,
29889,
8552,
580,
13,
13,
1678,
269,
29896,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29900,
29945,
29892,
29871,
29947,
876,
13,
1678,
269,
29906,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29900,
29953,
29892,
29871,
29947,
876,
13,
13,
1678,
269,
29941,
353,
269,
29896,
29889,
8552,
580,
13,
1678,
8372,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
17519,
742,
29871,
29941,
29906,
29897,
13,
1678,
269,
29941,
29889,
14834,
29889,
14634,
4197,
29879,
29906,
29889,
14834,
1402,
518,
17728,
1405,
29871,
29900,
29892,
8372,
5277,
29871,
29900,
1402,
2106,
29889,
14834,
29897,
13,
13,
1678,
620,
353,
269,
29941,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
29897,
13,
13,
1678,
364,
29896,
353,
269,
29941,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
690,
29892,
29871,
29906,
29892,
4805,
29918,
13646,
29879,
7607,
17728,
1405,
29871,
29900,
29892,
876,
13,
1678,
4974,
7431,
29898,
29878,
29896,
29897,
1275,
29871,
29896,
322,
364,
29896,
29961,
29900,
29962,
1275,
29871,
29900,
29916,
29900,
29896,
29900,
29945,
29900,
29941,
29900,
29946,
13,
13,
1678,
364,
29906,
353,
269,
29941,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
690,
29892,
29871,
29906,
29892,
4805,
29918,
13646,
29879,
7607,
17728,
5277,
29871,
29900,
29892,
876,
13,
1678,
4974,
7431,
29898,
29878,
29906,
29897,
1275,
29871,
29896,
322,
364,
29906,
29961,
29900,
29962,
1275,
29871,
29900,
29916,
29900,
29896,
29900,
29953,
29900,
29941,
29900,
29946,
13,
13,
1753,
1243,
29918,
535,
9084,
29918,
14634,
29918,
2541,
29918,
16122,
29898,
3859,
1125,
13,
13,
1678,
659,
353,
29871,
29900,
29916,
29900,
29896,
29900,
29906,
29900,
29941,
29900,
29946,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29900,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
791,
29892,
29871,
29941,
29906,
876,
13,
13,
1678,
269,
29896,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29906,
353,
2106,
29889,
8552,
580,
13,
13,
1678,
269,
29896,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29900,
29945,
29892,
29871,
29947,
876,
13,
13,
1678,
2148,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
1116,
742,
29871,
29941,
29906,
29897,
13,
1678,
269,
29906,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29900,
29953,
29892,
29871,
29947,
511,
4195,
29922,
1116,
2804,
29871,
29900,
29897,
13,
13,
1678,
269,
29941,
353,
269,
29896,
29889,
8552,
580,
13,
1678,
8372,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
17728,
742,
29871,
29941,
29906,
29897,
13,
1678,
269,
29941,
29889,
14834,
29889,
14634,
4197,
29879,
29906,
29889,
14834,
1402,
518,
17728,
1405,
29871,
29896,
29892,
8372,
5277,
29871,
29896,
1402,
269,
29896,
29889,
14834,
29897,
13,
13,
1678,
620,
353,
269,
29941,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
29897,
13,
13,
1678,
364,
29896,
353,
269,
29941,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
690,
29892,
29871,
29906,
29892,
4805,
29918,
13646,
29879,
7607,
17728,
1405,
29871,
29896,
29892,
876,
13,
1678,
4974,
7431,
29898,
29878,
29896,
29897,
1275,
29871,
29896,
322,
364,
29896,
29961,
29900,
29962,
1275,
29871,
29900,
29916,
29900,
29896,
29900,
29945,
29900,
29941,
29900,
29946,
13,
13,
1678,
364,
29906,
353,
269,
29941,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
690,
29892,
29871,
29941,
29892,
4805,
29918,
13646,
29879,
7607,
17728,
5277,
29871,
29896,
29892,
876,
13,
1678,
4974,
7431,
29898,
29878,
29906,
29897,
1275,
29871,
29906,
322,
731,
29898,
29878,
29906,
29897,
1275,
731,
4197,
29900,
29916,
29900,
29896,
29900,
29906,
29900,
29941,
29900,
29946,
29892,
29871,
29900,
29916,
29900,
29896,
29900,
29953,
29900,
29941,
29900,
29946,
2314,
13,
13,
1678,
269,
29946,
353,
269,
29941,
29889,
8552,
580,
13,
1678,
269,
29946,
29889,
344,
29889,
1202,
29898,
17728,
1275,
29871,
29896,
29897,
13,
1678,
269,
29946,
29889,
344,
29889,
1202,
29898,
1116,
2804,
29871,
29900,
29897,
13,
1678,
620,
353,
269,
29946,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29946,
29897,
13,
1678,
364,
29941,
353,
269,
29946,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
690,
29892,
29871,
29906,
29897,
13,
1678,
4974,
7431,
29898,
29878,
29941,
29897,
1275,
29871,
29896,
322,
364,
29941,
29961,
29900,
29962,
1275,
29871,
29900,
29916,
29900,
29896,
29900,
29953,
29900,
29941,
29900,
29946,
13,
13,
1753,
1243,
29918,
18098,
293,
29918,
14634,
29898,
3859,
1125,
13,
13,
1678,
659,
353,
29871,
29900,
29916,
29900,
29896,
29900,
29906,
29900,
29941,
29900,
29946,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29900,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
791,
29892,
29871,
29941,
29906,
876,
13,
13,
1678,
263,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
29874,
29900,
742,
29871,
29953,
29946,
29897,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
29874,
5277,
29871,
29896,
29897,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
29874,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29945,
29892,
29871,
29947,
876,
13,
13,
1678,
620,
353,
2106,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29896,
29897,
13,
1678,
1423,
29898,
3859,
29892,
620,
29892,
518,
29945,
29892,
29871,
29896,
2314,
13,
13,
1678,
269,
29896,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29896,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29953,
29892,
29871,
29947,
876,
13,
1678,
263,
29896,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
29874,
29896,
742,
29871,
29953,
29946,
29897,
13,
1678,
269,
29896,
29889,
344,
29889,
1202,
29898,
29874,
29896,
6736,
29871,
29896,
29897,
13,
1678,
269,
29896,
29889,
344,
29889,
1202,
29898,
29874,
29896,
5277,
29871,
29906,
29897,
13,
1678,
269,
29896,
29889,
14834,
29889,
8899,
29898,
29874,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29955,
29892,
29871,
29947,
876,
13,
13,
1678,
269,
29906,
353,
2106,
29889,
8552,
580,
13,
1678,
269,
29906,
29889,
14834,
29889,
8899,
29898,
29900,
29916,
29896,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29947,
29892,
29871,
29947,
876,
13,
1678,
263,
29906,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
29874,
29906,
742,
29871,
29953,
29946,
29897,
13,
1678,
269,
29906,
29889,
344,
29889,
1202,
29898,
29874,
29906,
6736,
29871,
29896,
29897,
13,
1678,
269,
29906,
29889,
344,
29889,
1202,
29898,
29874,
29906,
5277,
29871,
29906,
29897,
13,
1678,
269,
29906,
29889,
14834,
29889,
8899,
29898,
29874,
29906,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29929,
29892,
29871,
29947,
876,
13,
13,
1678,
269,
29941,
353,
269,
29896,
29889,
8552,
580,
13,
1678,
8372,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
17728,
742,
29871,
29941,
29906,
29897,
13,
1678,
269,
29941,
29889,
14834,
29889,
14634,
4197,
29879,
29906,
29889,
14834,
1402,
518,
17728,
1405,
29871,
29896,
29892,
8372,
5277,
29871,
29896,
1402,
269,
29896,
29889,
14834,
29897,
13,
13,
1678,
620,
353,
269,
29941,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29900,
29892,
29871,
29896,
29897,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29945,
1402,
313,
29874,
1275,
29871,
29900,
29892,
876,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29896,
1402,
313,
29874,
1275,
29871,
29896,
29892,
876,
13,
13,
1678,
620,
353,
269,
29941,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29896,
29892,
29871,
29896,
29897,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29955,
1402,
313,
17728,
1405,
29871,
29896,
29892,
263,
29896,
1275,
29871,
29896,
29892,
29871,
876,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29953,
1402,
313,
17728,
1405,
29871,
29896,
29892,
263,
29896,
1275,
29871,
29906,
29892,
876,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29929,
1402,
313,
17728,
5277,
29871,
29896,
29892,
263,
29906,
1275,
29871,
29896,
29892,
876,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29947,
1402,
313,
17728,
5277,
29871,
29896,
29892,
263,
29906,
1275,
29871,
29906,
29892,
876,
13,
13,
1678,
620,
353,
269,
29941,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29906,
29892,
29871,
29896,
29897,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29955,
1402,
313,
17728,
1405,
29871,
29896,
29892,
263,
29896,
1275,
29871,
29906,
29892,
876,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29941,
1402,
313,
17728,
1405,
29871,
29896,
29892,
263,
29896,
1275,
29871,
29896,
29892,
876,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29929,
1402,
313,
17728,
5277,
29871,
29896,
29892,
263,
29906,
1275,
29871,
29906,
29892,
876,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29941,
1402,
313,
17728,
5277,
29871,
29896,
29892,
263,
29906,
1275,
29871,
29896,
29892,
876,
13,
13,
1678,
620,
353,
269,
29941,
29889,
14834,
29889,
1359,
29898,
29900,
29916,
29941,
29892,
29871,
29896,
29897,
13,
1678,
1423,
29898,
29879,
29941,
29892,
620,
29892,
518,
29946,
1402,
731,
3101,
13,
13,
1753,
1243,
29918,
18098,
293,
29918,
5943,
29898,
3859,
1125,
13,
13,
1678,
396,
385,
3211,
607,
338,
297,
263,
2854,
5120,
13,
1678,
1369,
29918,
10030,
353,
2106,
29889,
354,
481,
29889,
15956,
403,
29898,
29941,
29906,
29897,
13,
13,
1678,
396,
9294,
2106,
29889,
344,
29889,
1384,
29918,
524,
29898,
3859,
29889,
14834,
29889,
17858,
6847,
29898,
2962,
29918,
10030,
876,
1275,
29871,
29900,
29916,
29941,
13,
1678,
396,
9294,
2106,
29889,
344,
29889,
1384,
29918,
524,
29898,
3859,
29889,
14834,
29889,
17858,
6847,
29898,
2962,
29918,
10030,
718,
29871,
29896,
876,
1275,
29871,
29900,
29916,
29941,
13,
1678,
396,
9294,
2106,
29889,
344,
29889,
1384,
29918,
524,
29898,
3859,
29889,
14834,
29889,
17858,
6847,
29898,
2962,
29918,
10030,
718,
29871,
29906,
876,
1275,
29871,
29900,
29916,
29941,
13,
13,
1678,
396,
2069,
3370,
29871,
29941,
6262,
6257,
472,
1369,
29918,
10030,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
2962,
29918,
10030,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29900,
29892,
29871,
29906,
29946,
511,
29871,
29941,
29897,
13,
13,
1678,
396,
263,
5829,
293,
4879,
393,
508,
367,
5186,
304,
518,
2962,
29918,
10030,
29892,
1369,
29918,
10030,
718,
29871,
29896,
29962,
13,
1678,
28915,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
10030,
742,
29871,
29953,
29946,
29897,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
10030,
6736,
1369,
29918,
10030,
29897,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
10030,
5277,
1369,
29918,
10030,
718,
29871,
29896,
29897,
13,
1678,
788,
2288,
353,
2106,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
10030,
29892,
29871,
29896,
29900,
29897,
13,
1678,
4974,
7431,
29898,
1202,
2288,
29897,
1275,
29871,
29906,
322,
731,
29898,
1202,
2288,
29897,
1275,
731,
4197,
2962,
29918,
10030,
29892,
1369,
29918,
10030,
718,
29871,
29896,
2314,
13,
13,
1678,
659,
353,
29871,
29900,
29916,
2882,
6530,
13,
13,
1678,
396,
5829,
293,
3787,
472,
28915,
13,
1678,
2106,
29889,
14834,
29889,
8899,
29898,
10030,
29892,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
791,
29892,
29871,
29896,
29953,
511,
29871,
29906,
29897,
13,
13,
1678,
396,
5829,
293,
2254,
472,
28915,
13,
1678,
620,
353,
2106,
29889,
14834,
29889,
1359,
29898,
10030,
29892,
29871,
29906,
29897,
13,
1678,
620,
353,
2106,
29889,
344,
29889,
14513,
29918,
21245,
29877,
29898,
690,
29892,
29871,
29906,
29900,
29897,
13,
1678,
4974,
7431,
29898,
690,
29897,
1275,
29871,
29896,
322,
620,
29961,
29900,
29962,
1275,
659,
13,
13,
13,
1753,
1243,
29918,
17642,
29918,
6891,
29898,
3859,
1125,
13,
13,
1678,
263,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
29874,
742,
29871,
29947,
29897,
13,
1678,
289,
353,
7542,
666,
29891,
29889,
29933,
21819,
877,
29890,
742,
29871,
29947,
29897,
13,
13,
1678,
4974,
451,
2106,
29889,
14834,
29889,
17642,
29898,
29874,
29892,
289,
29897,
13,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
29874,
1275,
289,
29897,
13,
13,
1678,
4974,
2106,
29889,
14834,
29889,
17642,
29898,
29874,
29892,
289,
29897,
13,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
29874,
529,
29871,
29945,
29897,
13,
13,
1678,
4974,
2106,
29889,
14834,
29889,
17642,
29898,
29874,
29892,
289,
29897,
13,
13,
1678,
5225,
353,
7542,
666,
29891,
29889,
29933,
29963,
29963,
29898,
29900,
29916,
29900,
29892,
29871,
29947,
29897,
13,
1678,
4974,
451,
2106,
29889,
14834,
29889,
17642,
29898,
29874,
29892,
5225,
29897,
13,
13,
1678,
2106,
29889,
344,
29889,
1202,
29898,
29874,
529,
29871,
29896,
29897,
13,
13,
1678,
4974,
2106,
29889,
14834,
29889,
17642,
29898,
29874,
29892,
5225,
29897,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
13,
1678,
260,
353,
29871,
29900,
13,
1678,
385,
629,
29918,
4836,
353,
385,
629,
29889,
7653,
11974,
2109,
29914,
3137,
613,
2254,
29918,
6768,
3790,
29915,
6921,
29918,
1359,
29918,
10254,
2396,
7700,
1800,
13,
13,
1678,
565,
260,
1275,
29871,
29900,
29901,
13,
4706,
2626,
29918,
14834,
29892,
1072,
29918,
14834,
353,
6213,
29892,
6213,
13,
1678,
25342,
260,
1275,
29871,
29896,
29901,
13,
4706,
2626,
29918,
14834,
29892,
1072,
29918,
14834,
353,
12529,
29889,
657,
29918,
3881,
29918,
3730,
29918,
18098,
293,
29918,
14834,
29898,
574,
29878,
29918,
4836,
29897,
13,
4706,
396,
6954,
29918,
14834,
29889,
842,
29918,
369,
15828,
29898,
5574,
29897,
13,
13,
1678,
18224,
353,
6571,
13,
1678,
565,
2626,
29918,
14834,
338,
451,
6213,
29901,
13,
4706,
18224,
1839,
14834,
2033,
353,
2626,
29918,
14834,
13,
1678,
565,
1072,
29918,
14834,
338,
451,
6213,
29901,
13,
4706,
18224,
1839,
9573,
29879,
2033,
353,
1072,
29918,
14834,
13,
13,
1678,
788,
29918,
6768,
353,
426,
8516,
29913,
13,
1678,
396,
1202,
29918,
6768,
353,
426,
3601,
29884,
13809,
29889,
29877,
29889,
1254,
3960,
1783,
29918,
7228,
1692,
29918,
2477,
23524,
29913,
13,
1678,
396,
788,
29918,
6768,
353,
426,
3601,
29884,
13809,
29889,
29877,
29889,
29907,
8766,
29918,
29999,
1001,
29949,
29918,
3738,
2208,
29918,
3904,
6007,
1254,
4717,
1177,
3352,
29918,
2303,
29924,
18929,
29913,
13,
13,
1678,
2106,
353,
385,
629,
29918,
4836,
29889,
14399,
29889,
8269,
29918,
3859,
29898,
5992,
29918,
6768,
3790,
574,
29878,
29889,
6768,
29889,
4375,
29999,
29979,
29918,
29903,
5607,
29963,
2890,
1118,
13,
462,
462,
632,
788,
29918,
6768,
29922,
1202,
29918,
6768,
29892,
18224,
29922,
12800,
29897,
13,
13,
1678,
565,
260,
1275,
29871,
29900,
29901,
13,
4706,
396,
3787,
29901,
788,
716,
378,
4838,
2133,
13705,
13,
4706,
2106,
29889,
14834,
29889,
3539,
29918,
710,
1845,
583,
29889,
7851,
29898,
29900,
29892,
385,
629,
29889,
535,
4838,
2133,
29918,
710,
1845,
583,
29889,
8942,
1168,
4838,
2133,
26910,
6069,
29898,
29906,
29900,
29946,
29947,
876,
13,
4706,
2106,
29889,
14834,
29889,
949,
29918,
710,
1845,
583,
29889,
7851,
29898,
29900,
29892,
385,
629,
29889,
535,
4838,
2133,
29918,
710,
1845,
583,
29889,
8942,
1168,
4838,
2133,
26910,
6069,
29898,
29906,
29900,
29946,
29947,
876,
13,
4706,
1209,
13,
13,
1678,
1243,
29918,
18098,
293,
29918,
5943,
29898,
3859,
29889,
8552,
3101,
13,
13,
1678,
1243,
29918,
8899,
29918,
2541,
29918,
18098,
293,
29918,
2311,
29898,
3859,
29889,
8552,
3101,
13,
1678,
1243,
29918,
8899,
29918,
2541,
29918,
18098,
293,
29918,
10030,
29918,
392,
29918,
18098,
293,
29918,
2311,
29898,
3859,
29889,
8552,
3101,
13,
13,
1678,
1243,
29918,
535,
9084,
29918,
14634,
29898,
3859,
29889,
8552,
3101,
13,
1678,
1243,
29918,
535,
9084,
29918,
14634,
29918,
2541,
29918,
16122,
29898,
3859,
29889,
8552,
3101,
13,
13,
1678,
1243,
29918,
18098,
293,
29918,
14634,
29898,
3859,
29889,
8552,
3101,
13,
13,
1678,
565,
260,
1275,
29871,
29896,
29901,
13,
4706,
1243,
29918,
17642,
29918,
6891,
29898,
3859,
29889,
8552,
3101,
13,
2
] |
config/looper.py | panoramichq/data-collection-fb | 0 | 129464 | <gh_stars>0
# flake8: noqa: E722
RUN_SWEEP_TIMEOUT = 60 * 60 # seconds
RUN_TASKS_TIMEOUT = 30 * 60 # 30 minutes.
FB_THROTTLING_WINDOW = 20 * 60 # 20 minutes.
OOZER_ENABLE_LEARNING = True
OOZER_LEARNING_RATE = 0.05
OOZER_REVIEW_INTERVAL = 10
OOZER_START_RATE = 100.0
OOZER_MIN_RATE = 10.0
# Hour, DMA, AgeGender * about 2 years back + 3 levels of lifetime + 3 levels of Entities
_number_of_long_tasks_per_aa = 3 * 600 + 3 + 3
# there is also a way to get to this real number by scanning FacebookAdAccount table,
# but, we'd like to dream.
# This does not really limit anything, just defines some optimistic upper range for
# "normal" when it comes estimating "total possible" number of tasks to run per sweep.
MAX_EXPECTED_AD_ACCOUNTS = 500 # yeah, optimistic
# Real number of tasks can be much greater, as we are not counting
# per-entity report type permutations. There there can be millions per single AdAccount
# for that reason:
_looney_balooney_multiplier = 10 # yeah, this is NOT millions, but something, right
# When we relax prioritizer logic to schedule per-entity tasks along with per-parent
# tasks, you need to crank this ^ up quite a bit, to 10,000 at least.
# Used to define "max normal" estimatable tasks when it comes to Early Exit logic in looper
SANE_MAX_TASKS = _number_of_long_tasks_per_aa * MAX_EXPECTED_AD_ACCOUNTS * _looney_balooney_multiplier
from common.updatefromenv import update_from_env
update_from_env(__name__)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
17422,
446,
29947,
29901,
694,
25621,
29901,
382,
29955,
29906,
29906,
13,
13,
29934,
3904,
29918,
29903,
8851,
15488,
29918,
15307,
12015,
353,
29871,
29953,
29900,
334,
29871,
29953,
29900,
29871,
396,
6923,
13,
29934,
3904,
29918,
29911,
3289,
17557,
29918,
15307,
12015,
353,
29871,
29941,
29900,
334,
29871,
29953,
29900,
29871,
396,
29871,
29941,
29900,
6233,
29889,
13,
13,
18426,
29918,
4690,
1672,
29911,
14632,
4214,
29918,
25152,
3970,
29956,
353,
29871,
29906,
29900,
334,
29871,
29953,
29900,
29871,
396,
29871,
29906,
29900,
6233,
29889,
13,
13,
29949,
29949,
29999,
1001,
29918,
1430,
6181,
29918,
1307,
25614,
353,
5852,
13,
29949,
29949,
29999,
1001,
29918,
1307,
25614,
29918,
29934,
3040,
353,
29871,
29900,
29889,
29900,
29945,
13,
29949,
29949,
29999,
1001,
29918,
1525,
29963,
8673,
29956,
29918,
23845,
8932,
353,
29871,
29896,
29900,
13,
29949,
29949,
29999,
1001,
29918,
25826,
29918,
29934,
3040,
353,
29871,
29896,
29900,
29900,
29889,
29900,
13,
29949,
29949,
29999,
1001,
29918,
16173,
29918,
29934,
3040,
353,
29871,
29896,
29900,
29889,
29900,
13,
13,
29937,
379,
473,
29892,
360,
1529,
29892,
16767,
29954,
1581,
334,
1048,
29871,
29906,
2440,
1250,
718,
29871,
29941,
11174,
310,
25423,
718,
29871,
29941,
11174,
310,
4284,
1907,
13,
29918,
4537,
29918,
974,
29918,
5426,
29918,
20673,
29918,
546,
29918,
7340,
353,
29871,
29941,
334,
29871,
29953,
29900,
29900,
718,
29871,
29941,
718,
29871,
29941,
13,
13,
29937,
727,
338,
884,
263,
982,
304,
679,
304,
445,
1855,
1353,
491,
885,
9450,
13327,
3253,
10601,
1591,
29892,
13,
29937,
541,
29892,
591,
29915,
29881,
763,
304,
12561,
29889,
13,
29937,
910,
947,
451,
2289,
4046,
3099,
29892,
925,
17645,
777,
5994,
4695,
7568,
3464,
363,
13,
29937,
376,
8945,
29908,
746,
372,
5304,
4844,
1218,
376,
7827,
1950,
29908,
1353,
310,
9595,
304,
1065,
639,
7901,
1022,
29889,
13,
12648,
29918,
5746,
4162,
1783,
3352,
29918,
3035,
29918,
2477,
3217,
3904,
9375,
353,
29871,
29945,
29900,
29900,
29871,
396,
21915,
29892,
5994,
4695,
13,
13,
29937,
8195,
1353,
310,
9595,
508,
367,
1568,
7621,
29892,
408,
591,
526,
451,
21248,
13,
29937,
639,
29899,
10041,
3461,
1134,
20005,
800,
29889,
1670,
727,
508,
367,
14746,
639,
2323,
2087,
10601,
13,
29937,
363,
393,
2769,
29901,
13,
29918,
417,
4992,
29918,
5521,
29877,
4992,
29918,
18056,
4926,
353,
29871,
29896,
29900,
29871,
396,
21915,
29892,
445,
338,
6058,
14746,
29892,
541,
1554,
29892,
1492,
13,
29937,
1932,
591,
26681,
7536,
277,
3950,
5900,
304,
20410,
639,
29899,
10041,
9595,
3412,
411,
639,
29899,
3560,
13,
29937,
9595,
29892,
366,
817,
304,
274,
10003,
445,
6228,
701,
3755,
263,
2586,
29892,
304,
29871,
29896,
29900,
29892,
29900,
29900,
29900,
472,
3203,
29889,
13,
13,
29937,
501,
8485,
304,
4529,
376,
3317,
4226,
29908,
4844,
17219,
9595,
746,
372,
5304,
304,
11095,
25954,
5900,
297,
2425,
261,
13,
29903,
2190,
29923,
29918,
12648,
29918,
29911,
3289,
17557,
353,
903,
4537,
29918,
974,
29918,
5426,
29918,
20673,
29918,
546,
29918,
7340,
334,
18134,
29918,
5746,
4162,
1783,
3352,
29918,
3035,
29918,
2477,
3217,
3904,
9375,
334,
903,
417,
4992,
29918,
5521,
29877,
4992,
29918,
18056,
4926,
13,
13,
3166,
3619,
29889,
5504,
3166,
6272,
1053,
2767,
29918,
3166,
29918,
6272,
13,
13,
5504,
29918,
3166,
29918,
6272,
22168,
978,
1649,
29897,
13,
2
] |
spira/gdsii/cell.py | cloudcalvin/spira | 0 | 153881 | <filename>spira/gdsii/cell.py
import gdspy
import numpy as np
from copy import copy, deepcopy
from spira import param
from spira.core.lists import ElementList
from spira.lne import *
from spira.gdsii import *
from spira.core.initializer import CellInitializer
from spira.core.mixin.property import CellMixin
from spira.core.mixin.gdsii_output import OutputMixin
from spira.gdsii.elemental.port import __Port__
from spira.core.mixin.transform import TranformationMixin
class __Cell__(gdspy.Cell, CellInitializer):
__mixins__ = [OutputMixin, CellMixin, TranformationMixin]
def __init__(self, name=None, elementals=None, ports=None, library=None, **kwargs):
CellInitializer.__init__(self, **kwargs)
gdspy.Cell.__init__(self, name, exclude_from_current=True)
if name is not None:
self.__dict__['__name__'] = name
Cell.name.__set__(self, name)
if library is not None:
self.library = library
if elementals is not None:
self.elementals = elementals
if ports is not None:
self.ports = ports
# self.move(midpoint=self.center, destination=(0,0))
# self.center = (0,0)
def __add__(self, other):
if other is None:
return self
if issubclass(type(other), __Port__):
self.ports += other
else:
self.elementals += other
return self
# if issubclass(type(other), Cell):
# print(other)
# self.elementals += SRef(other)
# # for e in other.elementals:
# # self.elementals += e
# # for p in other.ports:
# # self.ports += p
def __sub__(self, other):
pass
class CellAbstract(__Cell__):
name = param.StringField()
ports = param.ElementListField(fdef_name='create_ports')
elementals = param.ElementListField(fdef_name='create_elementals')
def create_elementals(self, elems):
result = ElementList()
return result
def create_ports(self, ports):
return ports
def flatten(self):
self.elementals = self.elementals.flatten()
return self.elementals
def flat_copy(self, level=-1, commit_to_gdspy=False):
self.elementals = self.elementals.flat_copy(level, commit_to_gdspy)
return self.elementals
def dependencies(self):
deps = self.elementals.dependencies()
deps += self
return deps
def commit_to_gdspy(self):
cell = gdspy.Cell(self.name, exclude_from_current=True)
for e in self.elementals:
if issubclass(type(e), Cell):
for elem in e.elementals:
elem.commit_to_gdspy(cell=cell)
for port in e.ports:
port.commit_to_gdspy(cell=cell)
elif not isinstance(e, (SRef, ElementList, Graph, Mesh)):
e.commit_to_gdspy(cell=cell)
return cell
def move(self, midpoint=(0,0), destination=None, axis=None):
"""
Moves elements of the Device from the midpoint point to
the destination. Both midpoint and destination can be 1x2
array-like, Port, or a key corresponding to
one of the Ports in this device
"""
if destination is None:
destination = midpoint
midpoint = [0,0]
if issubclass(type(midpoint), __Port__):
o = midpoint.midpoint
elif np.array(midpoint).size == 2:
o = midpoint
elif midpoint in self.ports:
o = self.ports[midpoint].midpoint
else:
raise ValueError('[DeviceReference.move()] ``midpoint`` ' + \
'not array-like, a port, or port name')
if issubclass(type(destination), __Port__):
d = destination.midpoint
elif np.array(destination).size == 2:
d = destination
elif destination in self.ports:
d = self.ports[destination].midpoint
else:
raise ValueError('[DeviceReference.move()] ``destination`` ' + \
'not array-like, a port, or port name')
if axis == 'x':
d = (d[0], o[1])
if axis == 'y':
d = (o[0], d[1])
dx, dy = np.array(d) - o
for e in self.elementals:
if issubclass(type(e), (LabelAbstract, PolygonAbstract)):
e.translate(dx, dy)
if isinstance(e, (Cell, SRef)):
e.move(destination=d, midpoint=o)
for p in self.ports:
mc = np.array(p.midpoint) + np.array(d) - np.array(o)
p.move(midpoint=p.midpoint, destination=mc)
return self
def reflect(self, p1=(0,1), p2=(0,0)):
""" Reflects the cell around the line [p1, p2]. """
for e in self.elementals:
if not issubclass(type(e), (LabelAbstract, __Port__)):
e.reflect(p1, p2)
for p in self.ports:
p.midpoint = self.__reflect__(p.midpoint, p1, p2)
phi = np.arctan2(p2[1]-p1[1], p2[0]-p1[0])*180 / np.pi
p.orientation = 2*phi - p.orientation
return self
def rotate(self, angle=45, center=(0,0)):
""" Rotates the cell with angle around a center. """
if angle == 0:
return self
for e in self.elementals:
if issubclass(type(e), PolygonAbstract):
e.rotate(angle=angle, center=center)
elif isinstance(e, SRef):
e.rotate(angle, center)
ports = self.ports
self.ports = ElementList()
for p in ports:
if issubclass(type(p), __Port__):
p.midpoint = self.__rotate__(p.midpoint, angle, center)
p.orientation = np.mod(p.orientation + angle, 360)
self.ports += p
return self
def get_ports(self, level=None):
""" Returns copies of all the ports of the Device """
port_list = [p._copy() for p in self.ports]
if level is None or level > 0:
for r in self.elementals.sref:
if level is None:
new_level = None
else:
new_level = level - 1
ref_ports = r.ref.get_ports(level=new_level)
tf = {
'midpoint': r.midpoint,
'rotation': r.rotation,
'magnification': r.magnification,
'reflection': r.reflection
}
ref_ports_transformed = []
for rp in ref_ports:
new_port = rp._copy()
new_port = new_port.transform(tf)
ref_ports_transformed.append(new_port)
port_list += ref_ports_transformed
return port_list
class Cell(CellAbstract):
""" A Cell encapsulates a set of elementals that
describes the layout being generated. """
def __repr__(self):
if hasattr(self, 'elementals'):
elems = self.elementals
return ("[SPiRA: Cell(\'{}\')] " +
"({} elementals: {} sref, {} polygons, " +
"{} labels, {} ports)").format(
self.name,
elems.__len__(),
elems.sref.__len__(),
elems.polygons.__len__(),
elems.labels.__len__(),
self.ports.__len__()
)
else:
return "[SPiRA: Cell(\'{}\')]".format(self.__class__.__name__)
def __str__(self):
return self.__repr__()
@property
def id(self):
return self.__str__()
| [
1,
529,
9507,
29958,
1028,
3055,
29914,
29887,
29881,
1039,
29875,
29914,
3729,
29889,
2272,
13,
5215,
330,
29881,
1028,
29891,
13,
5215,
12655,
408,
7442,
13,
3166,
3509,
1053,
3509,
29892,
6483,
8552,
13,
13,
3166,
805,
3055,
1053,
1828,
13,
13,
3166,
805,
3055,
29889,
3221,
29889,
21513,
1053,
10619,
1293,
13,
3166,
805,
3055,
29889,
29880,
484,
1053,
334,
13,
3166,
805,
3055,
29889,
29887,
29881,
1039,
29875,
1053,
334,
13,
13,
3166,
805,
3055,
29889,
3221,
29889,
11228,
3950,
1053,
19413,
15514,
3950,
13,
3166,
805,
3055,
29889,
3221,
29889,
28084,
262,
29889,
6799,
1053,
19413,
29924,
861,
262,
13,
3166,
805,
3055,
29889,
3221,
29889,
28084,
262,
29889,
29887,
29881,
1039,
29875,
29918,
4905,
1053,
10604,
29924,
861,
262,
13,
3166,
805,
3055,
29889,
29887,
29881,
1039,
29875,
29889,
5029,
284,
29889,
637,
1053,
4770,
2290,
1649,
13,
3166,
805,
3055,
29889,
3221,
29889,
28084,
262,
29889,
9067,
1053,
323,
661,
5404,
29924,
861,
262,
13,
13,
13,
1990,
4770,
4617,
12035,
29887,
29881,
1028,
29891,
29889,
4617,
29892,
19413,
15514,
3950,
1125,
13,
13,
1678,
4770,
28084,
1144,
1649,
353,
518,
6466,
29924,
861,
262,
29892,
19413,
29924,
861,
262,
29892,
323,
661,
5404,
29924,
861,
262,
29962,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1024,
29922,
8516,
29892,
1543,
1338,
29922,
8516,
29892,
16169,
29922,
8516,
29892,
3489,
29922,
8516,
29892,
3579,
19290,
1125,
13,
4706,
19413,
15514,
3950,
17255,
2344,
12035,
1311,
29892,
3579,
19290,
29897,
13,
4706,
330,
29881,
1028,
29891,
29889,
4617,
17255,
2344,
12035,
1311,
29892,
1024,
29892,
19060,
29918,
3166,
29918,
3784,
29922,
5574,
29897,
13,
13,
4706,
565,
1024,
338,
451,
6213,
29901,
13,
9651,
1583,
17255,
8977,
1649,
1839,
1649,
978,
1649,
2033,
353,
1024,
13,
9651,
19413,
29889,
978,
17255,
842,
12035,
1311,
29892,
1024,
29897,
13,
4706,
565,
3489,
338,
451,
6213,
29901,
13,
9651,
1583,
29889,
5258,
353,
3489,
13,
4706,
565,
1543,
1338,
338,
451,
6213,
29901,
13,
9651,
1583,
29889,
5029,
1338,
353,
1543,
1338,
13,
4706,
565,
16169,
338,
451,
6213,
29901,
13,
9651,
1583,
29889,
4011,
353,
16169,
13,
13,
4706,
396,
1583,
29889,
11631,
29898,
6563,
3149,
29922,
1311,
29889,
5064,
29892,
12551,
7607,
29900,
29892,
29900,
876,
13,
4706,
396,
1583,
29889,
5064,
353,
313,
29900,
29892,
29900,
29897,
13,
13,
1678,
822,
4770,
1202,
12035,
1311,
29892,
916,
1125,
13,
4706,
565,
916,
338,
6213,
29901,
13,
9651,
736,
1583,
13,
4706,
565,
338,
1491,
1990,
29898,
1853,
29898,
1228,
511,
4770,
2290,
1649,
1125,
13,
9651,
1583,
29889,
4011,
4619,
916,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
5029,
1338,
4619,
916,
13,
4706,
736,
1583,
13,
13,
4706,
396,
565,
338,
1491,
1990,
29898,
1853,
29898,
1228,
511,
19413,
1125,
13,
4706,
396,
268,
1596,
29898,
1228,
29897,
13,
4706,
396,
268,
1583,
29889,
5029,
1338,
4619,
317,
5620,
29898,
1228,
29897,
13,
4706,
396,
268,
396,
363,
321,
297,
916,
29889,
5029,
1338,
29901,
13,
4706,
396,
268,
396,
268,
1583,
29889,
5029,
1338,
4619,
321,
13,
4706,
396,
268,
396,
363,
282,
297,
916,
29889,
4011,
29901,
13,
4706,
396,
268,
396,
268,
1583,
29889,
4011,
4619,
282,
13,
13,
1678,
822,
4770,
1491,
12035,
1311,
29892,
916,
1125,
13,
4706,
1209,
13,
13,
13,
1990,
19413,
9118,
22168,
4617,
1649,
1125,
13,
13,
1678,
1024,
353,
1828,
29889,
1231,
3073,
580,
13,
1678,
16169,
353,
1828,
29889,
2642,
1293,
3073,
29898,
29888,
1753,
29918,
978,
2433,
3258,
29918,
4011,
1495,
13,
1678,
1543,
1338,
353,
1828,
29889,
2642,
1293,
3073,
29898,
29888,
1753,
29918,
978,
2433,
3258,
29918,
5029,
1338,
1495,
13,
13,
1678,
822,
1653,
29918,
5029,
1338,
29898,
1311,
29892,
4552,
1516,
1125,
13,
4706,
1121,
353,
10619,
1293,
580,
13,
4706,
736,
1121,
13,
13,
1678,
822,
1653,
29918,
4011,
29898,
1311,
29892,
16169,
1125,
13,
4706,
736,
16169,
13,
13,
1678,
822,
1652,
8606,
29898,
1311,
1125,
13,
4706,
1583,
29889,
5029,
1338,
353,
1583,
29889,
5029,
1338,
29889,
1579,
8606,
580,
13,
4706,
736,
1583,
29889,
5029,
1338,
13,
13,
1678,
822,
12151,
29918,
8552,
29898,
1311,
29892,
3233,
10457,
29896,
29892,
9063,
29918,
517,
29918,
29887,
29881,
1028,
29891,
29922,
8824,
1125,
13,
4706,
1583,
29889,
5029,
1338,
353,
1583,
29889,
5029,
1338,
29889,
20620,
29918,
8552,
29898,
5563,
29892,
9063,
29918,
517,
29918,
29887,
29881,
1028,
29891,
29897,
13,
4706,
736,
1583,
29889,
5029,
1338,
13,
13,
1678,
822,
9962,
29898,
1311,
1125,
13,
4706,
316,
567,
353,
1583,
29889,
5029,
1338,
29889,
22594,
580,
13,
4706,
316,
567,
4619,
1583,
13,
4706,
736,
316,
567,
13,
13,
1678,
822,
9063,
29918,
517,
29918,
29887,
29881,
1028,
29891,
29898,
1311,
1125,
13,
4706,
3038,
353,
330,
29881,
1028,
29891,
29889,
4617,
29898,
1311,
29889,
978,
29892,
19060,
29918,
3166,
29918,
3784,
29922,
5574,
29897,
13,
4706,
363,
321,
297,
1583,
29889,
5029,
1338,
29901,
13,
9651,
565,
338,
1491,
1990,
29898,
1853,
29898,
29872,
511,
19413,
1125,
13,
18884,
363,
21268,
297,
321,
29889,
5029,
1338,
29901,
13,
462,
1678,
21268,
29889,
15060,
29918,
517,
29918,
29887,
29881,
1028,
29891,
29898,
3729,
29922,
3729,
29897,
13,
18884,
363,
2011,
297,
321,
29889,
4011,
29901,
13,
462,
1678,
2011,
29889,
15060,
29918,
517,
29918,
29887,
29881,
1028,
29891,
29898,
3729,
29922,
3729,
29897,
13,
9651,
25342,
451,
338,
8758,
29898,
29872,
29892,
313,
29903,
5620,
29892,
10619,
1293,
29892,
12367,
29892,
341,
12094,
22164,
13,
18884,
321,
29889,
15060,
29918,
517,
29918,
29887,
29881,
1028,
29891,
29898,
3729,
29922,
3729,
29897,
13,
4706,
736,
3038,
13,
13,
1678,
822,
4337,
29898,
1311,
29892,
7145,
3149,
7607,
29900,
29892,
29900,
511,
12551,
29922,
8516,
29892,
9685,
29922,
8516,
1125,
13,
4706,
9995,
13,
4706,
14104,
267,
3161,
310,
278,
21830,
515,
278,
7145,
3149,
1298,
304,
13,
4706,
278,
12551,
29889,
9134,
7145,
3149,
322,
12551,
508,
367,
29871,
29896,
29916,
29906,
13,
4706,
1409,
29899,
4561,
29892,
3371,
29892,
470,
263,
1820,
6590,
304,
13,
4706,
697,
310,
278,
3371,
29879,
297,
445,
4742,
13,
4706,
9995,
13,
13,
4706,
565,
12551,
338,
6213,
29901,
13,
9651,
12551,
353,
7145,
3149,
13,
9651,
7145,
3149,
353,
518,
29900,
29892,
29900,
29962,
13,
13,
4706,
565,
338,
1491,
1990,
29898,
1853,
29898,
6563,
3149,
511,
4770,
2290,
1649,
1125,
13,
9651,
288,
353,
7145,
3149,
29889,
6563,
3149,
13,
4706,
25342,
7442,
29889,
2378,
29898,
6563,
3149,
467,
2311,
1275,
29871,
29906,
29901,
13,
9651,
288,
353,
7145,
3149,
13,
4706,
25342,
7145,
3149,
297,
1583,
29889,
4011,
29901,
13,
9651,
288,
353,
1583,
29889,
4011,
29961,
6563,
3149,
1822,
6563,
3149,
13,
4706,
1683,
29901,
13,
9651,
12020,
7865,
2392,
877,
29961,
11501,
7422,
29889,
11631,
580,
29962,
4954,
6563,
3149,
16159,
525,
718,
320,
13,
462,
632,
525,
1333,
1409,
29899,
4561,
29892,
263,
2011,
29892,
470,
2011,
1024,
1495,
13,
13,
4706,
565,
338,
1491,
1990,
29898,
1853,
29898,
23848,
511,
4770,
2290,
1649,
1125,
13,
9651,
270,
353,
12551,
29889,
6563,
3149,
13,
4706,
25342,
7442,
29889,
2378,
29898,
23848,
467,
2311,
1275,
29871,
29906,
29901,
13,
9651,
270,
353,
12551,
13,
4706,
25342,
12551,
297,
1583,
29889,
4011,
29901,
13,
9651,
270,
353,
1583,
29889,
4011,
29961,
23848,
1822,
6563,
3149,
13,
4706,
1683,
29901,
13,
9651,
12020,
7865,
2392,
877,
29961,
11501,
7422,
29889,
11631,
580,
29962,
4954,
23848,
16159,
525,
718,
320,
13,
462,
632,
525,
1333,
1409,
29899,
4561,
29892,
263,
2011,
29892,
470,
2011,
1024,
1495,
13,
13,
4706,
565,
9685,
1275,
525,
29916,
2396,
13,
9651,
270,
353,
313,
29881,
29961,
29900,
1402,
288,
29961,
29896,
2314,
13,
4706,
565,
9685,
1275,
525,
29891,
2396,
13,
9651,
270,
353,
313,
29877,
29961,
29900,
1402,
270,
29961,
29896,
2314,
13,
13,
4706,
15414,
29892,
13475,
353,
7442,
29889,
2378,
29898,
29881,
29897,
448,
288,
13,
13,
4706,
363,
321,
297,
1583,
29889,
5029,
1338,
29901,
13,
9651,
565,
338,
1491,
1990,
29898,
1853,
29898,
29872,
511,
313,
4775,
9118,
29892,
2043,
17125,
9118,
22164,
13,
18884,
321,
29889,
21652,
29898,
8235,
29892,
13475,
29897,
13,
9651,
565,
338,
8758,
29898,
29872,
29892,
313,
4617,
29892,
317,
5620,
22164,
13,
18884,
321,
29889,
11631,
29898,
23848,
29922,
29881,
29892,
7145,
3149,
29922,
29877,
29897,
13,
13,
4706,
363,
282,
297,
1583,
29889,
4011,
29901,
13,
9651,
286,
29883,
353,
7442,
29889,
2378,
29898,
29886,
29889,
6563,
3149,
29897,
718,
7442,
29889,
2378,
29898,
29881,
29897,
448,
7442,
29889,
2378,
29898,
29877,
29897,
13,
9651,
282,
29889,
11631,
29898,
6563,
3149,
29922,
29886,
29889,
6563,
3149,
29892,
12551,
29922,
14047,
29897,
13,
13,
4706,
736,
1583,
13,
13,
1678,
822,
9432,
29898,
1311,
29892,
282,
29896,
7607,
29900,
29892,
29896,
511,
282,
29906,
7607,
29900,
29892,
29900,
22164,
13,
4706,
9995,
9897,
781,
29879,
278,
3038,
2820,
278,
1196,
518,
29886,
29896,
29892,
282,
29906,
1822,
9995,
13,
4706,
363,
321,
297,
1583,
29889,
5029,
1338,
29901,
13,
9651,
565,
451,
338,
1491,
1990,
29898,
1853,
29898,
29872,
511,
313,
4775,
9118,
29892,
4770,
2290,
1649,
22164,
13,
18884,
321,
29889,
13191,
29898,
29886,
29896,
29892,
282,
29906,
29897,
13,
4706,
363,
282,
297,
1583,
29889,
4011,
29901,
13,
9651,
282,
29889,
6563,
3149,
353,
1583,
17255,
13191,
12035,
29886,
29889,
6563,
3149,
29892,
282,
29896,
29892,
282,
29906,
29897,
13,
9651,
1374,
29875,
353,
7442,
29889,
27014,
273,
29906,
29898,
29886,
29906,
29961,
29896,
29962,
29899,
29886,
29896,
29961,
29896,
1402,
282,
29906,
29961,
29900,
29962,
29899,
29886,
29896,
29961,
29900,
2314,
29930,
29896,
29947,
29900,
847,
7442,
29889,
1631,
13,
9651,
282,
29889,
20659,
353,
29871,
29906,
29930,
2876,
448,
282,
29889,
20659,
13,
4706,
736,
1583,
13,
13,
1678,
822,
16734,
29898,
1311,
29892,
10696,
29922,
29946,
29945,
29892,
4818,
7607,
29900,
29892,
29900,
22164,
13,
4706,
9995,
9664,
1078,
278,
3038,
411,
10696,
2820,
263,
4818,
29889,
9995,
13,
4706,
565,
10696,
1275,
29871,
29900,
29901,
13,
9651,
736,
1583,
13,
4706,
363,
321,
297,
1583,
29889,
5029,
1338,
29901,
13,
9651,
565,
338,
1491,
1990,
29898,
1853,
29898,
29872,
511,
2043,
17125,
9118,
1125,
13,
18884,
321,
29889,
23361,
29898,
2521,
29922,
2521,
29892,
4818,
29922,
5064,
29897,
13,
9651,
25342,
338,
8758,
29898,
29872,
29892,
317,
5620,
1125,
13,
18884,
321,
29889,
23361,
29898,
2521,
29892,
4818,
29897,
13,
4706,
16169,
353,
1583,
29889,
4011,
13,
4706,
1583,
29889,
4011,
353,
10619,
1293,
580,
13,
4706,
363,
282,
297,
16169,
29901,
13,
9651,
565,
338,
1491,
1990,
29898,
1853,
29898,
29886,
511,
4770,
2290,
1649,
1125,
13,
18884,
282,
29889,
6563,
3149,
353,
1583,
17255,
23361,
12035,
29886,
29889,
6563,
3149,
29892,
10696,
29892,
4818,
29897,
13,
18884,
282,
29889,
20659,
353,
7442,
29889,
1545,
29898,
29886,
29889,
20659,
718,
10696,
29892,
29871,
29941,
29953,
29900,
29897,
13,
18884,
1583,
29889,
4011,
4619,
282,
13,
4706,
736,
1583,
13,
13,
1678,
822,
679,
29918,
4011,
29898,
1311,
29892,
3233,
29922,
8516,
1125,
13,
4706,
9995,
16969,
14591,
310,
599,
278,
16169,
310,
278,
21830,
9995,
13,
4706,
2011,
29918,
1761,
353,
518,
29886,
3032,
8552,
580,
363,
282,
297,
1583,
29889,
4011,
29962,
13,
4706,
565,
3233,
338,
6213,
470,
3233,
1405,
29871,
29900,
29901,
13,
9651,
363,
364,
297,
1583,
29889,
5029,
1338,
29889,
29879,
999,
29901,
13,
18884,
565,
3233,
338,
6213,
29901,
13,
462,
1678,
716,
29918,
5563,
353,
6213,
13,
18884,
1683,
29901,
13,
462,
1678,
716,
29918,
5563,
353,
3233,
448,
29871,
29896,
13,
13,
18884,
2143,
29918,
4011,
353,
364,
29889,
999,
29889,
657,
29918,
4011,
29898,
5563,
29922,
1482,
29918,
5563,
29897,
13,
13,
18884,
15886,
353,
426,
13,
462,
1678,
525,
6563,
3149,
2396,
364,
29889,
6563,
3149,
29892,
13,
462,
1678,
525,
5450,
362,
2396,
364,
29889,
5450,
362,
29892,
13,
462,
1678,
525,
29885,
4211,
2450,
2396,
364,
29889,
29885,
4211,
2450,
29892,
13,
462,
1678,
525,
999,
1464,
2396,
364,
29889,
999,
1464,
13,
18884,
500,
13,
13,
18884,
2143,
29918,
4011,
29918,
9067,
287,
353,
5159,
13,
18884,
363,
364,
29886,
297,
2143,
29918,
4011,
29901,
13,
462,
1678,
716,
29918,
637,
353,
364,
29886,
3032,
8552,
580,
13,
462,
1678,
716,
29918,
637,
353,
716,
29918,
637,
29889,
9067,
29898,
13264,
29897,
13,
462,
1678,
2143,
29918,
4011,
29918,
9067,
287,
29889,
4397,
29898,
1482,
29918,
637,
29897,
13,
18884,
2011,
29918,
1761,
4619,
2143,
29918,
4011,
29918,
9067,
287,
13,
4706,
736,
2011,
29918,
1761,
13,
13,
13,
1990,
19413,
29898,
4617,
9118,
1125,
13,
1678,
9995,
319,
19413,
2094,
2547,
352,
1078,
263,
731,
310,
1543,
1338,
393,
13,
1678,
16612,
278,
5912,
1641,
5759,
29889,
9995,
13,
13,
1678,
822,
4770,
276,
558,
12035,
1311,
1125,
13,
4706,
565,
756,
5552,
29898,
1311,
29892,
525,
5029,
1338,
29374,
13,
9651,
4552,
1516,
353,
1583,
29889,
5029,
1338,
13,
9651,
736,
4852,
29961,
5550,
29875,
4717,
29901,
19413,
1194,
29915,
29912,
1012,
1495,
29962,
376,
718,
13,
462,
1678,
376,
3319,
29913,
1543,
1338,
29901,
6571,
269,
999,
29892,
6571,
1248,
4790,
787,
29892,
376,
718,
13,
462,
1678,
376,
8875,
11073,
29892,
6571,
16169,
29897,
2564,
4830,
29898,
13,
462,
4706,
1583,
29889,
978,
29892,
13,
462,
4706,
4552,
1516,
17255,
2435,
1649,
3285,
13,
462,
4706,
4552,
1516,
29889,
29879,
999,
17255,
2435,
1649,
3285,
13,
462,
4706,
4552,
1516,
29889,
3733,
4790,
787,
17255,
2435,
1649,
3285,
13,
462,
4706,
4552,
1516,
29889,
21134,
17255,
2435,
1649,
3285,
13,
462,
4706,
1583,
29889,
4011,
17255,
2435,
1649,
580,
13,
462,
1678,
1723,
13,
4706,
1683,
29901,
13,
9651,
736,
14704,
5550,
29875,
4717,
29901,
19413,
1194,
29915,
29912,
1012,
1495,
29962,
1642,
4830,
29898,
1311,
17255,
1990,
1649,
17255,
978,
1649,
29897,
13,
13,
1678,
822,
4770,
710,
12035,
1311,
1125,
13,
4706,
736,
1583,
17255,
276,
558,
1649,
580,
13,
13,
1678,
732,
6799,
13,
1678,
822,
1178,
29898,
1311,
1125,
13,
4706,
736,
1583,
17255,
710,
1649,
580,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
13,
2
] |
spockpy/config/app.py | gavindsouza/spockpy | 58 | 1601267 | # imports - compatibility imports
from __future__ import absolute_import
# imports - module imports
from spockpy.config import Config
from spockpy._util import _round_int
def _get_video_panel_size(length):
size = _round_int(length * 0.25)
return (size, size)
class AppConfig(Config):
WINDOW_WIDTH = 1024
WINDOW_HEIGHT = 768
WINDOW_SIZE = (WINDOW_WIDTH, WINDOW_HEIGHT)
VIDEO_PANEL_SIZE = _get_video_panel_size(WINDOW_WIDTH) | [
1,
396,
24802,
448,
24521,
24802,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
13,
13,
29937,
24802,
448,
3883,
24802,
13,
3166,
805,
1698,
2272,
29889,
2917,
1053,
12782,
13,
3166,
805,
1698,
2272,
3032,
4422,
29871,
1053,
903,
14486,
29918,
524,
13,
13,
1753,
903,
657,
29918,
9641,
29918,
15119,
29918,
2311,
29898,
2848,
1125,
13,
12,
2311,
353,
903,
14486,
29918,
524,
29898,
2848,
334,
29871,
29900,
29889,
29906,
29945,
29897,
13,
13,
12,
2457,
313,
2311,
29892,
2159,
29897,
13,
13,
1990,
2401,
3991,
29898,
3991,
1125,
13,
12,
25152,
3970,
29956,
29918,
22574,
268,
353,
29871,
29896,
29900,
29906,
29946,
13,
12,
25152,
3970,
29956,
29918,
9606,
22530,
1678,
353,
29871,
29955,
29953,
29947,
13,
12,
25152,
3970,
29956,
29918,
14226,
418,
353,
313,
25152,
3970,
29956,
29918,
22574,
29892,
399,
1177,
3970,
29956,
29918,
9606,
22530,
29897,
13,
13,
12,
13044,
29923,
29949,
29918,
29925,
2190,
6670,
29918,
14226,
353,
903,
657,
29918,
9641,
29918,
15119,
29918,
2311,
29898,
25152,
3970,
29956,
29918,
22574,
29897,
2
] |
tests/test_cell.py | nat-chan/nokogiri | 0 | 1606812 | <gh_stars>0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
import unittest
from nokogiri.cell import cell
class test_cell(unittest.TestCase):
def test_スクリプトとしてとして実行したときはラムダ式を返す(self):
self.assertEqual("<lambda>", cell(globals()).__name__)
if __name__ == '__main__':
unittest.main()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
29941,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
5215,
10876,
13,
3166,
2224,
1982,
1053,
10802,
13,
9675,
29889,
2084,
29889,
7851,
29898,
29900,
29892,
851,
29898,
2605,
22168,
1445,
1649,
467,
17863,
2141,
3560,
29889,
3560,
876,
13,
5215,
443,
27958,
13,
3166,
302,
554,
468,
12737,
29889,
3729,
1053,
3038,
13,
13,
1990,
1243,
29918,
3729,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
1678,
822,
1243,
29918,
30255,
30305,
30303,
30605,
30279,
30364,
30326,
30466,
30364,
30326,
30466,
31525,
30448,
30326,
30366,
30364,
30538,
30449,
30281,
30579,
30617,
30607,
30396,
31086,
30427,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
9843,
28945,
2892,
28341,
3038,
29898,
23705,
1338,
16655,
1649,
978,
1649,
29897,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
443,
27958,
29889,
3396,
580,
13,
2
] |
mamonsu/lib/zbx_template.py | dan-aksenov/mamonsu | 0 | 30304 | <gh_stars>0
# -*- coding: utf-8 -*-
from mamonsu.lib.const import Template
class ZbxTemplate(object):
mainTemplate = u"""<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>2.0</version>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>{template}</template>
<name>{template}</name>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name>{application}</name>
</application>
</applications>
<items>{items}</items>
<discovery_rules>{discovery_rules}</discovery_rules>
<macros>{macros}</macros>
</template>
</templates>
<triggers>{triggers}</triggers>
<graphs>{graphs}</graphs>
</zabbix_export>"""
# https://www.zabbix.com/documentation/2.0/manual/appendix/api/item/definitions
item_defaults = [
('name', None), ('type', 2), ('snmp_community', None),
('multiplier', 0), ('inventory_link', 0),
('key', None), ('snmp_oid', None), ('history', 7),
('trends', 365), ('status', 0), ('delay', 60),
('value_type', Template.VALUE_TYPE.numeric_float),
('allowed_hosts', None), ('valuemap', None),
('units', Template.UNITS.none), ('delta', Template.DELTA.as_is),
('snmpv3_contextname', None), ('snmpv3_securityname', None),
('snmpv3_securitylevel', 0), ('snmpv3_authprotocol', 0),
('snmpv3_authpassphrase', None), ('snmpv3_privprotocol', 0),
('snmpv3_privpassphrase', None), ('formula', 1),
('delay_flex', None), ('params', None),
('ipmi_sensor', None), ('data_type', 0), ('authtype', 0),
('username', None), ('password', None), ('publickey', None),
('privatekey', None), ('port', None), ('description', None)
]
trigger_defaults = [
('expression', None), ('name', None), ('url', None),
('status', 0), ('priority', 3), ('description', None),
('type', 0), ('dependencies', None)
]
trigger_discovery_defaults = [
('expression', None), ('name', None), ('url', None),
('status', 0), ('priority', 3), ('description', None),
('type', 0)
]
graph_values_defaults = [
('name', None), ('width', 900), ('height', 200),
('yaxismin', 0.0000), ('yaxismax', 100.0), ('show_work_period', 1),
('show_triggers', 1), ('type', 0), ('show_legend', 1),
('show_3d', 0), ('percent_left', 0.0), ('percent_right', 0.0),
('ymin_type_1', 0), ('ymax_type_1', 0), ('ymin_item_1', 0),
('ymax_item_1', 0)
]
graph_items_defaults = [
('sortorder', None), ('drawtype', 0),
('color', '00CC00'), ('yaxisside', 0),
('calc_fnc', 2), ('type', Template.GRAPH_TYPE.normal)
]
discovery_defaults = [
('name', None), ('type', 2), ('snmp_community', None),
('snmp_oid', None), ('delay', 60), ('status', 0),
('allowed_hosts', None), ('snmpv3_contextname', None),
('snmpv3_securityname', None), ('snmpv3_securitylevel', 0),
('snmpv3_authprotocol', 0), ('snmpv3_authpassphrase', None),
('snmpv3_privprotocol', 0), ('snmpv3_privpassphrase', None),
('delay_flex', None), ('params', None), ('filter', None),
('ipmi_sensor', None), ('authtype', 0),
('username', None), ('password', None), ('publickey', None),
('privatekey', None), ('port', None), ('lifetime', 7),
('description', None), ('key', None)
]
def __init__(self, name, app):
self.Application = app
self.Template = name
def xml(self, plugins=[]):
# sort plugins!
plugins.sort(key=lambda x: x.__class__.__name__)
# create template
template_data = {}
template_data['template'] = self.Template
template_data['application'] = self.Application
template_data['items'] = self._get_all('items', plugins)
template_data['macros'] = ''
template_data['triggers'] = self._get_all('triggers', plugins)
template_data['graphs'] = self._get_all('graphs', plugins)
template_data['discovery_rules'] = self._get_all(
'discovery_rules', plugins)
return self.mainTemplate.format(**template_data)
def _get_all(self, items='items', plugins=[]):
result = ''
for plugin in plugins:
row = getattr(plugin, items)(self)
if row is None:
continue
result += row
return result
def item(self, args={}, xml_key='item'):
return '<{2}>{0}{1}</{2}>'.format(
self._format_args(self.item_defaults, args),
self._application(),
xml_key)
def trigger(self, args={}, xml_key='trigger', defaults=None):
if defaults is None:
defaults = self.trigger_defaults
try:
expression = args['expression']
except KeyError:
raise LookupError(
'Miss expression in trigger: {0}.'.format(args))
args['expression'] = expression.replace('#TEMPLATE', self.Template)
return '<{1}>{0}</{1}>'.format(
self._format_args(defaults, args),
xml_key)
def graph(self, args={}, xml_key='graph'):
try:
items = args['items']
except KeyError:
raise LookupError(
'Miss item in graph: {0}.'.format(args))
graph_items = ''
for idx, item in enumerate(items):
try:
key = item['key']
except KeyError:
raise LookupError(
'Missed key in graph item: {0}.'.format(item))
if 'sortorder' not in item:
item['sortorder'] = idx
row = '<graph_item>{0}<item><host>{1}'
row += '</host><key>{2}</key></item></graph_item>'
graph_items += row.format(
self._format_args(self.graph_items_defaults, item),
self.Template, key)
result = '<{2}>{0}<graph_items>{1}</graph_items></{2}>'
return result.format(
self._format_args(self.graph_values_defaults, args),
graph_items, xml_key)
def discovery_rule(self, rule={}, items=[], triggers=[], graphs=[]):
result_items = '<item_prototypes>'
for item in items:
result_items += self.item(item, xml_key='item_prototype')
result_items += '</item_prototypes>'
result_triggers = '<trigger_prototypes>'
for trigger in triggers:
result_triggers += self.trigger(
trigger, xml_key='trigger_prototype',
defaults=self.trigger_discovery_defaults)
result_triggers += '</trigger_prototypes>'
result_graphs = '<graph_prototypes>'
for graph in graphs:
result_graphs += self.graph(
graph, xml_key='graph_prototype')
result_graphs += '</graph_prototypes>'
result = '<discovery_rule>{0}{1}{2}{3}</discovery_rule>'
return result.format(
self._format_args(self.discovery_defaults, rule),
result_items, result_triggers, result_graphs)
def _application(self):
result = '<applications><application><name>{0}'
result += '</name></application></applications>'
return result.format(self.Application)
def _format_args(self, defaults, override):
result = ''
for pair in defaults:
key = pair[0]
try:
val = override[key]
except KeyError:
val = pair[1]
if val is None:
row = '<{0}/>'.format(key)
else:
row = '<{0}>{1}</{0}>'.format(key, val)
result += row
return result
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
3166,
286,
314,
787,
29884,
29889,
1982,
29889,
3075,
1053,
25663,
13,
13,
13,
1990,
796,
29890,
29916,
6733,
29898,
3318,
1125,
13,
13,
1678,
1667,
6733,
353,
318,
15945,
29908,
8169,
3134,
1873,
543,
29896,
29889,
29900,
29908,
8025,
543,
10496,
29899,
29947,
18943,
13,
29966,
29920,
8846,
861,
29918,
15843,
29958,
13,
29966,
3259,
29958,
29906,
29889,
29900,
829,
3259,
29958,
13,
1678,
529,
13155,
29958,
13,
4706,
529,
2972,
29958,
13,
9651,
529,
978,
29958,
5776,
9884,
829,
978,
29958,
13,
4706,
1533,
2972,
29958,
13,
1678,
1533,
13155,
29958,
13,
1678,
529,
20943,
29958,
13,
4706,
529,
6886,
29958,
13,
9651,
529,
6886,
26208,
6886,
16040,
6886,
29958,
13,
9651,
529,
978,
26208,
6886,
16040,
978,
29958,
13,
9651,
529,
13155,
29958,
13,
18884,
529,
2972,
29958,
13,
462,
1678,
529,
978,
29958,
5776,
9884,
829,
978,
29958,
13,
18884,
1533,
2972,
29958,
13,
9651,
1533,
13155,
29958,
13,
9651,
529,
932,
5795,
29958,
13,
18884,
529,
6214,
29958,
13,
462,
1678,
529,
978,
26208,
6214,
16040,
978,
29958,
13,
18884,
1533,
6214,
29958,
13,
9651,
1533,
932,
5795,
29958,
13,
9651,
529,
7076,
26208,
7076,
16040,
7076,
29958,
13,
9651,
529,
2218,
11911,
29891,
29918,
19238,
26208,
2218,
11911,
29891,
29918,
19238,
16040,
2218,
11911,
29891,
29918,
19238,
29958,
13,
9651,
529,
8628,
1883,
26208,
8628,
1883,
16040,
8628,
1883,
29958,
13,
4706,
1533,
6886,
29958,
13,
1678,
1533,
20943,
29958,
13,
1678,
529,
509,
335,
5743,
26208,
509,
335,
5743,
16040,
509,
335,
5743,
29958,
13,
1678,
529,
4262,
29879,
26208,
4262,
29879,
16040,
4262,
29879,
29958,
13,
829,
29920,
8846,
861,
29918,
15843,
11903,
15945,
13,
13,
29937,
2045,
597,
1636,
29889,
29920,
8846,
861,
29889,
510,
29914,
12663,
29914,
29906,
29889,
29900,
29914,
11288,
29914,
4397,
861,
29914,
2754,
29914,
667,
29914,
25476,
2187,
13,
1678,
2944,
29918,
4381,
29879,
353,
518,
13,
4706,
6702,
978,
742,
6213,
511,
6702,
1853,
742,
29871,
29906,
511,
6702,
16586,
1526,
29918,
23834,
742,
6213,
511,
13,
4706,
6702,
18056,
4926,
742,
29871,
29900,
511,
6702,
262,
23886,
29918,
2324,
742,
29871,
29900,
511,
13,
4706,
6702,
1989,
742,
6213,
511,
6702,
16586,
1526,
29918,
3398,
742,
6213,
511,
6702,
18434,
742,
29871,
29955,
511,
13,
4706,
6702,
509,
1975,
742,
29871,
29941,
29953,
29945,
511,
6702,
4882,
742,
29871,
29900,
511,
6702,
18829,
742,
29871,
29953,
29900,
511,
13,
4706,
6702,
1767,
29918,
1853,
742,
25663,
29889,
19143,
29918,
11116,
29889,
21574,
29918,
7411,
511,
13,
4706,
6702,
24622,
29918,
23525,
742,
6213,
511,
6702,
4387,
331,
481,
742,
6213,
511,
13,
4706,
6702,
348,
1169,
742,
25663,
29889,
3904,
1806,
29903,
29889,
9290,
511,
6702,
4181,
742,
25663,
29889,
2287,
5850,
29909,
29889,
294,
29918,
275,
511,
13,
4706,
6702,
16586,
1526,
29894,
29941,
29918,
4703,
978,
742,
6213,
511,
6702,
16586,
1526,
29894,
29941,
29918,
8926,
978,
742,
6213,
511,
13,
4706,
6702,
16586,
1526,
29894,
29941,
29918,
8926,
5563,
742,
29871,
29900,
511,
6702,
16586,
1526,
29894,
29941,
29918,
5150,
20464,
742,
29871,
29900,
511,
13,
4706,
6702,
16586,
1526,
29894,
29941,
29918,
5150,
3364,
24588,
559,
742,
6213,
511,
6702,
16586,
1526,
29894,
29941,
29918,
22534,
20464,
742,
29871,
29900,
511,
13,
4706,
6702,
16586,
1526,
29894,
29941,
29918,
22534,
3364,
24588,
559,
742,
6213,
511,
6702,
689,
2497,
742,
29871,
29896,
511,
13,
4706,
6702,
18829,
29918,
16041,
742,
6213,
511,
6702,
7529,
742,
6213,
511,
13,
4706,
6702,
666,
2460,
29918,
29879,
6073,
742,
6213,
511,
6702,
1272,
29918,
1853,
742,
29871,
29900,
511,
6702,
1300,
400,
668,
742,
29871,
29900,
511,
13,
4706,
6702,
6786,
742,
6213,
511,
6702,
5630,
742,
6213,
511,
6702,
3597,
1989,
742,
6213,
511,
13,
4706,
6702,
9053,
1989,
742,
6213,
511,
6702,
637,
742,
6213,
511,
6702,
8216,
742,
6213,
29897,
13,
1678,
4514,
13,
13,
1678,
7135,
29918,
4381,
29879,
353,
518,
13,
4706,
6702,
17471,
742,
6213,
511,
6702,
978,
742,
6213,
511,
6702,
2271,
742,
6213,
511,
13,
4706,
6702,
4882,
742,
29871,
29900,
511,
6702,
29886,
21766,
742,
29871,
29941,
511,
6702,
8216,
742,
6213,
511,
13,
4706,
6702,
1853,
742,
29871,
29900,
511,
6702,
22594,
742,
6213,
29897,
13,
1678,
4514,
13,
13,
1678,
7135,
29918,
2218,
11911,
29891,
29918,
4381,
29879,
353,
518,
13,
4706,
6702,
17471,
742,
6213,
511,
6702,
978,
742,
6213,
511,
6702,
2271,
742,
6213,
511,
13,
4706,
6702,
4882,
742,
29871,
29900,
511,
6702,
29886,
21766,
742,
29871,
29941,
511,
6702,
8216,
742,
6213,
511,
13,
4706,
6702,
1853,
742,
29871,
29900,
29897,
13,
1678,
4514,
13,
13,
1678,
3983,
29918,
5975,
29918,
4381,
29879,
353,
518,
13,
4706,
6702,
978,
742,
6213,
511,
6702,
2103,
742,
29871,
29929,
29900,
29900,
511,
6702,
3545,
742,
29871,
29906,
29900,
29900,
511,
13,
4706,
6702,
29891,
8990,
1195,
742,
29871,
29900,
29889,
29900,
29900,
29900,
29900,
511,
6702,
29891,
8990,
3317,
742,
29871,
29896,
29900,
29900,
29889,
29900,
511,
6702,
4294,
29918,
1287,
29918,
19145,
742,
29871,
29896,
511,
13,
4706,
6702,
4294,
29918,
509,
335,
5743,
742,
29871,
29896,
511,
6702,
1853,
742,
29871,
29900,
511,
6702,
4294,
29918,
26172,
742,
29871,
29896,
511,
13,
4706,
6702,
4294,
29918,
29941,
29881,
742,
29871,
29900,
511,
6702,
25376,
29918,
1563,
742,
29871,
29900,
29889,
29900,
511,
6702,
25376,
29918,
1266,
742,
29871,
29900,
29889,
29900,
511,
13,
4706,
6702,
962,
262,
29918,
1853,
29918,
29896,
742,
29871,
29900,
511,
6702,
29891,
3317,
29918,
1853,
29918,
29896,
742,
29871,
29900,
511,
6702,
962,
262,
29918,
667,
29918,
29896,
742,
29871,
29900,
511,
13,
4706,
6702,
29891,
3317,
29918,
667,
29918,
29896,
742,
29871,
29900,
29897,
13,
1678,
4514,
13,
13,
1678,
3983,
29918,
7076,
29918,
4381,
29879,
353,
518,
13,
4706,
6702,
6605,
2098,
742,
6213,
511,
6702,
4012,
1853,
742,
29871,
29900,
511,
13,
4706,
6702,
2780,
742,
525,
29900,
29900,
4174,
29900,
29900,
5477,
6702,
29891,
1165,
790,
680,
742,
29871,
29900,
511,
13,
4706,
6702,
28667,
29918,
9144,
29883,
742,
29871,
29906,
511,
6702,
1853,
742,
25663,
29889,
14345,
3301,
29950,
29918,
11116,
29889,
8945,
29897,
13,
1678,
4514,
13,
13,
1678,
20699,
29918,
4381,
29879,
353,
518,
13,
4706,
6702,
978,
742,
6213,
511,
6702,
1853,
742,
29871,
29906,
511,
6702,
16586,
1526,
29918,
23834,
742,
6213,
511,
13,
4706,
6702,
16586,
1526,
29918,
3398,
742,
6213,
511,
6702,
18829,
742,
29871,
29953,
29900,
511,
6702,
4882,
742,
29871,
29900,
511,
13,
4706,
6702,
24622,
29918,
23525,
742,
6213,
511,
6702,
16586,
1526,
29894,
29941,
29918,
4703,
978,
742,
6213,
511,
13,
4706,
6702,
16586,
1526,
29894,
29941,
29918,
8926,
978,
742,
6213,
511,
6702,
16586,
1526,
29894,
29941,
29918,
8926,
5563,
742,
29871,
29900,
511,
13,
4706,
6702,
16586,
1526,
29894,
29941,
29918,
5150,
20464,
742,
29871,
29900,
511,
6702,
16586,
1526,
29894,
29941,
29918,
5150,
3364,
24588,
559,
742,
6213,
511,
13,
4706,
6702,
16586,
1526,
29894,
29941,
29918,
22534,
20464,
742,
29871,
29900,
511,
6702,
16586,
1526,
29894,
29941,
29918,
22534,
3364,
24588,
559,
742,
6213,
511,
13,
4706,
6702,
18829,
29918,
16041,
742,
6213,
511,
6702,
7529,
742,
6213,
511,
6702,
4572,
742,
6213,
511,
13,
4706,
6702,
666,
2460,
29918,
29879,
6073,
742,
6213,
511,
6702,
1300,
400,
668,
742,
29871,
29900,
511,
13,
4706,
6702,
6786,
742,
6213,
511,
6702,
5630,
742,
6213,
511,
6702,
3597,
1989,
742,
6213,
511,
13,
4706,
6702,
9053,
1989,
742,
6213,
511,
6702,
637,
742,
6213,
511,
6702,
29880,
361,
5410,
742,
29871,
29955,
511,
13,
4706,
6702,
8216,
742,
6213,
511,
6702,
1989,
742,
6213,
29897,
13,
1678,
4514,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1024,
29892,
623,
1125,
13,
4706,
1583,
29889,
4873,
353,
623,
13,
4706,
1583,
29889,
6733,
353,
1024,
13,
13,
1678,
822,
4903,
29898,
1311,
29892,
18224,
29922,
2636,
1125,
13,
4706,
396,
2656,
18224,
29991,
13,
4706,
18224,
29889,
6605,
29898,
1989,
29922,
2892,
921,
29901,
921,
17255,
1990,
1649,
17255,
978,
1649,
29897,
13,
4706,
396,
1653,
4472,
13,
4706,
4472,
29918,
1272,
353,
6571,
13,
4706,
4472,
29918,
1272,
1839,
6886,
2033,
353,
1583,
29889,
6733,
13,
4706,
4472,
29918,
1272,
1839,
6214,
2033,
353,
1583,
29889,
4873,
13,
4706,
4472,
29918,
1272,
1839,
7076,
2033,
353,
1583,
3032,
657,
29918,
497,
877,
7076,
742,
18224,
29897,
13,
4706,
4472,
29918,
1272,
1839,
8628,
1883,
2033,
353,
6629,
13,
4706,
4472,
29918,
1272,
1839,
509,
335,
5743,
2033,
353,
1583,
3032,
657,
29918,
497,
877,
509,
335,
5743,
742,
18224,
29897,
13,
4706,
4472,
29918,
1272,
1839,
4262,
29879,
2033,
353,
1583,
3032,
657,
29918,
497,
877,
4262,
29879,
742,
18224,
29897,
13,
4706,
4472,
29918,
1272,
1839,
2218,
11911,
29891,
29918,
19238,
2033,
353,
1583,
3032,
657,
29918,
497,
29898,
13,
9651,
525,
2218,
11911,
29891,
29918,
19238,
742,
18224,
29897,
13,
4706,
736,
1583,
29889,
3396,
6733,
29889,
4830,
29898,
1068,
6886,
29918,
1272,
29897,
13,
13,
1678,
822,
903,
657,
29918,
497,
29898,
1311,
29892,
4452,
2433,
7076,
742,
18224,
29922,
2636,
1125,
13,
4706,
1121,
353,
6629,
13,
4706,
363,
7079,
297,
18224,
29901,
13,
9651,
1948,
353,
679,
5552,
29898,
8582,
29892,
4452,
5033,
1311,
29897,
13,
9651,
565,
1948,
338,
6213,
29901,
13,
18884,
6773,
13,
9651,
1121,
4619,
1948,
13,
4706,
736,
1121,
13,
13,
1678,
822,
2944,
29898,
1311,
29892,
6389,
3790,
1118,
4903,
29918,
1989,
2433,
667,
29374,
13,
4706,
736,
12801,
29912,
29906,
17428,
29912,
29900,
1157,
29896,
16040,
29912,
29906,
17428,
4286,
4830,
29898,
13,
9651,
1583,
3032,
4830,
29918,
5085,
29898,
1311,
29889,
667,
29918,
4381,
29879,
29892,
6389,
511,
13,
9651,
1583,
3032,
6214,
3285,
13,
9651,
4903,
29918,
1989,
29897,
13,
13,
1678,
822,
7135,
29898,
1311,
29892,
6389,
3790,
1118,
4903,
29918,
1989,
2433,
21001,
742,
21274,
29922,
8516,
1125,
13,
4706,
565,
21274,
338,
6213,
29901,
13,
9651,
21274,
353,
1583,
29889,
21001,
29918,
4381,
29879,
13,
4706,
1018,
29901,
13,
9651,
4603,
353,
6389,
1839,
17471,
2033,
13,
4706,
5174,
7670,
2392,
29901,
13,
9651,
12020,
7419,
786,
2392,
29898,
13,
18884,
525,
18552,
4603,
297,
7135,
29901,
426,
29900,
1836,
4286,
4830,
29898,
5085,
876,
13,
4706,
6389,
1839,
17471,
2033,
353,
4603,
29889,
6506,
14237,
4330,
3580,
29931,
3040,
742,
1583,
29889,
6733,
29897,
13,
4706,
736,
12801,
29912,
29896,
17428,
29912,
29900,
16040,
29912,
29896,
17428,
4286,
4830,
29898,
13,
9651,
1583,
3032,
4830,
29918,
5085,
29898,
4381,
29879,
29892,
6389,
511,
13,
9651,
4903,
29918,
1989,
29897,
13,
13,
1678,
822,
3983,
29898,
1311,
29892,
6389,
3790,
1118,
4903,
29918,
1989,
2433,
4262,
29374,
13,
4706,
1018,
29901,
13,
9651,
4452,
353,
6389,
1839,
7076,
2033,
13,
4706,
5174,
7670,
2392,
29901,
13,
9651,
12020,
7419,
786,
2392,
29898,
13,
18884,
525,
18552,
2944,
297,
3983,
29901,
426,
29900,
1836,
4286,
4830,
29898,
5085,
876,
13,
4706,
3983,
29918,
7076,
353,
6629,
13,
4706,
363,
22645,
29892,
2944,
297,
26985,
29898,
7076,
1125,
13,
9651,
1018,
29901,
13,
18884,
1820,
353,
2944,
1839,
1989,
2033,
13,
9651,
5174,
7670,
2392,
29901,
13,
18884,
12020,
7419,
786,
2392,
29898,
13,
462,
1678,
525,
18552,
287,
1820,
297,
3983,
2944,
29901,
426,
29900,
1836,
4286,
4830,
29898,
667,
876,
13,
9651,
565,
525,
6605,
2098,
29915,
451,
297,
2944,
29901,
13,
18884,
2944,
1839,
6605,
2098,
2033,
353,
22645,
13,
9651,
1948,
353,
12801,
4262,
29918,
667,
26208,
29900,
29913,
29966,
667,
5299,
3069,
26208,
29896,
10162,
13,
9651,
1948,
4619,
525,
829,
3069,
5299,
1989,
26208,
29906,
16040,
1989,
2565,
667,
2565,
4262,
29918,
667,
16299,
13,
9651,
3983,
29918,
7076,
4619,
1948,
29889,
4830,
29898,
13,
18884,
1583,
3032,
4830,
29918,
5085,
29898,
1311,
29889,
4262,
29918,
7076,
29918,
4381,
29879,
29892,
2944,
511,
13,
18884,
1583,
29889,
6733,
29892,
1820,
29897,
13,
4706,
1121,
353,
12801,
29912,
29906,
17428,
29912,
29900,
29913,
29966,
4262,
29918,
7076,
26208,
29896,
16040,
4262,
29918,
7076,
2565,
29912,
29906,
29913,
16299,
13,
4706,
736,
1121,
29889,
4830,
29898,
13,
9651,
1583,
3032,
4830,
29918,
5085,
29898,
1311,
29889,
4262,
29918,
5975,
29918,
4381,
29879,
29892,
6389,
511,
13,
9651,
3983,
29918,
7076,
29892,
4903,
29918,
1989,
29897,
13,
13,
1678,
822,
20699,
29918,
7491,
29898,
1311,
29892,
5751,
3790,
1118,
4452,
11759,
1402,
23660,
11759,
1402,
18445,
29922,
2636,
1125,
13,
13,
4706,
1121,
29918,
7076,
353,
12801,
667,
29918,
771,
4260,
7384,
16299,
13,
4706,
363,
2944,
297,
4452,
29901,
13,
9651,
1121,
29918,
7076,
4619,
1583,
29889,
667,
29898,
667,
29892,
4903,
29918,
1989,
2433,
667,
29918,
16309,
1495,
13,
4706,
1121,
29918,
7076,
4619,
525,
829,
667,
29918,
771,
4260,
7384,
16299,
13,
13,
4706,
1121,
29918,
509,
335,
5743,
353,
12801,
21001,
29918,
771,
4260,
7384,
16299,
13,
4706,
363,
7135,
297,
23660,
29901,
13,
9651,
1121,
29918,
509,
335,
5743,
4619,
1583,
29889,
21001,
29898,
13,
18884,
7135,
29892,
4903,
29918,
1989,
2433,
21001,
29918,
16309,
742,
13,
18884,
21274,
29922,
1311,
29889,
21001,
29918,
2218,
11911,
29891,
29918,
4381,
29879,
29897,
13,
4706,
1121,
29918,
509,
335,
5743,
4619,
525,
829,
21001,
29918,
771,
4260,
7384,
16299,
13,
13,
4706,
1121,
29918,
4262,
29879,
353,
12801,
4262,
29918,
771,
4260,
7384,
16299,
13,
4706,
363,
3983,
297,
18445,
29901,
13,
9651,
1121,
29918,
4262,
29879,
4619,
1583,
29889,
4262,
29898,
13,
18884,
3983,
29892,
4903,
29918,
1989,
2433,
4262,
29918,
16309,
1495,
13,
4706,
1121,
29918,
4262,
29879,
4619,
525,
829,
4262,
29918,
771,
4260,
7384,
16299,
13,
13,
4706,
1121,
353,
12801,
2218,
11911,
29891,
29918,
7491,
26208,
29900,
1157,
29896,
1157,
29906,
1157,
29941,
16040,
2218,
11911,
29891,
29918,
7491,
16299,
13,
4706,
736,
1121,
29889,
4830,
29898,
13,
9651,
1583,
3032,
4830,
29918,
5085,
29898,
1311,
29889,
2218,
11911,
29891,
29918,
4381,
29879,
29892,
5751,
511,
13,
9651,
1121,
29918,
7076,
29892,
1121,
29918,
509,
335,
5743,
29892,
1121,
29918,
4262,
29879,
29897,
13,
13,
1678,
822,
903,
6214,
29898,
1311,
1125,
13,
4706,
1121,
353,
12801,
932,
5795,
5299,
6214,
5299,
978,
26208,
29900,
10162,
13,
4706,
1121,
4619,
525,
829,
978,
2565,
6214,
2565,
932,
5795,
16299,
13,
4706,
736,
1121,
29889,
4830,
29898,
1311,
29889,
4873,
29897,
13,
13,
1678,
822,
903,
4830,
29918,
5085,
29898,
1311,
29892,
21274,
29892,
5712,
1125,
13,
4706,
1121,
353,
6629,
13,
4706,
363,
5101,
297,
21274,
29901,
13,
9651,
1820,
353,
5101,
29961,
29900,
29962,
13,
9651,
1018,
29901,
13,
18884,
659,
353,
5712,
29961,
1989,
29962,
13,
9651,
5174,
7670,
2392,
29901,
13,
18884,
659,
353,
5101,
29961,
29896,
29962,
13,
9651,
565,
659,
338,
6213,
29901,
13,
18884,
1948,
353,
12801,
29912,
29900,
29913,
3779,
4286,
4830,
29898,
1989,
29897,
13,
9651,
1683,
29901,
13,
18884,
1948,
353,
12801,
29912,
29900,
17428,
29912,
29896,
16040,
29912,
29900,
17428,
4286,
4830,
29898,
1989,
29892,
659,
29897,
13,
9651,
1121,
4619,
1948,
13,
4706,
736,
1121,
13,
2
] |
tests/hadoop-etl/test/compression_types.py | mace84/script-languages | 6 | 103490 | <filename>tests/hadoop-etl/test/compression_types.py
#!/usr/bin/env python2.7
# encoding: utf8
import os
import sys
sys.path.append(os.path.realpath(__file__ + '/../../../lib'))
sys.path.append(os.path.realpath(__file__ + '/../../lib'))
import udf
import utils
import datagen
import hadoopenv
class TestDeflate(utils.HiveTestCase):
hive_file_format = 'textfile'
hive_table = '{file_format}_%s'.format(file_format = hive_file_format)
hive_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'string', 'char(20)', 'varchar(50)', 'boolean', 'binary', \
'array<timestamp>', 'map<int, string>', 'struct<s1:int, s2:smallint, s3:date>', \
'uniontype<bigint, timestamp, boolean, varchar(100)>']
exa_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'varchar(5000)', 'char(20)', 'varchar(50)', 'boolean', 'varchar(5000) ASCII', \
'varchar(5000)', 'varchar(5000)', 'varchar(5000)', \
'varchar(5000)']
hive_config_props = ['hive.exec.compress.output=true', \
'mapred.output.compression.codec=org.apache.hadoop.io.compress.DefaultCodec']
num_rows = 1000
has_id_col = True
def test(self):
utils.test_import(self)
utils.validate_import_odbc(self)
class TestGzip(utils.HiveTestCase):
hive_file_format = 'textfile'
hive_table = '{file_format}_%s'.format(file_format = hive_file_format)
hive_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'string', 'char(20)', 'varchar(50)', 'boolean', 'binary', \
'array<timestamp>', 'map<int, string>', 'struct<s1:int, s2:smallint, s3:date>', \
'uniontype<bigint, timestamp, boolean, varchar(100)>']
exa_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'varchar(5000)', 'char(20)', 'varchar(50)', 'boolean', 'varchar(5000) ASCII', \
'varchar(5000)', 'varchar(5000)', 'varchar(5000)', \
'varchar(5000)']
hive_config_props = ['hive.exec.compress.output=true', \
'mapred.output.compression.codec=org.apache.hadoop.io.compress.GzipCodec']
num_rows = 1000
has_id_col = True
def test(self):
utils.test_import(self)
utils.validate_import_odbc(self)
class TestBzip2(utils.HiveTestCase):
hive_file_format = 'textfile'
hive_table = '{file_format}_%s'.format(file_format = hive_file_format)
hive_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'string', 'char(20)', 'varchar(50)', 'boolean', 'binary', \
'array<timestamp>', 'map<int, string>', 'struct<s1:int, s2:smallint, s3:date>', \
'uniontype<bigint, timestamp, boolean, varchar(100)>']
exa_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'varchar(5000)', 'char(20)', 'varchar(50)', 'boolean', 'varchar(5000) ASCII', \
'varchar(5000)', 'varchar(5000)', 'varchar(5000)', \
'varchar(5000)']
hive_config_props = ['hive.exec.compress.output=true', \
'mapred.output.compression.codec=org.apache.hadoop.io.compress.BZip2Codec']
num_rows = 1000
has_id_col = True
def test(self):
utils.test_import(self)
utils.validate_import_odbc(self)
class TestLzo(utils.HiveTestCase):
hive_file_format = 'textfile'
hive_table = '{file_format}_%s'.format(file_format = hive_file_format)
hive_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'string', 'char(20)', 'varchar(50)', 'boolean', 'binary', \
'array<timestamp>', 'map<int, string>', 'struct<s1:int, s2:smallint, s3:date>', \
'uniontype<bigint, timestamp, boolean, varchar(100)>']
exa_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'varchar(5000)', 'char(20)', 'varchar(50)', 'boolean', 'varchar(5000) ASCII', \
'varchar(5000)', 'varchar(5000)', 'varchar(5000)', \
'varchar(5000)']
hive_config_props = ['hive.exec.compress.output=true', \
'mapred.output.compression.codec=com.hadoop.compression.lzo.LzoCodec']
num_rows = 1000
has_id_col = True
def test(self):
utils.test_import(self)
utils.validate_import_odbc(self)
class TestLzop(utils.HiveTestCase):
hive_file_format = 'textfile'
hive_table = '{file_format}_%s'.format(file_format = hive_file_format)
hive_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'string', 'char(20)', 'varchar(50)', 'boolean', 'binary', \
'array<timestamp>', 'map<int, string>', 'struct<s1:int, s2:smallint, s3:date>', \
'uniontype<bigint, timestamp, boolean, varchar(100)>']
exa_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'varchar(5000)', 'char(20)', 'varchar(50)', 'boolean', 'varchar(5000) ASCII', \
'varchar(5000)', 'varchar(5000)', 'varchar(5000)', \
'varchar(5000)']
hive_config_props = ['hive.exec.compress.output=true', \
'mapred.output.compression.codec=com.hadoop.compression.lzo.LzopCodec']
num_rows = 1000
has_id_col = True
def test(self):
utils.test_import(self)
utils.validate_import_odbc(self)
'''
# Requires native libraries
class TestLz4(utils.HiveTestCase):
hive_file_format = 'textfile'
hive_table = '{file_format}_%s'.format(file_format = hive_file_format)
hive_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'string', 'char(20)', 'varchar(50)', 'boolean', 'binary', \
'array<timestamp>', 'map<int, string>', 'struct<s1:int, s2:smallint, s3:date>', \
'uniontype<bigint, timestamp, boolean, varchar(100)>']
exa_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'varchar(5000)', 'char(20)', 'varchar(50)', 'boolean', 'varchar(5000) ASCII', \
'varchar(5000)', 'varchar(5000)', 'varchar(5000)', \
'varchar(5000)']
hive_config_props = ['hive.exec.compress.output=true', \
'mapred.output.compression.codec=org.apache.hadoop.io.compress.Lz4Codec']
num_rows = 1000
has_id_col = True
def test(self):
utils.test_import(self)
utils.validate_import_odbc(self)
'''
'''
# Requires native libraries
class TestSnappy(utils.HiveTestCase):
hive_file_format = 'textfile'
hive_table = '{file_format}_%s'.format(file_format = hive_file_format)
hive_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'string', 'char(20)', 'varchar(50)', 'boolean', 'binary', \
'array<timestamp>', 'map<int, string>', 'struct<s1:int, s2:smallint, s3:date>', \
'uniontype<bigint, timestamp, boolean, varchar(100)>']
exa_col_types = ['decimal(36,0)', 'tinyint', 'smallint', 'int', 'bigint', 'decimal(18,5)', 'float', 'double', \
'date', 'timestamp', 'varchar(5000)', 'char(20)', 'varchar(50)', 'boolean', 'varchar(5000) ASCII', \
'varchar(5000)', 'varchar(5000)', 'varchar(5000)', \
'varchar(5000)']
hive_config_props = ['hive.exec.compress.output=true', \
'mapred.output.compression.codec=org.apache.hadoop.io.compress.SnappyCodec']
num_rows = 1000
has_id_col = True
def test(self):
utils.test_import(self)
utils.validate_import_odbc(self)
'''
if __name__ == '__main__':
udf.main()
| [
1,
529,
9507,
29958,
21150,
29914,
22075,
29899,
300,
29880,
29914,
1688,
29914,
510,
2590,
29918,
8768,
29889,
2272,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
29906,
29889,
29955,
13,
29937,
8025,
29901,
23616,
29947,
13,
13,
5215,
2897,
13,
5215,
10876,
13,
13,
9675,
29889,
2084,
29889,
4397,
29898,
359,
29889,
2084,
29889,
6370,
2084,
22168,
1445,
1649,
718,
8207,
21546,
6995,
1982,
8785,
13,
9675,
29889,
2084,
29889,
4397,
29898,
359,
29889,
2084,
29889,
6370,
2084,
22168,
1445,
1649,
718,
8207,
21546,
1982,
8785,
13,
13,
5215,
318,
2176,
13,
5215,
3667,
29879,
13,
5215,
1418,
5370,
13,
5215,
750,
29877,
3150,
29894,
13,
13,
13,
1990,
4321,
3206,
9632,
29898,
13239,
29889,
29950,
573,
3057,
8259,
1125,
13,
1678,
298,
573,
29918,
1445,
29918,
4830,
353,
525,
726,
1445,
29915,
13,
1678,
298,
573,
29918,
2371,
353,
22372,
1445,
29918,
4830,
2403,
29995,
29879,
4286,
4830,
29898,
1445,
29918,
4830,
353,
298,
573,
29918,
1445,
29918,
4830,
29897,
13,
1678,
298,
573,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
1807,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
19541,
742,
320,
13,
462,
1678,
525,
2378,
29966,
16394,
29958,
742,
525,
1958,
29966,
524,
29892,
1347,
29958,
742,
525,
4984,
29966,
29879,
29896,
29901,
524,
29892,
269,
29906,
29901,
9278,
524,
29892,
269,
29941,
29901,
1256,
29958,
742,
320,
13,
462,
1678,
525,
13094,
1853,
29966,
3752,
524,
29892,
14334,
29892,
7223,
29892,
15236,
29898,
29896,
29900,
29900,
15410,
2033,
13,
1678,
429,
29874,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
27196,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
2033,
13,
1678,
298,
573,
29918,
2917,
29918,
11030,
353,
6024,
29882,
573,
29889,
4258,
29889,
510,
2139,
29889,
4905,
29922,
3009,
742,
320,
13,
462,
4706,
525,
1958,
1127,
29889,
4905,
29889,
510,
2590,
29889,
401,
29883,
29922,
990,
29889,
4288,
29889,
22075,
29889,
601,
29889,
510,
2139,
29889,
4592,
3399,
29883,
2033,
13,
1678,
954,
29918,
5727,
353,
29871,
29896,
29900,
29900,
29900,
13,
1678,
756,
29918,
333,
29918,
1054,
353,
5852,
13,
13,
1678,
822,
1243,
29898,
1311,
1125,
13,
4706,
3667,
29879,
29889,
1688,
29918,
5215,
29898,
1311,
29897,
13,
4706,
3667,
29879,
29889,
15480,
29918,
5215,
29918,
10396,
29883,
29898,
1311,
29897,
13,
13,
13,
1990,
4321,
29954,
7554,
29898,
13239,
29889,
29950,
573,
3057,
8259,
1125,
13,
1678,
298,
573,
29918,
1445,
29918,
4830,
353,
525,
726,
1445,
29915,
13,
1678,
298,
573,
29918,
2371,
353,
22372,
1445,
29918,
4830,
2403,
29995,
29879,
4286,
4830,
29898,
1445,
29918,
4830,
353,
298,
573,
29918,
1445,
29918,
4830,
29897,
13,
1678,
298,
573,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
1807,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
19541,
742,
320,
13,
462,
1678,
525,
2378,
29966,
16394,
29958,
742,
525,
1958,
29966,
524,
29892,
1347,
29958,
742,
525,
4984,
29966,
29879,
29896,
29901,
524,
29892,
269,
29906,
29901,
9278,
524,
29892,
269,
29941,
29901,
1256,
29958,
742,
320,
13,
462,
1678,
525,
13094,
1853,
29966,
3752,
524,
29892,
14334,
29892,
7223,
29892,
15236,
29898,
29896,
29900,
29900,
15410,
2033,
13,
1678,
429,
29874,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
27196,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
2033,
13,
1678,
298,
573,
29918,
2917,
29918,
11030,
353,
6024,
29882,
573,
29889,
4258,
29889,
510,
2139,
29889,
4905,
29922,
3009,
742,
320,
13,
462,
4706,
525,
1958,
1127,
29889,
4905,
29889,
510,
2590,
29889,
401,
29883,
29922,
990,
29889,
4288,
29889,
22075,
29889,
601,
29889,
510,
2139,
29889,
29954,
7554,
3399,
29883,
2033,
13,
1678,
954,
29918,
5727,
353,
29871,
29896,
29900,
29900,
29900,
13,
1678,
756,
29918,
333,
29918,
1054,
353,
5852,
13,
13,
1678,
822,
1243,
29898,
1311,
1125,
13,
4706,
3667,
29879,
29889,
1688,
29918,
5215,
29898,
1311,
29897,
13,
4706,
3667,
29879,
29889,
15480,
29918,
5215,
29918,
10396,
29883,
29898,
1311,
29897,
13,
13,
13,
1990,
4321,
29933,
7554,
29906,
29898,
13239,
29889,
29950,
573,
3057,
8259,
1125,
13,
1678,
298,
573,
29918,
1445,
29918,
4830,
353,
525,
726,
1445,
29915,
13,
1678,
298,
573,
29918,
2371,
353,
22372,
1445,
29918,
4830,
2403,
29995,
29879,
4286,
4830,
29898,
1445,
29918,
4830,
353,
298,
573,
29918,
1445,
29918,
4830,
29897,
13,
1678,
298,
573,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
1807,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
19541,
742,
320,
13,
462,
1678,
525,
2378,
29966,
16394,
29958,
742,
525,
1958,
29966,
524,
29892,
1347,
29958,
742,
525,
4984,
29966,
29879,
29896,
29901,
524,
29892,
269,
29906,
29901,
9278,
524,
29892,
269,
29941,
29901,
1256,
29958,
742,
320,
13,
462,
1678,
525,
13094,
1853,
29966,
3752,
524,
29892,
14334,
29892,
7223,
29892,
15236,
29898,
29896,
29900,
29900,
15410,
2033,
13,
1678,
429,
29874,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
27196,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
2033,
13,
1678,
298,
573,
29918,
2917,
29918,
11030,
353,
6024,
29882,
573,
29889,
4258,
29889,
510,
2139,
29889,
4905,
29922,
3009,
742,
320,
13,
462,
4706,
525,
1958,
1127,
29889,
4905,
29889,
510,
2590,
29889,
401,
29883,
29922,
990,
29889,
4288,
29889,
22075,
29889,
601,
29889,
510,
2139,
29889,
29933,
26264,
29906,
3399,
29883,
2033,
13,
1678,
954,
29918,
5727,
353,
29871,
29896,
29900,
29900,
29900,
13,
1678,
756,
29918,
333,
29918,
1054,
353,
5852,
13,
13,
1678,
822,
1243,
29898,
1311,
1125,
13,
4706,
3667,
29879,
29889,
1688,
29918,
5215,
29898,
1311,
29897,
13,
4706,
3667,
29879,
29889,
15480,
29918,
5215,
29918,
10396,
29883,
29898,
1311,
29897,
13,
13,
13,
1990,
4321,
29931,
2502,
29898,
13239,
29889,
29950,
573,
3057,
8259,
1125,
13,
1678,
298,
573,
29918,
1445,
29918,
4830,
353,
525,
726,
1445,
29915,
13,
1678,
298,
573,
29918,
2371,
353,
22372,
1445,
29918,
4830,
2403,
29995,
29879,
4286,
4830,
29898,
1445,
29918,
4830,
353,
298,
573,
29918,
1445,
29918,
4830,
29897,
13,
1678,
298,
573,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
1807,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
19541,
742,
320,
13,
462,
1678,
525,
2378,
29966,
16394,
29958,
742,
525,
1958,
29966,
524,
29892,
1347,
29958,
742,
525,
4984,
29966,
29879,
29896,
29901,
524,
29892,
269,
29906,
29901,
9278,
524,
29892,
269,
29941,
29901,
1256,
29958,
742,
320,
13,
462,
1678,
525,
13094,
1853,
29966,
3752,
524,
29892,
14334,
29892,
7223,
29892,
15236,
29898,
29896,
29900,
29900,
15410,
2033,
13,
1678,
429,
29874,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
27196,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
2033,
13,
1678,
298,
573,
29918,
2917,
29918,
11030,
353,
6024,
29882,
573,
29889,
4258,
29889,
510,
2139,
29889,
4905,
29922,
3009,
742,
320,
13,
462,
4706,
525,
1958,
1127,
29889,
4905,
29889,
510,
2590,
29889,
401,
29883,
29922,
510,
29889,
22075,
29889,
510,
2590,
29889,
29880,
2502,
29889,
29931,
2502,
3399,
29883,
2033,
13,
1678,
954,
29918,
5727,
353,
29871,
29896,
29900,
29900,
29900,
13,
1678,
756,
29918,
333,
29918,
1054,
353,
5852,
13,
13,
1678,
822,
1243,
29898,
1311,
1125,
13,
4706,
3667,
29879,
29889,
1688,
29918,
5215,
29898,
1311,
29897,
13,
4706,
3667,
29879,
29889,
15480,
29918,
5215,
29918,
10396,
29883,
29898,
1311,
29897,
13,
13,
13,
1990,
4321,
29931,
29920,
459,
29898,
13239,
29889,
29950,
573,
3057,
8259,
1125,
13,
1678,
298,
573,
29918,
1445,
29918,
4830,
353,
525,
726,
1445,
29915,
13,
1678,
298,
573,
29918,
2371,
353,
22372,
1445,
29918,
4830,
2403,
29995,
29879,
4286,
4830,
29898,
1445,
29918,
4830,
353,
298,
573,
29918,
1445,
29918,
4830,
29897,
13,
1678,
298,
573,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
1807,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
19541,
742,
320,
13,
462,
1678,
525,
2378,
29966,
16394,
29958,
742,
525,
1958,
29966,
524,
29892,
1347,
29958,
742,
525,
4984,
29966,
29879,
29896,
29901,
524,
29892,
269,
29906,
29901,
9278,
524,
29892,
269,
29941,
29901,
1256,
29958,
742,
320,
13,
462,
1678,
525,
13094,
1853,
29966,
3752,
524,
29892,
14334,
29892,
7223,
29892,
15236,
29898,
29896,
29900,
29900,
15410,
2033,
13,
1678,
429,
29874,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
27196,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
2033,
13,
1678,
298,
573,
29918,
2917,
29918,
11030,
353,
6024,
29882,
573,
29889,
4258,
29889,
510,
2139,
29889,
4905,
29922,
3009,
742,
320,
13,
462,
4706,
525,
1958,
1127,
29889,
4905,
29889,
510,
2590,
29889,
401,
29883,
29922,
510,
29889,
22075,
29889,
510,
2590,
29889,
29880,
2502,
29889,
29931,
29920,
459,
3399,
29883,
2033,
13,
1678,
954,
29918,
5727,
353,
29871,
29896,
29900,
29900,
29900,
13,
1678,
756,
29918,
333,
29918,
1054,
353,
5852,
13,
13,
1678,
822,
1243,
29898,
1311,
1125,
13,
4706,
3667,
29879,
29889,
1688,
29918,
5215,
29898,
1311,
29897,
13,
4706,
3667,
29879,
29889,
15480,
29918,
5215,
29918,
10396,
29883,
29898,
1311,
29897,
13,
13,
13,
12008,
13,
29937,
830,
339,
2658,
7531,
9562,
13,
1990,
4321,
29931,
29920,
29946,
29898,
13239,
29889,
29950,
573,
3057,
8259,
1125,
13,
1678,
298,
573,
29918,
1445,
29918,
4830,
353,
525,
726,
1445,
29915,
13,
1678,
298,
573,
29918,
2371,
353,
22372,
1445,
29918,
4830,
2403,
29995,
29879,
4286,
4830,
29898,
1445,
29918,
4830,
353,
298,
573,
29918,
1445,
29918,
4830,
29897,
13,
1678,
298,
573,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
1807,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
19541,
742,
320,
13,
462,
1678,
525,
2378,
29966,
16394,
29958,
742,
525,
1958,
29966,
524,
29892,
1347,
29958,
742,
525,
4984,
29966,
29879,
29896,
29901,
524,
29892,
269,
29906,
29901,
9278,
524,
29892,
269,
29941,
29901,
1256,
29958,
742,
320,
13,
462,
1678,
525,
13094,
1853,
29966,
3752,
524,
29892,
14334,
29892,
7223,
29892,
15236,
29898,
29896,
29900,
29900,
15410,
2033,
13,
1678,
429,
29874,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
27196,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
2033,
13,
1678,
298,
573,
29918,
2917,
29918,
11030,
353,
6024,
29882,
573,
29889,
4258,
29889,
510,
2139,
29889,
4905,
29922,
3009,
742,
320,
13,
462,
4706,
525,
1958,
1127,
29889,
4905,
29889,
510,
2590,
29889,
401,
29883,
29922,
990,
29889,
4288,
29889,
22075,
29889,
601,
29889,
510,
2139,
29889,
29931,
29920,
29946,
3399,
29883,
2033,
13,
1678,
954,
29918,
5727,
353,
29871,
29896,
29900,
29900,
29900,
13,
1678,
756,
29918,
333,
29918,
1054,
353,
5852,
13,
13,
1678,
822,
1243,
29898,
1311,
1125,
13,
4706,
3667,
29879,
29889,
1688,
29918,
5215,
29898,
1311,
29897,
13,
4706,
3667,
29879,
29889,
15480,
29918,
5215,
29918,
10396,
29883,
29898,
1311,
29897,
13,
12008,
13,
13,
13,
12008,
13,
29937,
830,
339,
2658,
7531,
9562,
13,
1990,
4321,
29903,
29876,
14862,
29898,
13239,
29889,
29950,
573,
3057,
8259,
1125,
13,
1678,
298,
573,
29918,
1445,
29918,
4830,
353,
525,
726,
1445,
29915,
13,
1678,
298,
573,
29918,
2371,
353,
22372,
1445,
29918,
4830,
2403,
29995,
29879,
4286,
4830,
29898,
1445,
29918,
4830,
353,
298,
573,
29918,
1445,
29918,
4830,
29897,
13,
1678,
298,
573,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
1807,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
19541,
742,
320,
13,
462,
1678,
525,
2378,
29966,
16394,
29958,
742,
525,
1958,
29966,
524,
29892,
1347,
29958,
742,
525,
4984,
29966,
29879,
29896,
29901,
524,
29892,
269,
29906,
29901,
9278,
524,
29892,
269,
29941,
29901,
1256,
29958,
742,
320,
13,
462,
1678,
525,
13094,
1853,
29966,
3752,
524,
29892,
14334,
29892,
7223,
29892,
15236,
29898,
29896,
29900,
29900,
15410,
2033,
13,
1678,
429,
29874,
29918,
1054,
29918,
8768,
353,
6024,
7099,
3039,
29898,
29941,
29953,
29892,
29900,
29897,
742,
525,
25649,
524,
742,
525,
9278,
524,
742,
525,
524,
742,
525,
3752,
524,
742,
525,
7099,
3039,
29898,
29896,
29947,
29892,
29945,
29897,
742,
525,
7411,
742,
525,
8896,
742,
320,
13,
462,
1678,
525,
1256,
742,
525,
16394,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
3090,
29898,
29906,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29897,
742,
525,
20054,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
27196,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
742,
320,
13,
462,
1678,
525,
22408,
29898,
29945,
29900,
29900,
29900,
29897,
2033,
13,
1678,
298,
573,
29918,
2917,
29918,
11030,
353,
6024,
29882,
573,
29889,
4258,
29889,
510,
2139,
29889,
4905,
29922,
3009,
742,
320,
13,
462,
4706,
525,
1958,
1127,
29889,
4905,
29889,
510,
2590,
29889,
401,
29883,
29922,
990,
29889,
4288,
29889,
22075,
29889,
601,
29889,
510,
2139,
29889,
29903,
29876,
14862,
3399,
29883,
2033,
13,
1678,
954,
29918,
5727,
353,
29871,
29896,
29900,
29900,
29900,
13,
1678,
756,
29918,
333,
29918,
1054,
353,
5852,
13,
13,
1678,
822,
1243,
29898,
1311,
1125,
13,
4706,
3667,
29879,
29889,
1688,
29918,
5215,
29898,
1311,
29897,
13,
4706,
3667,
29879,
29889,
15480,
29918,
5215,
29918,
10396,
29883,
29898,
1311,
29897,
13,
12008,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
318,
2176,
29889,
3396,
580,
13,
2
] |
open_sea_v1/endpoints/abc.py | MyNameIsBondJamesBond/opensea-python-wrapper | 14 | 191919 | <gh_stars>10-100
from abc import ABC, abstractmethod
from typing import Generator, Type
from open_sea_v1.endpoints.client import ClientParams
from open_sea_v1.responses.abc import BaseResponse
class BaseEndpoint(ABC):
@property
@abstractmethod
def __post_init__(self):
"""Using post_init to run param validation"""
@property
@abstractmethod
def client_params(self) -> ClientParams:
"""Instance of common OpenSea Endpoint parameters."""
@property
@abstractmethod
def _response_type(self) -> Type[BaseResponse]:
""""""
@property
@abstractmethod
def url(self) -> str:
"""Endpoint URL"""
@abstractmethod
def _parse_json(self) -> Generator[list[list[BaseResponse]], None, None]:
"""Returns all pages for the query."""
@property
@abstractmethod
def get_params(self) -> str:
"""Endpoint URL"""
@property
@abstractmethod
def _validate_request_params(self) -> None:
""""""
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29899,
29896,
29900,
29900,
13,
3166,
25638,
1053,
16417,
29892,
9846,
5696,
13,
3166,
19229,
1053,
3251,
1061,
29892,
5167,
13,
13,
3166,
1722,
29918,
344,
29874,
29918,
29894,
29896,
29889,
355,
9748,
29889,
4645,
1053,
12477,
9629,
13,
3166,
1722,
29918,
344,
29874,
29918,
29894,
29896,
29889,
26679,
267,
29889,
10736,
1053,
7399,
5103,
13,
13,
13,
1990,
7399,
25602,
29898,
19658,
1125,
13,
13,
1678,
732,
6799,
13,
1678,
732,
16595,
5696,
13,
1678,
822,
4770,
2490,
29918,
2344,
12035,
1311,
1125,
13,
4706,
9995,
15156,
1400,
29918,
2344,
304,
1065,
1828,
8845,
15945,
29908,
13,
13,
1678,
732,
6799,
13,
1678,
732,
16595,
5696,
13,
1678,
822,
3132,
29918,
7529,
29898,
1311,
29897,
1599,
12477,
9629,
29901,
13,
4706,
9995,
4998,
310,
3619,
4673,
2008,
29874,
2796,
3149,
4128,
1213,
15945,
13,
13,
1678,
732,
6799,
13,
1678,
732,
16595,
5696,
13,
1678,
822,
903,
5327,
29918,
1853,
29898,
1311,
29897,
1599,
5167,
29961,
5160,
5103,
5387,
13,
4706,
9995,
15945,
29908,
13,
13,
1678,
732,
6799,
13,
1678,
732,
16595,
5696,
13,
1678,
822,
3142,
29898,
1311,
29897,
1599,
851,
29901,
13,
4706,
9995,
25602,
3988,
15945,
29908,
13,
13,
1678,
732,
16595,
5696,
13,
1678,
822,
903,
5510,
29918,
3126,
29898,
1311,
29897,
1599,
3251,
1061,
29961,
1761,
29961,
1761,
29961,
5160,
5103,
20526,
6213,
29892,
6213,
5387,
13,
4706,
9995,
11609,
29879,
599,
6515,
363,
278,
2346,
1213,
15945,
13,
13,
1678,
732,
6799,
13,
1678,
732,
16595,
5696,
13,
1678,
822,
679,
29918,
7529,
29898,
1311,
29897,
1599,
851,
29901,
13,
4706,
9995,
25602,
3988,
15945,
29908,
13,
13,
1678,
732,
6799,
13,
1678,
732,
16595,
5696,
13,
1678,
822,
903,
15480,
29918,
3827,
29918,
7529,
29898,
1311,
29897,
1599,
6213,
29901,
13,
4706,
9995,
15945,
29908,
13,
2
] |
parsifal/apps/reviews/migrations/0020_searchresult.py | ShivamPytho/parsifal | 342 | 29244 | <reponame>ShivamPytho/parsifal<filename>parsifal/apps/reviews/migrations/0020_searchresult.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import parsifal.apps.reviews.models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('library', '0013_auto_20150710_1614'),
('reviews', '0019_study_comments'),
]
operations = [
migrations.CreateModel(
name='SearchResult',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('imported_file', models.FileField(null=True, upload_to=parsifal.apps.reviews.models.search_result_file_upload_to)),
('documents', models.ManyToManyField(to='library.Document')),
('review', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='reviews.Review')),
('search_session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='reviews.SearchSession', null=True)),
('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='reviews.Source')),
],
),
]
| [
1,
529,
276,
1112,
420,
29958,
2713,
440,
314,
29925,
1541,
29877,
29914,
862,
29879,
361,
284,
29966,
9507,
29958,
862,
29879,
361,
284,
29914,
13371,
29914,
276,
7406,
29914,
26983,
800,
29914,
29900,
29900,
29906,
29900,
29918,
4478,
2914,
29889,
2272,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
3166,
9557,
29889,
2585,
1053,
4733,
29892,
9725,
800,
13,
5215,
610,
29879,
361,
284,
29889,
13371,
29889,
276,
7406,
29889,
9794,
13,
5215,
9557,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
13,
13,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
13,
13,
1678,
9962,
353,
518,
13,
4706,
6702,
5258,
742,
525,
29900,
29900,
29896,
29941,
29918,
6921,
29918,
29906,
29900,
29896,
29945,
29900,
29955,
29896,
29900,
29918,
29896,
29953,
29896,
29946,
5477,
13,
4706,
6702,
276,
7406,
742,
525,
29900,
29900,
29896,
29929,
29918,
18082,
29891,
29918,
21032,
5477,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
7974,
3591,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
369,
15828,
29918,
978,
2433,
1367,
742,
28755,
29922,
8824,
29892,
4469,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
8243,
13,
18884,
6702,
5215,
287,
29918,
1445,
742,
4733,
29889,
2283,
3073,
29898,
4304,
29922,
5574,
29892,
6441,
29918,
517,
29922,
862,
29879,
361,
284,
29889,
13371,
29889,
276,
7406,
29889,
9794,
29889,
4478,
29918,
2914,
29918,
1445,
29918,
9009,
29918,
517,
8243,
13,
18884,
6702,
3225,
29879,
742,
4733,
29889,
14804,
1762,
14804,
3073,
29898,
517,
2433,
5258,
29889,
6268,
1495,
511,
13,
18884,
6702,
27828,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
276,
7406,
29889,
1123,
1493,
1495,
511,
13,
18884,
6702,
4478,
29918,
7924,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
276,
7406,
29889,
7974,
7317,
742,
1870,
29922,
5574,
8243,
13,
18884,
6702,
4993,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
276,
7406,
29889,
4435,
1495,
511,
13,
9651,
21251,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
emotion_classifier/data/data_utilities/pkl_emotion_fixer.py | IronEdward/chatbot | 0 | 97028 | <gh_stars>0
import pickle as pkl
from Functions.functions import *
data = pkl.load(open("Data(new)/data.pkl", "rb"))
emotion_type = pkl.load(open("Data(new)/emotion_types.pkl", "rb"))
new_data = []
for i in data:
new_data.append([i[0], emotion_type.index(i[1])])
pkl.dump(new_data, open("Data(new)/final_data.pkl", "wb")) | [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
5839,
280,
408,
282,
6321,
13,
3166,
6680,
29879,
29889,
12171,
1053,
334,
13,
13,
1272,
353,
282,
6321,
29889,
1359,
29898,
3150,
703,
1469,
29898,
1482,
6802,
1272,
29889,
29886,
6321,
613,
376,
6050,
5783,
13,
331,
8194,
29918,
1853,
353,
282,
6321,
29889,
1359,
29898,
3150,
703,
1469,
29898,
1482,
6802,
331,
8194,
29918,
8768,
29889,
29886,
6321,
613,
376,
6050,
5783,
13,
13,
1482,
29918,
1272,
353,
5159,
13,
13,
1454,
474,
297,
848,
29901,
13,
1678,
716,
29918,
1272,
29889,
4397,
4197,
29875,
29961,
29900,
1402,
953,
8194,
29918,
1853,
29889,
2248,
29898,
29875,
29961,
29896,
2314,
2314,
13,
13,
29886,
6321,
29889,
15070,
29898,
1482,
29918,
1272,
29892,
1722,
703,
1469,
29898,
1482,
6802,
8394,
29918,
1272,
29889,
29886,
6321,
613,
376,
29893,
29890,
5783,
2
] |
models/LASSO.py | MattAHarrington/crypto-comovement | 1 | 29226 | #!/usr/bin/env python
# Standard imports
import pandas as pd
import numpy as np
# Pytorch
import torch
from torch import nn
# Using sklearn's LASSO implementation
from sklearn.linear_model import Lasso
# Local Files
from models.model_interface import CryptoModel
class LASSO(CryptoModel):
"""Wrapper around the sklearn LASSO class"""
def __init__(self, alpha=0.1, warm_start=True, verbose_training=False):
"""Create the LASSO model.
:input_size: Input size to the AutoEncoder, should be n_coins
"""
# Arguments
self.alpha = alpha
self.verbose_training = verbose_training
self.model = Lasso(alpha=alpha, fit_intercept=True, warm_start=warm_start)
# set the default plotting color
self.set_plotting_color()
def predict(self, sample):
"""Predict the next out of sample timestep
:sample: Vector or DataFrame of timesteps to use as input for the predictor(s).
:returns: [batch_size, 1, n_coins] Tensor of predictions
"""
n_samp, _, n_features = sample.shape
yhat = self.model.predict(sample.reshape((n_samp, n_features)))
if self.verbose_training:
print(f'prediction: {yhat}')
return yhat
def train(self, training_set):
"""Train, or re-train, the LSTM and AE
:training_set: DataFrame of training samples
"""
X, Y = [], []
for data, target in training_set:
X.append(data.numpy())
Y.append(target.numpy())
X = np.vstack(X)
Y = np.vstack(Y)
n_samples, _, n_features = X.shape
X = X.reshape((n_samples, n_features))
Y = Y.reshape((n_samples, n_features))
self.model.fit(X, Y)
#TODO: print out that coefficients (or at least num of) that the L1 normalization leaves
coef = self.model.coef_
all_zeros = np.isin([0,-0], coef)
if self.verbose_training:
print(f'All zeros? {all_zeros}')
print(f'Coefs? {coef.shape}')
if np.isin(False, all_zeros):
print(self.model.coef_)
print(type(self.model.coef_))
print(self.model.coef_.shape)
def get_fullname(self):
"""Get the full-grammar name for this model
:returns: English phrase as string
"""
return f"LASSO_alpha-{self.alpha}"
def get_filename(self):
"""Get the abbreviated (file)name for this model
:returns: Abbreviated string with underscores
"""
return f"LASSO_alpha-{self.alpha}"
def needs_retraining(self):
"""Does this model need regular retraining while forecasting?
:returns: bool
"""
return True
def set_plotting_color(self, color="#FCB97D"):
"""Set color used for plotting
:color: Hex value string
"""
self.color = color
def get_plotting_color(self):
"""return color for graphing distinction
:returns: str of color
"""
return self.color
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
13,
29937,
10117,
24802,
13,
5215,
11701,
408,
10518,
13,
5215,
12655,
408,
7442,
13,
13,
29937,
349,
3637,
25350,
13,
5215,
4842,
305,
13,
3166,
4842,
305,
1053,
302,
29876,
13,
13,
29937,
5293,
2071,
19668,
29915,
29879,
17900,
1799,
29949,
5314,
13,
3166,
2071,
19668,
29889,
10660,
29918,
4299,
1053,
365,
9979,
13,
13,
29937,
9959,
12745,
13,
3166,
4733,
29889,
4299,
29918,
13248,
1053,
315,
17929,
3195,
13,
13,
1990,
17900,
1799,
29949,
29898,
29907,
17929,
3195,
1125,
13,
1678,
9995,
15646,
2820,
278,
2071,
19668,
17900,
1799,
29949,
770,
15945,
29908,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
15595,
29922,
29900,
29889,
29896,
29892,
14294,
29918,
2962,
29922,
5574,
29892,
26952,
29918,
26495,
29922,
8824,
1125,
13,
4706,
9995,
4391,
278,
17900,
1799,
29949,
1904,
29889,
13,
13,
4706,
584,
2080,
29918,
2311,
29901,
10567,
2159,
304,
278,
11133,
8566,
6119,
29892,
881,
367,
302,
29918,
1111,
1144,
13,
13,
4706,
9995,
13,
13,
4706,
396,
11842,
9331,
13,
4706,
1583,
29889,
2312,
353,
15595,
13,
4706,
1583,
29889,
369,
15828,
29918,
26495,
353,
26952,
29918,
26495,
13,
13,
4706,
1583,
29889,
4299,
353,
365,
9979,
29898,
2312,
29922,
2312,
29892,
6216,
29918,
1639,
1547,
29922,
5574,
29892,
14294,
29918,
2962,
29922,
29893,
2817,
29918,
2962,
29897,
13,
13,
4706,
396,
731,
278,
2322,
6492,
1259,
2927,
13,
4706,
1583,
29889,
842,
29918,
5317,
1259,
29918,
2780,
580,
13,
13,
1678,
822,
8500,
29898,
1311,
29892,
4559,
1125,
13,
4706,
9995,
23084,
919,
278,
2446,
714,
310,
4559,
5335,
342,
1022,
13,
4706,
584,
11249,
29901,
16510,
470,
3630,
4308,
310,
5335,
4196,
567,
304,
671,
408,
1881,
363,
278,
8500,
272,
29898,
29879,
467,
13,
4706,
584,
18280,
29901,
518,
16175,
29918,
2311,
29892,
29871,
29896,
29892,
302,
29918,
1111,
1144,
29962,
323,
6073,
310,
27303,
13,
4706,
9995,
13,
4706,
302,
29918,
29879,
1160,
29892,
17117,
302,
29918,
22100,
353,
4559,
29889,
12181,
13,
4706,
343,
2455,
353,
1583,
29889,
4299,
29889,
27711,
29898,
11249,
29889,
690,
14443,
3552,
29876,
29918,
29879,
1160,
29892,
302,
29918,
22100,
4961,
13,
4706,
565,
1583,
29889,
369,
15828,
29918,
26495,
29901,
13,
9651,
1596,
29898,
29888,
29915,
11965,
2463,
29901,
426,
29891,
2455,
29913,
1495,
13,
4706,
736,
343,
2455,
13,
13,
1678,
822,
7945,
29898,
1311,
29892,
6694,
29918,
842,
1125,
13,
4706,
9995,
5323,
262,
29892,
470,
337,
29899,
14968,
29892,
278,
365,
1254,
29924,
322,
319,
29923,
13,
13,
4706,
584,
26495,
29918,
842,
29901,
3630,
4308,
310,
6694,
11916,
13,
13,
4706,
9995,
13,
4706,
1060,
29892,
612,
353,
19997,
5159,
13,
4706,
363,
848,
29892,
3646,
297,
6694,
29918,
842,
29901,
13,
9651,
1060,
29889,
4397,
29898,
1272,
29889,
23749,
3101,
13,
9651,
612,
29889,
4397,
29898,
5182,
29889,
23749,
3101,
13,
13,
4706,
1060,
353,
7442,
29889,
29894,
1429,
29898,
29990,
29897,
13,
4706,
612,
353,
7442,
29889,
29894,
1429,
29898,
29979,
29897,
13,
4706,
302,
29918,
27736,
29892,
17117,
302,
29918,
22100,
353,
1060,
29889,
12181,
13,
4706,
1060,
353,
1060,
29889,
690,
14443,
3552,
29876,
29918,
27736,
29892,
302,
29918,
22100,
876,
13,
4706,
612,
353,
612,
29889,
690,
14443,
3552,
29876,
29918,
27736,
29892,
302,
29918,
22100,
876,
13,
4706,
1583,
29889,
4299,
29889,
9202,
29898,
29990,
29892,
612,
29897,
13,
13,
4706,
396,
4986,
3970,
29901,
1596,
714,
393,
16127,
313,
272,
472,
3203,
954,
310,
29897,
393,
278,
365,
29896,
4226,
2133,
11308,
13,
4706,
1302,
1389,
353,
1583,
29889,
4299,
29889,
1111,
1389,
29918,
13,
4706,
599,
29918,
3298,
359,
353,
7442,
29889,
275,
262,
4197,
29900,
6653,
29900,
1402,
1302,
1389,
29897,
13,
4706,
565,
1583,
29889,
369,
15828,
29918,
26495,
29901,
13,
9651,
1596,
29898,
29888,
29915,
3596,
24786,
29973,
426,
497,
29918,
3298,
359,
29913,
1495,
13,
9651,
1596,
29898,
29888,
29915,
7967,
1389,
29879,
29973,
426,
1111,
1389,
29889,
12181,
29913,
1495,
13,
9651,
565,
7442,
29889,
275,
262,
29898,
8824,
29892,
599,
29918,
3298,
359,
1125,
13,
18884,
1596,
29898,
1311,
29889,
4299,
29889,
1111,
1389,
19925,
13,
18884,
1596,
29898,
1853,
29898,
1311,
29889,
4299,
29889,
1111,
1389,
29918,
876,
13,
18884,
1596,
29898,
1311,
29889,
4299,
29889,
1111,
1389,
5396,
12181,
29897,
13,
13,
1678,
822,
679,
29918,
8159,
978,
29898,
1311,
1125,
13,
4706,
9995,
2577,
278,
2989,
29899,
1393,
3034,
1024,
363,
445,
1904,
13,
4706,
584,
18280,
29901,
4223,
16549,
408,
1347,
13,
4706,
9995,
13,
4706,
736,
285,
29908,
4375,
1799,
29949,
29918,
2312,
29899,
29912,
1311,
29889,
2312,
5038,
13,
13,
1678,
822,
679,
29918,
9507,
29898,
1311,
1125,
13,
4706,
9995,
2577,
278,
29759,
1403,
630,
313,
1445,
29897,
978,
363,
445,
1904,
13,
4706,
584,
18280,
29901,
1976,
1030,
1403,
630,
1347,
411,
23400,
29883,
2361,
13,
4706,
9995,
13,
4706,
736,
285,
29908,
4375,
1799,
29949,
29918,
2312,
29899,
29912,
1311,
29889,
2312,
5038,
13,
13,
1678,
822,
4225,
29918,
2267,
336,
2827,
29898,
1311,
1125,
13,
4706,
9995,
25125,
445,
1904,
817,
4943,
337,
26495,
1550,
29821,
579,
292,
29973,
13,
4706,
584,
18280,
29901,
6120,
13,
4706,
9995,
13,
4706,
736,
5852,
13,
13,
1678,
822,
731,
29918,
5317,
1259,
29918,
2780,
29898,
1311,
29892,
2927,
9880,
8610,
29933,
29929,
29955,
29928,
29908,
1125,
13,
4706,
9995,
2697,
2927,
1304,
363,
6492,
1259,
13,
4706,
584,
2780,
29901,
379,
735,
995,
1347,
13,
4706,
9995,
13,
4706,
1583,
29889,
2780,
353,
2927,
13,
13,
1678,
822,
679,
29918,
5317,
1259,
29918,
2780,
29898,
1311,
1125,
13,
4706,
9995,
2457,
2927,
363,
3983,
292,
21578,
13,
4706,
584,
18280,
29901,
851,
310,
2927,
13,
4706,
9995,
13,
4706,
736,
1583,
29889,
2780,
13,
2
] |
src/util.py | BobToninho/cybersecurity-project | 0 | 142713 | <filename>src/util.py
# Taken from https://github.com/ojroques/garbled-circuit
import json
# HELPER FUNCTIONS
def parse_json(json_path):
with open(json_path) as json_file:
return json.load(json_file)
| [
1,
529,
9507,
29958,
4351,
29914,
4422,
29889,
2272,
13,
29937,
323,
9424,
515,
2045,
597,
3292,
29889,
510,
29914,
3848,
307,
1912,
29914,
5397,
27225,
29899,
6034,
3121,
13,
5215,
4390,
13,
13,
13,
29937,
379,
6670,
13171,
383,
28700,
29903,
13,
1753,
6088,
29918,
3126,
29898,
3126,
29918,
2084,
1125,
13,
1678,
411,
1722,
29898,
3126,
29918,
2084,
29897,
408,
4390,
29918,
1445,
29901,
13,
4706,
736,
4390,
29889,
1359,
29898,
3126,
29918,
1445,
29897,
13,
2
] |
app.py | iio1989/oshite | 0 | 12954 | <gh_stars>0
from flask import Flask, render_template, request, redirect, url_for, Markup
import app_helper as apHelp
app = Flask(__name__)
@app.route('/')
def root():
return render_template('home.html')
# click convetBtn. get HttpParam.
@app.route('/post', methods=['GET', 'POST'])
def post():
if request.method == 'POST':
input_kana = request.form['input_kana']
converted_input_list = apHelp.getConvetedStr_kanaToOshite(input_kana)
# rendering for home.html.
return render_template('home.html',
input_kana=input_kana,
converted_input_list=converted_input_list,
fileType= apHelp.FILE_TYPE)
else: # error redirect.
return redirect(url_for('home'))
# click homeBtn from header.
@app.route('/home', methods=['GET', 'POST'])
def home():
return render_template('home.html')
# click aboutBtn from header.
@app.route('/about', methods=['GET', 'POST'])
def about():
return render_template('about.html')
# click historyBtn from header.
@app.route('/history', methods=['GET', 'POST'])
def history():
return render_template('history.html')
if __name__ == '__main__':
app.run(debug=True) | [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
29784,
1053,
2379,
1278,
29892,
4050,
29918,
6886,
29892,
2009,
29892,
6684,
29892,
3142,
29918,
1454,
29892,
4485,
786,
13,
5215,
623,
29918,
20907,
408,
3095,
29648,
13,
13,
932,
353,
2379,
1278,
22168,
978,
1649,
29897,
13,
13,
29992,
932,
29889,
13134,
11219,
1495,
13,
1753,
3876,
7295,
13,
1678,
736,
4050,
29918,
6886,
877,
5184,
29889,
1420,
1495,
13,
13,
29937,
2828,
378,
5990,
20808,
29889,
679,
9056,
4736,
29889,
13,
29992,
932,
29889,
13134,
11219,
2490,
742,
3519,
29922,
1839,
7194,
742,
525,
5438,
11287,
13,
1753,
1400,
7295,
13,
1678,
565,
2009,
29889,
5696,
1275,
525,
5438,
2396,
13,
4706,
1881,
29918,
29895,
1648,
353,
2009,
29889,
689,
1839,
2080,
29918,
29895,
1648,
2033,
13,
4706,
11543,
29918,
2080,
29918,
1761,
353,
3095,
29648,
29889,
657,
1168,
5990,
287,
5015,
29918,
29895,
1648,
1762,
29949,
845,
568,
29898,
2080,
29918,
29895,
1648,
29897,
13,
4706,
396,
15061,
363,
3271,
29889,
1420,
29889,
13,
4706,
736,
4050,
29918,
6886,
877,
5184,
29889,
1420,
742,
13,
462,
1669,
1881,
29918,
29895,
1648,
29922,
2080,
29918,
29895,
1648,
29892,
13,
462,
1669,
11543,
29918,
2080,
29918,
1761,
29922,
13441,
287,
29918,
2080,
29918,
1761,
29892,
13,
462,
1669,
934,
1542,
29922,
3095,
29648,
29889,
7724,
29918,
11116,
29897,
13,
1678,
1683,
29901,
396,
1059,
6684,
29889,
13,
4706,
736,
6684,
29898,
2271,
29918,
1454,
877,
5184,
8785,
13,
13,
29937,
2828,
3271,
20808,
515,
4839,
29889,
13,
29992,
932,
29889,
13134,
11219,
5184,
742,
3519,
29922,
1839,
7194,
742,
525,
5438,
11287,
13,
1753,
3271,
7295,
13,
1678,
736,
4050,
29918,
6886,
877,
5184,
29889,
1420,
1495,
13,
13,
29937,
2828,
1048,
20808,
515,
4839,
29889,
13,
29992,
932,
29889,
13134,
11219,
12717,
742,
3519,
29922,
1839,
7194,
742,
525,
5438,
11287,
13,
1753,
1048,
7295,
13,
1678,
736,
4050,
29918,
6886,
877,
12717,
29889,
1420,
1495,
13,
13,
29937,
2828,
4955,
20808,
515,
4839,
29889,
13,
29992,
932,
29889,
13134,
11219,
18434,
742,
3519,
29922,
1839,
7194,
742,
525,
5438,
11287,
13,
1753,
4955,
7295,
13,
1678,
736,
4050,
29918,
6886,
877,
18434,
29889,
1420,
1495,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
623,
29889,
3389,
29898,
8382,
29922,
5574,
29897,
2
] |
tests/test_cache.py | phaustin/jupyter-cache | 0 | 128945 | <gh_stars>0
import os
from textwrap import dedent
import nbformat as nbf
import pytest
from jupyter_cache.cache.main import JupyterCacheBase
from jupyter_cache.base import NbValidityError
NB_PATH = os.path.join(os.path.realpath(os.path.dirname(__file__)), "notebooks")
def test_basic_workflow(tmp_path):
cache = JupyterCacheBase(str(tmp_path))
with pytest.raises(NbValidityError):
cache.cache_notebook_file(path=os.path.join(NB_PATH, "basic.ipynb"))
cache.cache_notebook_file(
path=os.path.join(NB_PATH, "basic.ipynb"),
uri="basic.ipynb",
check_validity=False,
)
assert cache.list_cache_records()[0].uri == "basic.ipynb"
pk = cache.match_cache_file(path=os.path.join(NB_PATH, "basic.ipynb")).pk
nb_bundle = cache.get_cache_bundle(pk)
assert nb_bundle.nb.metadata["kernelspec"] == {
"display_name": "Python 3",
"language": "python",
"name": "python3",
}
assert set(nb_bundle.record.to_dict().keys()) == {
"pk",
"hashkey",
"uri",
"data",
"created",
"accessed",
"description",
}
# assert cache.get_cache_codecell(pk, 0).source == "a=1\nprint(a)"
path = os.path.join(NB_PATH, "basic_failing.ipynb")
diff = cache.diff_nbfile_with_cache(pk, path, as_str=True, use_color=False)
assert diff == dedent(
f"""\
nbdiff
--- cached pk=1
+++ other: {path}
## inserted before nb/cells/0:
+ code cell:
+ source:
+ raise Exception('oopsie!')
## deleted nb/cells/0:
- code cell:
- execution_count: 2
- source:
- a=1
- print(a)
- outputs:
- output 0:
- output_type: stream
- name: stdout
- text:
- 1
"""
)
cache.remove_cache(pk)
assert cache.list_cache_records() == []
cache.cache_notebook_file(
path=os.path.join(NB_PATH, "basic.ipynb"),
uri="basic.ipynb",
check_validity=False,
)
with pytest.raises(ValueError):
cache.stage_notebook_file(os.path.join(NB_PATH, "basic.ipynb"), assets=[""])
cache.stage_notebook_file(
os.path.join(NB_PATH, "basic.ipynb"),
assets=[os.path.join(NB_PATH, "basic.ipynb")],
)
assert [r.pk for r in cache.list_staged_records()] == [1]
assert [r.pk for r in cache.list_staged_unexecuted()] == []
cache.stage_notebook_file(os.path.join(NB_PATH, "basic_failing.ipynb"))
assert [r.pk for r in cache.list_staged_records()] == [1, 2]
assert [r.pk for r in cache.list_staged_unexecuted()] == [2]
bundle = cache.get_staged_notebook(os.path.join(NB_PATH, "basic_failing.ipynb"))
assert bundle.nb.metadata
cache.clear_cache()
assert cache.list_cache_records() == []
def test_merge_match_into_notebook(tmp_path):
cache = JupyterCacheBase(str(tmp_path))
cache.cache_notebook_file(
path=os.path.join(NB_PATH, "basic.ipynb"), check_validity=False
)
nb = nbf.read(os.path.join(NB_PATH, "basic_unrun.ipynb"), 4)
pk, merged = cache.merge_match_into_notebook(nb)
assert merged.cells[1] == {
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [{"name": "stdout", "output_type": "stream", "text": "1\n"}],
"source": "a=1\nprint(a)",
}
def test_artifacts(tmp_path):
cache = JupyterCacheBase(str(tmp_path))
with pytest.raises(IOError):
cache.cache_notebook_file(
path=os.path.join(NB_PATH, "basic.ipynb"),
uri="basic.ipynb",
artifacts=(os.path.join(NB_PATH),),
check_validity=False,
)
cache.cache_notebook_file(
path=os.path.join(NB_PATH, "basic.ipynb"),
uri="basic.ipynb",
artifacts=(os.path.join(NB_PATH, "artifact_folder", "artifact.txt"),),
check_validity=False,
)
hashkey = cache.get_cache_record(1).hashkey
assert {
str(p.relative_to(tmp_path)) for p in tmp_path.glob("**/*") if p.is_file()
} == {
"global.db",
f"executed/{hashkey}/base.ipynb",
f"executed/{hashkey}/artifacts/artifact_folder/artifact.txt",
}
bundle = cache.get_cache_bundle(1)
assert {str(p) for p in bundle.artifacts.relative_paths} == {
"artifact_folder/artifact.txt"
}
text = list(h.read().decode() for r, h in bundle.artifacts)[0]
assert text.rstrip() == "An artifact"
with cache.cache_artefacts_temppath(1) as path:
assert path.joinpath("artifact_folder").exists()
# jupyter_client/session.py:371: DeprecationWarning:
# Session._key_changed is deprecated in traitlets: use @observe and @unobserve instead
@pytest.mark.filterwarnings("ignore")
def test_execution(tmp_path):
from jupyter_cache.executors import load_executor
db = JupyterCacheBase(str(tmp_path))
db.stage_notebook_file(path=os.path.join(NB_PATH, "basic_unrun.ipynb"))
db.stage_notebook_file(path=os.path.join(NB_PATH, "basic_failing.ipynb"))
db.stage_notebook_file(
path=os.path.join(NB_PATH, "external_output.ipynb"),
assets=(os.path.join(NB_PATH, "basic.ipynb"),),
)
executor = load_executor("basic", db)
result = executor.run_and_cache()
print(result)
assert result == {
"succeeded": [
os.path.join(NB_PATH, "basic_unrun.ipynb"),
os.path.join(NB_PATH, "external_output.ipynb"),
],
"excepted": [os.path.join(NB_PATH, "basic_failing.ipynb")],
"errored": [],
}
assert len(db.list_cache_records()) == 2
bundle = db.get_cache_bundle(1)
assert bundle.nb.cells[0] == {
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [{"name": "stdout", "output_type": "stream", "text": "1\n"}],
"source": "a=1\nprint(a)",
}
assert "execution_seconds" in bundle.record.data
with db.cache_artefacts_temppath(2) as path:
paths = [str(p.relative_to(path)) for p in path.glob("**/*") if p.is_file()]
assert paths == ["artifact.txt"]
assert path.joinpath("artifact.txt").read_text() == "hi"
stage_record = db.get_staged_record(2)
assert stage_record.traceback is not None
assert "Exception: oopsie!" in stage_record.traceback
@pytest.mark.filterwarnings("ignore")
def test_execution_timeout_config(tmp_path):
""" tests the timeout value passed to the executor"""
from jupyter_cache.executors import load_executor
db = JupyterCacheBase(str(tmp_path))
db.stage_notebook_file(path=os.path.join(NB_PATH, "complex_outputs_unrun.ipynb"))
executor = load_executor("basic", db)
result = executor.run_and_cache(timeout=60)
assert result == {
"succeeded": [os.path.join(NB_PATH, "complex_outputs_unrun.ipynb")],
"excepted": [],
"errored": [],
}
db.clear_cache()
db.stage_notebook_file(path=os.path.join(NB_PATH, "complex_outputs_unrun.ipynb"))
executor = load_executor("basic", db)
result = executor.run_and_cache(timeout=1)
assert result == {
"succeeded": [],
"excepted": [os.path.join(NB_PATH, "complex_outputs_unrun.ipynb")],
"errored": [],
}
@pytest.mark.filterwarnings("ignore")
def test_execution_timeout_metadata(tmp_path):
""" tests the timeout metadata key in notebooks"""
from jupyter_cache.executors import load_executor
db = JupyterCacheBase(str(tmp_path))
db.stage_notebook_file(
path=os.path.join(NB_PATH, "complex_outputs_unrun_timeout.ipynb")
)
executor = load_executor("basic", db)
result = executor.run_and_cache()
assert result == {
"succeeded": [],
"excepted": [os.path.join(NB_PATH, "complex_outputs_unrun_timeout.ipynb")],
"errored": [],
}
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
2897,
13,
3166,
1426,
6312,
1053,
28262,
296,
13,
13,
5215,
302,
29890,
4830,
408,
302,
1635,
13,
5215,
11451,
1688,
13,
13,
3166,
432,
786,
25547,
29918,
8173,
29889,
8173,
29889,
3396,
1053,
27441,
25547,
10408,
5160,
13,
3166,
432,
786,
25547,
29918,
8173,
29889,
3188,
1053,
405,
29890,
7211,
537,
2392,
13,
13,
13,
23189,
29918,
10145,
353,
2897,
29889,
2084,
29889,
7122,
29898,
359,
29889,
2084,
29889,
6370,
2084,
29898,
359,
29889,
2084,
29889,
25721,
22168,
1445,
1649,
8243,
376,
1333,
19273,
29879,
1159,
13,
13,
13,
1753,
1243,
29918,
16121,
29918,
1287,
1731,
29898,
7050,
29918,
2084,
1125,
13,
1678,
7090,
353,
27441,
25547,
10408,
5160,
29898,
710,
29898,
7050,
29918,
2084,
876,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
29940,
29890,
7211,
537,
2392,
1125,
13,
4706,
7090,
29889,
8173,
29918,
1333,
19273,
29918,
1445,
29898,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
5783,
13,
1678,
7090,
29889,
8173,
29918,
1333,
19273,
29918,
1445,
29898,
13,
4706,
2224,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
4968,
13,
4706,
21333,
543,
16121,
29889,
666,
948,
29890,
613,
13,
4706,
1423,
29918,
3084,
537,
29922,
8824,
29892,
13,
1678,
1723,
13,
1678,
4974,
7090,
29889,
1761,
29918,
8173,
29918,
3757,
4339,
580,
29961,
29900,
1822,
5338,
1275,
376,
16121,
29889,
666,
948,
29890,
29908,
13,
1678,
282,
29895,
353,
7090,
29889,
4352,
29918,
8173,
29918,
1445,
29898,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
1159,
467,
20571,
13,
1678,
302,
29890,
29918,
16718,
353,
7090,
29889,
657,
29918,
8173,
29918,
16718,
29898,
20571,
29897,
13,
1678,
4974,
302,
29890,
29918,
16718,
29889,
9877,
29889,
19635,
3366,
22178,
1379,
3135,
3108,
1275,
426,
13,
4706,
376,
4990,
29918,
978,
1115,
376,
11980,
29871,
29941,
613,
13,
4706,
376,
11675,
1115,
376,
4691,
613,
13,
4706,
376,
978,
1115,
376,
4691,
29941,
613,
13,
1678,
500,
13,
1678,
4974,
731,
29898,
9877,
29918,
16718,
29889,
11651,
29889,
517,
29918,
8977,
2141,
8149,
3101,
1275,
426,
13,
4706,
376,
20571,
613,
13,
4706,
376,
8568,
1989,
613,
13,
4706,
376,
5338,
613,
13,
4706,
376,
1272,
613,
13,
4706,
376,
11600,
613,
13,
4706,
376,
5943,
287,
613,
13,
4706,
376,
8216,
613,
13,
1678,
500,
13,
1678,
396,
4974,
7090,
29889,
657,
29918,
8173,
29918,
401,
3729,
29898,
20571,
29892,
29871,
29900,
467,
4993,
1275,
376,
29874,
29922,
29896,
29905,
29876,
2158,
29898,
29874,
5513,
13,
13,
1678,
2224,
353,
2897,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29918,
14057,
292,
29889,
666,
948,
29890,
1159,
13,
1678,
2923,
353,
7090,
29889,
12765,
29918,
9877,
1445,
29918,
2541,
29918,
8173,
29898,
20571,
29892,
2224,
29892,
408,
29918,
710,
29922,
5574,
29892,
671,
29918,
2780,
29922,
8824,
29897,
13,
1678,
4974,
2923,
1275,
28262,
296,
29898,
13,
4706,
285,
15945,
26732,
13,
4706,
302,
6448,
2593,
13,
4706,
11474,
22152,
282,
29895,
29922,
29896,
13,
4706,
718,
1817,
916,
29901,
426,
2084,
29913,
13,
4706,
444,
15478,
1434,
302,
29890,
29914,
3729,
29879,
29914,
29900,
29901,
13,
4706,
718,
29871,
775,
3038,
29901,
13,
4706,
718,
1678,
2752,
29901,
13,
4706,
718,
418,
12020,
8960,
877,
29877,
3554,
347,
29991,
1495,
13,
13,
4706,
444,
11132,
302,
29890,
29914,
3729,
29879,
29914,
29900,
29901,
13,
4706,
448,
29871,
775,
3038,
29901,
13,
4706,
448,
1678,
8225,
29918,
2798,
29901,
29871,
29906,
13,
4706,
448,
1678,
2752,
29901,
13,
4706,
448,
418,
263,
29922,
29896,
13,
4706,
448,
418,
1596,
29898,
29874,
29897,
13,
4706,
448,
1678,
14391,
29901,
13,
4706,
448,
418,
1962,
29871,
29900,
29901,
13,
4706,
448,
4706,
1962,
29918,
1853,
29901,
4840,
13,
4706,
448,
4706,
1024,
29901,
27591,
13,
4706,
448,
4706,
1426,
29901,
13,
4706,
448,
965,
29896,
13,
13,
4706,
9995,
13,
1678,
1723,
13,
1678,
7090,
29889,
5992,
29918,
8173,
29898,
20571,
29897,
13,
1678,
4974,
7090,
29889,
1761,
29918,
8173,
29918,
3757,
4339,
580,
1275,
5159,
13,
13,
1678,
7090,
29889,
8173,
29918,
1333,
19273,
29918,
1445,
29898,
13,
4706,
2224,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
4968,
13,
4706,
21333,
543,
16121,
29889,
666,
948,
29890,
613,
13,
4706,
1423,
29918,
3084,
537,
29922,
8824,
29892,
13,
1678,
1723,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
4706,
7090,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
4968,
21608,
29922,
3366,
20068,
13,
1678,
7090,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
13,
4706,
2897,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
4968,
13,
4706,
21608,
11759,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
1159,
1402,
13,
1678,
1723,
13,
1678,
4974,
518,
29878,
29889,
20571,
363,
364,
297,
7090,
29889,
1761,
29918,
303,
4063,
29918,
3757,
4339,
580,
29962,
1275,
518,
29896,
29962,
13,
1678,
4974,
518,
29878,
29889,
20571,
363,
364,
297,
7090,
29889,
1761,
29918,
303,
4063,
29918,
348,
4258,
3860,
580,
29962,
1275,
5159,
13,
13,
1678,
7090,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29918,
14057,
292,
29889,
666,
948,
29890,
5783,
13,
1678,
4974,
518,
29878,
29889,
20571,
363,
364,
297,
7090,
29889,
1761,
29918,
303,
4063,
29918,
3757,
4339,
580,
29962,
1275,
518,
29896,
29892,
29871,
29906,
29962,
13,
1678,
4974,
518,
29878,
29889,
20571,
363,
364,
297,
7090,
29889,
1761,
29918,
303,
4063,
29918,
348,
4258,
3860,
580,
29962,
1275,
518,
29906,
29962,
13,
13,
1678,
11846,
353,
7090,
29889,
657,
29918,
303,
4063,
29918,
1333,
19273,
29898,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29918,
14057,
292,
29889,
666,
948,
29890,
5783,
13,
1678,
4974,
11846,
29889,
9877,
29889,
19635,
13,
13,
1678,
7090,
29889,
8551,
29918,
8173,
580,
13,
1678,
4974,
7090,
29889,
1761,
29918,
8173,
29918,
3757,
4339,
580,
1275,
5159,
13,
13,
13,
1753,
1243,
29918,
14634,
29918,
4352,
29918,
8941,
29918,
1333,
19273,
29898,
7050,
29918,
2084,
1125,
13,
1678,
7090,
353,
27441,
25547,
10408,
5160,
29898,
710,
29898,
7050,
29918,
2084,
876,
13,
1678,
7090,
29889,
8173,
29918,
1333,
19273,
29918,
1445,
29898,
13,
4706,
2224,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
4968,
1423,
29918,
3084,
537,
29922,
8824,
13,
1678,
1723,
13,
1678,
302,
29890,
353,
302,
1635,
29889,
949,
29898,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29918,
348,
3389,
29889,
666,
948,
29890,
4968,
29871,
29946,
29897,
13,
1678,
282,
29895,
29892,
19412,
353,
7090,
29889,
14634,
29918,
4352,
29918,
8941,
29918,
1333,
19273,
29898,
9877,
29897,
13,
1678,
4974,
19412,
29889,
3729,
29879,
29961,
29896,
29962,
1275,
426,
13,
4706,
376,
3729,
29918,
1853,
1115,
376,
401,
613,
13,
4706,
376,
22256,
29918,
2798,
1115,
29871,
29906,
29892,
13,
4706,
376,
19635,
1115,
24335,
13,
4706,
376,
4905,
29879,
1115,
518,
6377,
978,
1115,
376,
25393,
613,
376,
4905,
29918,
1853,
1115,
376,
5461,
613,
376,
726,
1115,
376,
29896,
29905,
29876,
9092,
1402,
13,
4706,
376,
4993,
1115,
376,
29874,
29922,
29896,
29905,
29876,
2158,
29898,
29874,
19123,
13,
1678,
500,
13,
13,
13,
1753,
1243,
29918,
8813,
29879,
29898,
7050,
29918,
2084,
1125,
13,
1678,
7090,
353,
27441,
25547,
10408,
5160,
29898,
710,
29898,
7050,
29918,
2084,
876,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
5971,
2392,
1125,
13,
4706,
7090,
29889,
8173,
29918,
1333,
19273,
29918,
1445,
29898,
13,
9651,
2224,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
4968,
13,
9651,
21333,
543,
16121,
29889,
666,
948,
29890,
613,
13,
9651,
24238,
29879,
7607,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
511,
511,
13,
9651,
1423,
29918,
3084,
537,
29922,
8824,
29892,
13,
4706,
1723,
13,
1678,
7090,
29889,
8173,
29918,
1333,
19273,
29918,
1445,
29898,
13,
4706,
2224,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
4968,
13,
4706,
21333,
543,
16121,
29889,
666,
948,
29890,
613,
13,
4706,
24238,
29879,
7607,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
8813,
29918,
12083,
613,
376,
8813,
29889,
3945,
4968,
511,
13,
4706,
1423,
29918,
3084,
537,
29922,
8824,
29892,
13,
1678,
1723,
13,
1678,
6608,
1989,
353,
7090,
29889,
657,
29918,
8173,
29918,
11651,
29898,
29896,
467,
8568,
1989,
13,
1678,
4974,
426,
13,
4706,
851,
29898,
29886,
29889,
22925,
29918,
517,
29898,
7050,
29918,
2084,
876,
363,
282,
297,
13128,
29918,
2084,
29889,
23705,
703,
1068,
5515,
1159,
565,
282,
29889,
275,
29918,
1445,
580,
13,
1678,
500,
1275,
426,
13,
4706,
376,
10945,
29889,
2585,
613,
13,
4706,
285,
29908,
4258,
3860,
19248,
8568,
1989,
6822,
3188,
29889,
666,
948,
29890,
613,
13,
4706,
285,
29908,
4258,
3860,
19248,
8568,
1989,
6822,
8813,
29879,
29914,
8813,
29918,
12083,
29914,
8813,
29889,
3945,
613,
13,
1678,
500,
13,
13,
1678,
11846,
353,
7090,
29889,
657,
29918,
8173,
29918,
16718,
29898,
29896,
29897,
13,
1678,
4974,
426,
710,
29898,
29886,
29897,
363,
282,
297,
11846,
29889,
8813,
29879,
29889,
22925,
29918,
24772,
29913,
1275,
426,
13,
4706,
376,
8813,
29918,
12083,
29914,
8813,
29889,
3945,
29908,
13,
1678,
500,
13,
13,
1678,
1426,
353,
1051,
29898,
29882,
29889,
949,
2141,
13808,
580,
363,
364,
29892,
298,
297,
11846,
29889,
8813,
29879,
9601,
29900,
29962,
13,
1678,
4974,
1426,
29889,
29878,
17010,
580,
1275,
376,
2744,
24238,
29908,
13,
13,
1678,
411,
7090,
29889,
8173,
29918,
11908,
17028,
29879,
29918,
1356,
407,
493,
29898,
29896,
29897,
408,
2224,
29901,
13,
4706,
4974,
2224,
29889,
7122,
2084,
703,
8813,
29918,
12083,
2564,
9933,
580,
13,
13,
13,
29937,
432,
786,
25547,
29918,
4645,
29914,
7924,
29889,
2272,
29901,
29941,
29955,
29896,
29901,
897,
1457,
9252,
22709,
29901,
13,
29937,
16441,
3032,
1989,
29918,
15033,
338,
18164,
297,
22917,
10376,
29901,
671,
732,
711,
16349,
322,
732,
348,
711,
16349,
2012,
13,
29992,
2272,
1688,
29889,
3502,
29889,
4572,
25442,
886,
703,
17281,
1159,
13,
1753,
1243,
29918,
22256,
29898,
7050,
29918,
2084,
1125,
13,
1678,
515,
432,
786,
25547,
29918,
8173,
29889,
4258,
29560,
1053,
2254,
29918,
4258,
3406,
13,
13,
1678,
4833,
353,
27441,
25547,
10408,
5160,
29898,
710,
29898,
7050,
29918,
2084,
876,
13,
1678,
4833,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29918,
348,
3389,
29889,
666,
948,
29890,
5783,
13,
1678,
4833,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29918,
14057,
292,
29889,
666,
948,
29890,
5783,
13,
1678,
4833,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
13,
4706,
2224,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
23176,
29918,
4905,
29889,
666,
948,
29890,
4968,
13,
4706,
21608,
7607,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29889,
666,
948,
29890,
4968,
511,
13,
1678,
1723,
13,
1678,
2279,
3406,
353,
2254,
29918,
4258,
3406,
703,
16121,
613,
4833,
29897,
13,
1678,
1121,
353,
2279,
3406,
29889,
3389,
29918,
392,
29918,
8173,
580,
13,
1678,
1596,
29898,
2914,
29897,
13,
1678,
4974,
1121,
1275,
426,
13,
4706,
376,
29879,
1682,
3947,
287,
1115,
518,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29918,
348,
3389,
29889,
666,
948,
29890,
4968,
13,
9651,
2897,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
23176,
29918,
4905,
29889,
666,
948,
29890,
4968,
13,
4706,
21251,
13,
4706,
376,
19499,
287,
1115,
518,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
16121,
29918,
14057,
292,
29889,
666,
948,
29890,
1159,
1402,
13,
4706,
376,
2704,
287,
1115,
19997,
13,
1678,
500,
13,
1678,
4974,
7431,
29898,
2585,
29889,
1761,
29918,
8173,
29918,
3757,
4339,
3101,
1275,
29871,
29906,
13,
1678,
11846,
353,
4833,
29889,
657,
29918,
8173,
29918,
16718,
29898,
29896,
29897,
13,
1678,
4974,
11846,
29889,
9877,
29889,
3729,
29879,
29961,
29900,
29962,
1275,
426,
13,
4706,
376,
3729,
29918,
1853,
1115,
376,
401,
613,
13,
4706,
376,
22256,
29918,
2798,
1115,
29871,
29896,
29892,
13,
4706,
376,
19635,
1115,
24335,
13,
4706,
376,
4905,
29879,
1115,
518,
6377,
978,
1115,
376,
25393,
613,
376,
4905,
29918,
1853,
1115,
376,
5461,
613,
376,
726,
1115,
376,
29896,
29905,
29876,
9092,
1402,
13,
4706,
376,
4993,
1115,
376,
29874,
29922,
29896,
29905,
29876,
2158,
29898,
29874,
19123,
13,
1678,
500,
13,
1678,
4974,
376,
22256,
29918,
23128,
29908,
297,
11846,
29889,
11651,
29889,
1272,
13,
1678,
411,
4833,
29889,
8173,
29918,
11908,
17028,
29879,
29918,
1356,
407,
493,
29898,
29906,
29897,
408,
2224,
29901,
13,
4706,
10898,
353,
518,
710,
29898,
29886,
29889,
22925,
29918,
517,
29898,
2084,
876,
363,
282,
297,
2224,
29889,
23705,
703,
1068,
5515,
1159,
565,
282,
29889,
275,
29918,
1445,
580,
29962,
13,
4706,
4974,
10898,
1275,
6796,
8813,
29889,
3945,
3108,
13,
4706,
4974,
2224,
29889,
7122,
2084,
703,
8813,
29889,
3945,
2564,
949,
29918,
726,
580,
1275,
376,
2918,
29908,
13,
1678,
7408,
29918,
11651,
353,
4833,
29889,
657,
29918,
303,
4063,
29918,
11651,
29898,
29906,
29897,
13,
1678,
4974,
7408,
29918,
11651,
29889,
15003,
1627,
338,
451,
6213,
13,
1678,
4974,
376,
2451,
29901,
288,
3554,
347,
3850,
297,
7408,
29918,
11651,
29889,
15003,
1627,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
4572,
25442,
886,
703,
17281,
1159,
13,
1753,
1243,
29918,
22256,
29918,
15619,
29918,
2917,
29898,
7050,
29918,
2084,
1125,
13,
1678,
9995,
6987,
278,
11815,
995,
4502,
304,
278,
2279,
3406,
15945,
29908,
13,
1678,
515,
432,
786,
25547,
29918,
8173,
29889,
4258,
29560,
1053,
2254,
29918,
4258,
3406,
13,
13,
1678,
4833,
353,
27441,
25547,
10408,
5160,
29898,
710,
29898,
7050,
29918,
2084,
876,
13,
1678,
4833,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
19676,
29918,
4905,
29879,
29918,
348,
3389,
29889,
666,
948,
29890,
5783,
13,
1678,
2279,
3406,
353,
2254,
29918,
4258,
3406,
703,
16121,
613,
4833,
29897,
13,
1678,
1121,
353,
2279,
3406,
29889,
3389,
29918,
392,
29918,
8173,
29898,
15619,
29922,
29953,
29900,
29897,
13,
1678,
4974,
1121,
1275,
426,
13,
4706,
376,
29879,
1682,
3947,
287,
1115,
518,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
19676,
29918,
4905,
29879,
29918,
348,
3389,
29889,
666,
948,
29890,
1159,
1402,
13,
4706,
376,
19499,
287,
1115,
19997,
13,
4706,
376,
2704,
287,
1115,
19997,
13,
1678,
500,
13,
1678,
4833,
29889,
8551,
29918,
8173,
580,
13,
13,
1678,
4833,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
19676,
29918,
4905,
29879,
29918,
348,
3389,
29889,
666,
948,
29890,
5783,
13,
1678,
2279,
3406,
353,
2254,
29918,
4258,
3406,
703,
16121,
613,
4833,
29897,
13,
1678,
1121,
353,
2279,
3406,
29889,
3389,
29918,
392,
29918,
8173,
29898,
15619,
29922,
29896,
29897,
13,
1678,
4974,
1121,
1275,
426,
13,
4706,
376,
29879,
1682,
3947,
287,
1115,
19997,
13,
4706,
376,
19499,
287,
1115,
518,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
19676,
29918,
4905,
29879,
29918,
348,
3389,
29889,
666,
948,
29890,
1159,
1402,
13,
4706,
376,
2704,
287,
1115,
19997,
13,
1678,
500,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
4572,
25442,
886,
703,
17281,
1159,
13,
1753,
1243,
29918,
22256,
29918,
15619,
29918,
19635,
29898,
7050,
29918,
2084,
1125,
13,
1678,
9995,
6987,
278,
11815,
15562,
1820,
297,
451,
19273,
29879,
15945,
29908,
13,
1678,
515,
432,
786,
25547,
29918,
8173,
29889,
4258,
29560,
1053,
2254,
29918,
4258,
3406,
13,
13,
1678,
4833,
353,
27441,
25547,
10408,
5160,
29898,
710,
29898,
7050,
29918,
2084,
876,
13,
1678,
4833,
29889,
19190,
29918,
1333,
19273,
29918,
1445,
29898,
13,
4706,
2224,
29922,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
19676,
29918,
4905,
29879,
29918,
348,
3389,
29918,
15619,
29889,
666,
948,
29890,
1159,
13,
1678,
1723,
13,
1678,
2279,
3406,
353,
2254,
29918,
4258,
3406,
703,
16121,
613,
4833,
29897,
13,
1678,
1121,
353,
2279,
3406,
29889,
3389,
29918,
392,
29918,
8173,
580,
13,
1678,
4974,
1121,
1275,
426,
13,
4706,
376,
29879,
1682,
3947,
287,
1115,
19997,
13,
4706,
376,
19499,
287,
1115,
518,
359,
29889,
2084,
29889,
7122,
29898,
23189,
29918,
10145,
29892,
376,
19676,
29918,
4905,
29879,
29918,
348,
3389,
29918,
15619,
29889,
666,
948,
29890,
1159,
1402,
13,
4706,
376,
2704,
287,
1115,
19997,
13,
1678,
500,
13,
2
] |
tests/main_test.py | emilianomoscato/stl | 0 | 189336 | import pytest as pytest
from main import select_tasks
from task_selector.taskexceptions import EmptyFileException, \
JSONMissingFieldsExepction
def test_empty_json_list():
assert select_tasks("[]") == "[]"
@pytest.mark.parametrize('json_str,exception', [
(""
, EmptyFileException),
("[{'name': 'A', 'resources': ['1', '2', '3']}]"
, JSONMissingFieldsExepction),
("[{'name': 'A', 'profit': 9.2}]"
, JSONMissingFieldsExepction),
("[{'name': 'A', 'resources': [1], 'profit': 1},"
" {'resources': ['2','3'], 'profit': 1},"
" {'name': 'C', 'resources': ['3','4'], 'profit': 2}]"
, JSONMissingFieldsExepction)
])
def test_missing_json_fields(json_str, exception):
with pytest.raises(exception):
select_tasks(json_str)
@pytest.mark.parametrize('json_str,result', [
("[{'name': 'A', 'resources': ['1', '2', '3'], 'profit': 9.2}]",
"[{'name': 'A', 'resources': ['1', '2', '3'], 'profit': 9.2}]"
),
("[{'name': 'A', 'resources': ['1', '2', '3'], 'profit': 9.2},"
" {'name': 'B', 'resources': ['2'] , 'profit': 0.4},"
" {'name': 'C', 'resources': ['3'] , 'profit': 2.9}]",
"[{'name': 'A', 'resources': ['1', '2', '3'], 'profit': 9.2}]"
),
("[{'name': 'A', 'resources': ['1', '2'], 'profit': 1},"
" {'name': 'B', 'resources': ['2', '3'], 'profit': 1},"
" {'name': 'C', 'resources': ['3', '4'], 'profit': 1}]",
"[{'name': 'A', 'resources': ['1', '2'], 'profit': 1.0},"
" {'name': 'C', 'resources': ['3', '4'], 'profit': 1.0}]"),
("[{'name': 'A', 'resources': [], 'profit': 1},"
" {'name': 'B', 'resources': ['2', '3'], 'profit': 1},"
" {'name': 'C', 'resources': ['3', '4'], 'profit': 2}]",
"[{'name': 'A', 'resources': [], 'profit': 1.0},"
" {'name': 'C', 'resources': ['3', '4'], 'profit': 2.0}]")
])
def test_select_tasks(json_str, result):
assert select_tasks(json_str) == result
| [
1,
1053,
11451,
1688,
408,
11451,
1688,
13,
3166,
1667,
1053,
1831,
29918,
20673,
13,
3166,
3414,
29918,
14357,
29889,
29873,
294,
446,
29916,
1441,
29879,
1053,
2812,
2349,
2283,
2451,
29892,
320,
13,
1678,
4663,
18552,
292,
14256,
1252,
1022,
428,
13,
13,
13,
1753,
1243,
29918,
6310,
29918,
3126,
29918,
1761,
7295,
13,
1678,
4974,
1831,
29918,
20673,
703,
2636,
1159,
1275,
376,
2636,
29908,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
877,
3126,
29918,
710,
29892,
11739,
742,
518,
13,
1678,
4852,
29908,
13,
268,
1919,
2812,
2349,
2283,
2451,
511,
13,
1678,
4852,
29961,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
6024,
29896,
742,
525,
29906,
742,
525,
29941,
2033,
6525,
29908,
13,
268,
1919,
4663,
18552,
292,
14256,
1252,
1022,
428,
511,
13,
1678,
4852,
29961,
10998,
978,
2396,
525,
29909,
742,
525,
771,
9202,
2396,
29871,
29929,
29889,
29906,
6525,
29908,
13,
268,
1919,
4663,
18552,
292,
14256,
1252,
1022,
428,
511,
13,
1678,
4852,
29961,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
518,
29896,
1402,
525,
771,
9202,
2396,
29871,
29896,
1118,
29908,
13,
268,
376,
11117,
13237,
2396,
6024,
29906,
3788,
29941,
7464,
525,
771,
9202,
2396,
29871,
29896,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29907,
742,
525,
13237,
2396,
6024,
29941,
3788,
29946,
7464,
525,
771,
9202,
2396,
29871,
29906,
6525,
29908,
13,
268,
1919,
4663,
18552,
292,
14256,
1252,
1022,
428,
29897,
13,
2314,
13,
1753,
1243,
29918,
27259,
29918,
3126,
29918,
9621,
29898,
3126,
29918,
710,
29892,
3682,
1125,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
11739,
1125,
13,
4706,
1831,
29918,
20673,
29898,
3126,
29918,
710,
29897,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
877,
3126,
29918,
710,
29892,
2914,
742,
518,
13,
1678,
4852,
29961,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
6024,
29896,
742,
525,
29906,
742,
525,
29941,
7464,
525,
771,
9202,
2396,
29871,
29929,
29889,
29906,
6525,
613,
13,
268,
14704,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
6024,
29896,
742,
525,
29906,
742,
525,
29941,
7464,
525,
771,
9202,
2396,
29871,
29929,
29889,
29906,
6525,
29908,
13,
268,
10353,
13,
1678,
4852,
29961,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
6024,
29896,
742,
525,
29906,
742,
525,
29941,
7464,
525,
771,
9202,
2396,
29871,
29929,
29889,
29906,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29933,
742,
525,
13237,
2396,
6024,
29906,
2033,
1919,
525,
771,
9202,
2396,
29871,
29900,
29889,
29946,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29907,
742,
525,
13237,
2396,
6024,
29941,
2033,
1919,
525,
771,
9202,
2396,
29871,
29906,
29889,
29929,
6525,
613,
13,
268,
14704,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
6024,
29896,
742,
525,
29906,
742,
525,
29941,
7464,
525,
771,
9202,
2396,
29871,
29929,
29889,
29906,
6525,
29908,
13,
268,
10353,
13,
1678,
4852,
29961,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
6024,
29896,
742,
525,
29906,
7464,
525,
771,
9202,
2396,
29871,
29896,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29933,
742,
525,
13237,
2396,
6024,
29906,
742,
525,
29941,
7464,
525,
771,
9202,
2396,
29871,
29896,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29907,
742,
525,
13237,
2396,
6024,
29941,
742,
525,
29946,
7464,
525,
771,
9202,
2396,
29871,
29896,
6525,
613,
13,
268,
14704,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
6024,
29896,
742,
525,
29906,
7464,
525,
771,
9202,
2396,
29871,
29896,
29889,
29900,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29907,
742,
525,
13237,
2396,
6024,
29941,
742,
525,
29946,
7464,
525,
771,
9202,
2396,
29871,
29896,
29889,
29900,
6525,
4968,
13,
1678,
4852,
29961,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
19997,
525,
771,
9202,
2396,
29871,
29896,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29933,
742,
525,
13237,
2396,
6024,
29906,
742,
525,
29941,
7464,
525,
771,
9202,
2396,
29871,
29896,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29907,
742,
525,
13237,
2396,
6024,
29941,
742,
525,
29946,
7464,
525,
771,
9202,
2396,
29871,
29906,
6525,
613,
13,
268,
14704,
10998,
978,
2396,
525,
29909,
742,
525,
13237,
2396,
19997,
525,
771,
9202,
2396,
29871,
29896,
29889,
29900,
1118,
29908,
13,
268,
376,
11117,
978,
2396,
525,
29907,
742,
525,
13237,
2396,
6024,
29941,
742,
525,
29946,
7464,
525,
771,
9202,
2396,
29871,
29906,
29889,
29900,
6525,
1159,
13,
2314,
13,
1753,
1243,
29918,
2622,
29918,
20673,
29898,
3126,
29918,
710,
29892,
1121,
1125,
13,
1678,
4974,
1831,
29918,
20673,
29898,
3126,
29918,
710,
29897,
1275,
1121,
13,
2
] |
15-3SUM/solution.py | alfmunny/leetcode | 0 | 36238 | <gh_stars>0
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
if len(nums) < 3:
return []
ans = []
nums.sort()
for i in range(0, len(nums)-2):
if nums[i] > 0:
break
if i > 0 and nums[i-1] == nums[i]:
continue
left, right = i+1, len(nums)-1
while right > left:
s = nums[left] + nums[right] + nums[i]
if s == 0:
ans.append([nums[i], nums[left], nums[right]])
left += 1
right -= 1
while right > left and nums[left] == nums[left-1]:
left += 1
while right > left and nums[right] == nums[right+1]:
right -= 1
elif s < 0:
left += 1
else:
right -= 1
return ans
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
1990,
24380,
29901,
13,
1678,
822,
2211,
11139,
29898,
1311,
29892,
954,
29879,
29901,
2391,
29961,
524,
2314,
1599,
2391,
29961,
1293,
29961,
524,
5262,
29901,
13,
4706,
565,
7431,
29898,
1949,
29879,
29897,
529,
29871,
29941,
29901,
13,
9651,
736,
5159,
13,
4706,
6063,
353,
5159,
13,
4706,
954,
29879,
29889,
6605,
580,
13,
4706,
363,
474,
297,
3464,
29898,
29900,
29892,
7431,
29898,
1949,
29879,
6817,
29906,
1125,
13,
9651,
565,
954,
29879,
29961,
29875,
29962,
1405,
29871,
29900,
29901,
13,
18884,
2867,
13,
9651,
565,
474,
1405,
29871,
29900,
322,
954,
29879,
29961,
29875,
29899,
29896,
29962,
1275,
954,
29879,
29961,
29875,
5387,
13,
18884,
6773,
13,
9651,
2175,
29892,
1492,
353,
474,
29974,
29896,
29892,
7431,
29898,
1949,
29879,
6817,
29896,
13,
13,
9651,
1550,
1492,
1405,
2175,
29901,
13,
18884,
269,
353,
954,
29879,
29961,
1563,
29962,
718,
954,
29879,
29961,
1266,
29962,
718,
954,
29879,
29961,
29875,
29962,
13,
18884,
565,
269,
1275,
29871,
29900,
29901,
13,
462,
1678,
6063,
29889,
4397,
4197,
1949,
29879,
29961,
29875,
1402,
954,
29879,
29961,
1563,
1402,
954,
29879,
29961,
1266,
24960,
13,
462,
1678,
2175,
4619,
29871,
29896,
13,
462,
1678,
1492,
22361,
29871,
29896,
13,
462,
1678,
1550,
1492,
1405,
2175,
322,
954,
29879,
29961,
1563,
29962,
1275,
954,
29879,
29961,
1563,
29899,
29896,
5387,
13,
462,
4706,
2175,
4619,
29871,
29896,
13,
462,
1678,
1550,
1492,
1405,
2175,
322,
954,
29879,
29961,
1266,
29962,
1275,
954,
29879,
29961,
1266,
29974,
29896,
5387,
13,
462,
4706,
1492,
22361,
29871,
29896,
13,
18884,
25342,
269,
529,
29871,
29900,
29901,
13,
462,
1678,
2175,
4619,
29871,
29896,
13,
18884,
1683,
29901,
13,
462,
1678,
1492,
22361,
29871,
29896,
13,
4706,
736,
6063,
13,
2
] |
web/python/flask_api_mysql_pagination/movies_api/app.py | CALlanoR/virtual_environments | 0 | 188535 | <filename>web/python/flask_api_mysql_pagination/movies_api/app.py
from flask import Flask
from flask_cors import CORS, cross_origin
from flask_jwt_extended import (
JWTManager, jwt_required, create_access_token,
get_jwt_identity
)
app = Flask(__name__)
CORS(app) | [
1,
529,
9507,
29958,
2676,
29914,
4691,
29914,
1579,
1278,
29918,
2754,
29918,
7938,
29918,
13573,
3381,
29914,
13529,
583,
29918,
2754,
29914,
932,
29889,
2272,
13,
3166,
29784,
1053,
2379,
1278,
13,
3166,
29784,
29918,
29883,
943,
1053,
315,
24125,
29892,
4891,
29918,
12574,
13,
3166,
29784,
29918,
29926,
14554,
29918,
1062,
2760,
1053,
313,
13,
1678,
435,
17755,
3260,
29892,
432,
14554,
29918,
12403,
29892,
1653,
29918,
5943,
29918,
6979,
29892,
13,
1678,
679,
29918,
29926,
14554,
29918,
22350,
13,
29897,
13,
13,
932,
353,
2379,
1278,
22168,
978,
1649,
29897,
13,
29907,
24125,
29898,
932,
29897,
2
] |
models/three_layers_nn.py | erwanlecarpentier/optimistic-regressor | 0 | 24140 | <gh_stars>0
"""
N layers optimistic neural network
"""
import torch
class ThreeLayersNN(torch.nn.Module):
def __init__(self, in_dim, out_dim, h_dim, activation='relu'):
"""
:param in_dim: (int) input dimension
:param out_dim: (int) output dimension
"""
super(ThreeLayersNN, self).__init__()
self.activation = activation
# Initialize layers
self.h_dim = h_dim
self.linear1 = torch.nn.Linear(in_dim, h_dim[0])
self.linear2 = torch.nn.Linear(h_dim[0], h_dim[1])
self.linear3 = torch.nn.Linear(h_dim[1], out_dim)
def forward(self, x):
if self.activation == 'sigmoid':
h = torch.sigmoid(self.linear1(x))
h = torch.sigmoid(self.linear2(h))
return self.linear3(h)
elif self.activation == 'relu':
h = self.linear1(x).clamp(min=0)
h = self.linear2(h).clamp(min=0)
return self.linear3(h)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
15945,
29908,
13,
29940,
15359,
5994,
4695,
19677,
3564,
13,
15945,
29908,
13,
13,
5215,
4842,
305,
13,
13,
13,
1990,
12753,
29931,
388,
414,
10262,
29898,
7345,
305,
29889,
15755,
29889,
7355,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
297,
29918,
6229,
29892,
714,
29918,
6229,
29892,
298,
29918,
6229,
29892,
26229,
2433,
2674,
29884,
29374,
13,
4706,
9995,
13,
4706,
584,
3207,
297,
29918,
6229,
29901,
313,
524,
29897,
1881,
9927,
13,
4706,
584,
3207,
714,
29918,
6229,
29901,
313,
524,
29897,
1962,
9927,
13,
4706,
9995,
13,
4706,
2428,
29898,
28575,
29931,
388,
414,
10262,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
11236,
362,
353,
26229,
13,
13,
4706,
396,
25455,
15359,
13,
4706,
1583,
29889,
29882,
29918,
6229,
353,
298,
29918,
6229,
13,
4706,
1583,
29889,
10660,
29896,
353,
4842,
305,
29889,
15755,
29889,
12697,
29898,
262,
29918,
6229,
29892,
298,
29918,
6229,
29961,
29900,
2314,
13,
4706,
1583,
29889,
10660,
29906,
353,
4842,
305,
29889,
15755,
29889,
12697,
29898,
29882,
29918,
6229,
29961,
29900,
1402,
298,
29918,
6229,
29961,
29896,
2314,
13,
4706,
1583,
29889,
10660,
29941,
353,
4842,
305,
29889,
15755,
29889,
12697,
29898,
29882,
29918,
6229,
29961,
29896,
1402,
714,
29918,
6229,
29897,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
565,
1583,
29889,
11236,
362,
1275,
525,
18816,
29885,
3398,
2396,
13,
9651,
298,
353,
4842,
305,
29889,
18816,
29885,
3398,
29898,
1311,
29889,
10660,
29896,
29898,
29916,
876,
13,
9651,
298,
353,
4842,
305,
29889,
18816,
29885,
3398,
29898,
1311,
29889,
10660,
29906,
29898,
29882,
876,
13,
9651,
736,
1583,
29889,
10660,
29941,
29898,
29882,
29897,
13,
4706,
25342,
1583,
29889,
11236,
362,
1275,
525,
2674,
29884,
2396,
13,
9651,
298,
353,
1583,
29889,
10660,
29896,
29898,
29916,
467,
695,
1160,
29898,
1195,
29922,
29900,
29897,
13,
9651,
298,
353,
1583,
29889,
10660,
29906,
29898,
29882,
467,
695,
1160,
29898,
1195,
29922,
29900,
29897,
13,
9651,
736,
1583,
29889,
10660,
29941,
29898,
29882,
29897,
13,
2
] |
day13.py | jm-projects/AdventOfCode2021 | 0 | 166793 | from numpy.core.numeric import count_nonzero
import pandas as pd
import numpy as np
import re
data = pd.read_csv("data/day13.csv", header = None, dtype=str, delimiter= '\n')[0]
codes = [re.split("\s\S\S\s", word) for word in data.values][1:]
# Challenge 1
word = np.array(data.values)[0]
c_dic = {c[0]:c[1] for c in codes}
c_dic['0'+word[0]] = ''
c_dic[word[-1]+'0'] = ''
word = '0'+word+'0'
steps = 10
dic = {key:0 for key in c_dic}
for i in range(len(word)-1): dic[word[i]+word[i+1]] += 1
for step in range(steps):
dic2 = {k:val for k, val in dic.items()}
for key in dic:
if key[0] != '0' and key[-1] != '0':
res = c_dic[key]
dic2[key[0]+res] += dic[key]
dic2[res+key[1]] += dic[key]
dic2[key] -= dic[key]
dic = {k:val for k, val in dic2.items()}
occ = {val:0 for k,val in c_dic.items()}
for char in word: occ[char] = 0
for key in dic:
occ[key[0]] += dic[key]
occ[key[1]] += dic[key]
out = np.sort([val for k,val in occ.items()])
print((out[-1]-out[2])//2)
# Challenge 2
word = np.array(data.values)[0]
c_dic = {c[0]:c[1] for c in codes}
c_dic['0'+word[0]] = ''
c_dic[word[-1]+'0'] = ''
word = '0'+word+'0'
steps = 40
dic = {key:0 for key in c_dic}
for i in range(len(word)-1): dic[word[i]+word[i+1]] += 1
for step in range(steps):
dic2 = {k:val for k, val in dic.items()}
for key in dic:
if key[0] != '0' and key[-1] != '0':
res = c_dic[key]
dic2[key[0]+res] += dic[key]
dic2[res+key[1]] += dic[key]
dic2[key] -= dic[key]
dic = {k:val for k, val in dic2.items()}
occ = {val:0 for k,val in c_dic.items()}
for char in word: occ[char] = 0
for key in dic:
occ[key[0]] += dic[key]
occ[key[1]] += dic[key]
out = np.sort([val for k,val in occ.items()])
print((out[-1]-out[2])//2) | [
1,
515,
12655,
29889,
3221,
29889,
21574,
1053,
2302,
29918,
5464,
9171,
13,
5215,
11701,
408,
10518,
13,
5215,
12655,
408,
7442,
13,
5215,
337,
13,
13,
1272,
353,
10518,
29889,
949,
29918,
7638,
703,
1272,
29914,
3250,
29896,
29941,
29889,
7638,
613,
4839,
353,
6213,
29892,
26688,
29922,
710,
29892,
28552,
29922,
11297,
29876,
29861,
29900,
29962,
13,
18137,
353,
518,
276,
29889,
5451,
14182,
29879,
29905,
29903,
29905,
29903,
29905,
29879,
613,
1734,
29897,
363,
1734,
297,
848,
29889,
5975,
3816,
29896,
17531,
13,
13,
29937,
27211,
29871,
29896,
13,
1742,
353,
7442,
29889,
2378,
29898,
1272,
29889,
5975,
9601,
29900,
29962,
13,
29883,
29918,
27774,
353,
426,
29883,
29961,
29900,
5387,
29883,
29961,
29896,
29962,
363,
274,
297,
11561,
29913,
13,
29883,
29918,
27774,
1839,
29900,
18717,
1742,
29961,
29900,
5262,
353,
6629,
13,
29883,
29918,
27774,
29961,
1742,
14352,
29896,
10062,
29915,
29900,
2033,
353,
6629,
13,
1742,
353,
525,
29900,
18717,
1742,
23097,
29900,
29915,
13,
13,
13,
24530,
353,
29871,
29896,
29900,
13,
27774,
353,
426,
1989,
29901,
29900,
363,
1820,
297,
274,
29918,
27774,
29913,
13,
1454,
474,
297,
3464,
29898,
2435,
29898,
1742,
6817,
29896,
1125,
12124,
29961,
1742,
29961,
29875,
10062,
1742,
29961,
29875,
29974,
29896,
5262,
4619,
29871,
29896,
13,
13,
1454,
4331,
297,
3464,
29898,
24530,
1125,
13,
1678,
12124,
29906,
353,
426,
29895,
29901,
791,
363,
413,
29892,
659,
297,
12124,
29889,
7076,
28296,
13,
1678,
363,
1820,
297,
12124,
29901,
13,
4706,
565,
1820,
29961,
29900,
29962,
2804,
525,
29900,
29915,
322,
1820,
14352,
29896,
29962,
2804,
525,
29900,
2396,
13,
9651,
620,
353,
274,
29918,
27774,
29961,
1989,
29962,
13,
9651,
12124,
29906,
29961,
1989,
29961,
29900,
10062,
690,
29962,
4619,
12124,
29961,
1989,
29962,
13,
9651,
12124,
29906,
29961,
690,
29974,
1989,
29961,
29896,
5262,
4619,
12124,
29961,
1989,
29962,
13,
9651,
12124,
29906,
29961,
1989,
29962,
22361,
12124,
29961,
1989,
29962,
13,
1678,
12124,
353,
426,
29895,
29901,
791,
363,
413,
29892,
659,
297,
12124,
29906,
29889,
7076,
28296,
13,
13,
15693,
353,
426,
791,
29901,
29900,
363,
413,
29892,
791,
297,
274,
29918,
27774,
29889,
7076,
28296,
13,
1454,
1373,
297,
1734,
29901,
2179,
29961,
3090,
29962,
353,
29871,
29900,
13,
13,
1454,
1820,
297,
12124,
29901,
13,
1678,
2179,
29961,
1989,
29961,
29900,
5262,
4619,
12124,
29961,
1989,
29962,
13,
1678,
2179,
29961,
1989,
29961,
29896,
5262,
4619,
12124,
29961,
1989,
29962,
13,
449,
353,
7442,
29889,
6605,
4197,
791,
363,
413,
29892,
791,
297,
2179,
29889,
7076,
580,
2314,
13,
13,
2158,
3552,
449,
14352,
29896,
29962,
29899,
449,
29961,
29906,
2314,
458,
29906,
29897,
13,
13,
13,
29937,
27211,
29871,
29906,
13,
1742,
353,
7442,
29889,
2378,
29898,
1272,
29889,
5975,
9601,
29900,
29962,
13,
29883,
29918,
27774,
353,
426,
29883,
29961,
29900,
5387,
29883,
29961,
29896,
29962,
363,
274,
297,
11561,
29913,
13,
29883,
29918,
27774,
1839,
29900,
18717,
1742,
29961,
29900,
5262,
353,
6629,
13,
29883,
29918,
27774,
29961,
1742,
14352,
29896,
10062,
29915,
29900,
2033,
353,
6629,
13,
1742,
353,
525,
29900,
18717,
1742,
23097,
29900,
29915,
13,
13,
24530,
353,
29871,
29946,
29900,
13,
27774,
353,
426,
1989,
29901,
29900,
363,
1820,
297,
274,
29918,
27774,
29913,
13,
1454,
474,
297,
3464,
29898,
2435,
29898,
1742,
6817,
29896,
1125,
12124,
29961,
1742,
29961,
29875,
10062,
1742,
29961,
29875,
29974,
29896,
5262,
4619,
29871,
29896,
13,
13,
1454,
4331,
297,
3464,
29898,
24530,
1125,
13,
1678,
12124,
29906,
353,
426,
29895,
29901,
791,
363,
413,
29892,
659,
297,
12124,
29889,
7076,
28296,
13,
1678,
363,
1820,
297,
12124,
29901,
13,
4706,
565,
1820,
29961,
29900,
29962,
2804,
525,
29900,
29915,
322,
1820,
14352,
29896,
29962,
2804,
525,
29900,
2396,
13,
9651,
620,
353,
274,
29918,
27774,
29961,
1989,
29962,
13,
9651,
12124,
29906,
29961,
1989,
29961,
29900,
10062,
690,
29962,
4619,
12124,
29961,
1989,
29962,
13,
9651,
12124,
29906,
29961,
690,
29974,
1989,
29961,
29896,
5262,
4619,
12124,
29961,
1989,
29962,
13,
9651,
12124,
29906,
29961,
1989,
29962,
22361,
12124,
29961,
1989,
29962,
13,
1678,
12124,
353,
426,
29895,
29901,
791,
363,
413,
29892,
659,
297,
12124,
29906,
29889,
7076,
28296,
13,
13,
15693,
353,
426,
791,
29901,
29900,
363,
413,
29892,
791,
297,
274,
29918,
27774,
29889,
7076,
28296,
13,
1454,
1373,
297,
1734,
29901,
2179,
29961,
3090,
29962,
353,
29871,
29900,
13,
13,
1454,
1820,
297,
12124,
29901,
13,
1678,
2179,
29961,
1989,
29961,
29900,
5262,
4619,
12124,
29961,
1989,
29962,
13,
1678,
2179,
29961,
1989,
29961,
29896,
5262,
4619,
12124,
29961,
1989,
29962,
13,
449,
353,
7442,
29889,
6605,
4197,
791,
363,
413,
29892,
791,
297,
2179,
29889,
7076,
580,
2314,
13,
13,
2158,
3552,
449,
14352,
29896,
29962,
29899,
449,
29961,
29906,
2314,
458,
29906,
29897,
2
] |
timbr/machine/base_machine.py | timbr-io/timbr-python | 2 | 187294 | <reponame>timbr-io/timbr-python<gh_stars>1-10
from __future__ import print_function
from multiprocessing.pool import ThreadPool
import dask as da
# NOTE: sync mode wil likely be faster
# from dask.async import get_sync as get
from dask.threaded import get
_pool = ThreadPool()
da.set_options(pool=_pool)
try:
from Queue import Empty, Full, Queue # Python 2
except ImportError:
from queue import Empty, Full, Queue # Python 3
from bson.objectid import ObjectId
from functools import wraps, partial # should be used but isn't currently
from collections import defaultdict, deque
import inspect
import zmq
import json
from .util import identity, wrap_transform, json_serializable_exception
from .profiler import MachineProfiler
from .exception import UpstreamError
from .display import Display
from .dashboard import Dashboard
def json_serialize(obj):
try:
return json.dumps(obj)
except TypeError as te:
return json.dumps(json_serializable_exception(te))
def time_from_objectidstr(oid):
return ObjectId(oid).generation_time.isoformat()
def is_serialization_task(task):
if task[-2:] == "_s":
return True
return False
class BaseMachine(object):
def __init__(self, stages=8, bufsize=1024):
self.q = Queue(bufsize)
self.tbl = {}
self._status = {"last_oid": None, "processed": 0, "errored": 0, "queue_size": self.q.qsize()}
self.stages = stages
self._dsk = None
self._dirty = True
self._getter = partial(get, num_workers=1)
self.serialize_fn = json_serialize
self.REFERENCE_DASK = {
"oid_s": (str, "oid"),
"in_s": (self.serialize_fn, "in")
}
self.REFERENCE_DASK.update({"f{}_s".format(i): (self.serialize_fn, "f{}".format(i)) for i in xrange(self.stages)})
def put(self, msg):
# NOTE: Non-blocking
self.q.put(msg, False)
def get(self, block=False, timeout=0.5):
dsk = dict(self.dsk)
dsk["in"] = (self.q.get, block, timeout)
output = self._getter(dsk, ["oid_s", "in_s"] + ["f{}_s".format(i) for i in xrange(self.stages)])
return output
def display_status(self, interval=1):
self._display = Display(self, interval=interval)
def dashboard(self):
self._dashboard = Dashboard(self)
@property
def status(self):
self._status["last_processed_time"] = time_from_objectidstr(self._status["last_oid"])
self._status["queue_size"] = self.q.qsize()
return self._status
def __len__(self):
return self.stages
def __setitem__(self, pos, fn):
assert isinstance(pos, (int, long))
assert pos >=0 and pos < self.stages
wrapped_fn = wrap_transform(fn)
self.tbl["f{}".format(pos)] = wrapped_fn
self.dirty = True
def __getitem__(self, pos):
assert isinstance(pos, (int, long))
assert pos >=0 and pos < self.stages
return self.tbl["f{}".format(pos)]
def __missing__(self, pos):
return wrap_transform(identity)
def __delitem__(self, pos):
assert isinstance(pos, (int, long))
assert pos >=0 and pos < self.stages
del self.tbl["f{}".format(pos)]
self.dirty = True
def __call__(self, data, include_serialized=False):
dsk = dict(self.dsk)
dsk["in"] = data
args = ["oid", "in"] + ["f{}".format(i) for i in xrange(self.stages)]
if include_serialized:
args.extend(["oid_s", "in_s"] + ["f{}_s".format(i) for i in xrange(self.stages)])
output = self._getter(dsk, args)
return output
@property
def dsk(self):
if self._dsk is None or self.dirty:
self._dsk = {}
self._dsk["oid"] = (ObjectId,)
for i in xrange(self.stages):
fkey = "f{}".format(i)
cmd = [self.tbl.get(fkey, wrap_transform(identity))]
cmd.extend(["f{}".format(j) for j in reversed(xrange(i)) if i > 0])
cmd.append("in")
cmd.extend(["f{}_s".format(j) for j in reversed(xrange(i)) if i > 0])
cmd.append("in_s")
self._dsk[fkey] = tuple(cmd)
self._dsk.update(self.REFERENCE_DASK)
self.dirty = False
return self._dsk
def format_status(self):
stats = self.status
hmap = {k: " ".join(k.split("_")).upper() for k in stats.keys()}
s = ""
for h in sorted(stats.keys()):
s += "{:<5} --- {:<5}\n\n".format(hmap[h], stats[h])
return s
def print_status(self):
print(self.format_status())
| [
1,
529,
276,
1112,
420,
29958,
9346,
1182,
29899,
601,
29914,
9346,
1182,
29899,
4691,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
13,
3166,
6674,
307,
985,
292,
29889,
10109,
1053,
10480,
11426,
13,
5215,
270,
1278,
408,
1146,
13,
29937,
6058,
29923,
29901,
16523,
4464,
28292,
5517,
367,
8473,
13,
29937,
515,
270,
1278,
29889,
12674,
1053,
679,
29918,
16593,
408,
679,
13,
3166,
270,
1278,
29889,
7097,
287,
1053,
679,
13,
13,
29918,
10109,
353,
10480,
11426,
580,
13,
1388,
29889,
842,
29918,
6768,
29898,
10109,
29922,
29918,
10109,
29897,
13,
13,
2202,
29901,
13,
1678,
515,
5462,
434,
1053,
2812,
2349,
29892,
14846,
29892,
5462,
434,
396,
5132,
29871,
29906,
13,
19499,
16032,
2392,
29901,
13,
1678,
515,
9521,
1053,
2812,
2349,
29892,
14846,
29892,
5462,
434,
396,
5132,
29871,
29941,
13,
13,
3166,
289,
1100,
29889,
3318,
333,
1053,
4669,
1204,
13,
3166,
2090,
312,
8789,
1053,
11463,
567,
29892,
7687,
396,
881,
367,
1304,
541,
3508,
29915,
29873,
5279,
13,
3166,
16250,
1053,
2322,
8977,
29892,
316,
802,
13,
5215,
16096,
13,
13,
5215,
12162,
29939,
13,
5215,
4390,
13,
13,
3166,
869,
4422,
1053,
10110,
29892,
12244,
29918,
9067,
29892,
4390,
29918,
15550,
13902,
29918,
11739,
13,
3166,
869,
771,
1777,
261,
1053,
6189,
1184,
1777,
261,
13,
3166,
869,
11739,
1053,
5020,
5461,
2392,
13,
13,
3166,
869,
4990,
1053,
17440,
13,
3166,
869,
14592,
3377,
1053,
360,
1161,
3377,
13,
13,
1753,
4390,
29918,
643,
6646,
29898,
5415,
1125,
13,
1678,
1018,
29901,
13,
4706,
736,
4390,
29889,
29881,
17204,
29898,
5415,
29897,
13,
1678,
5174,
20948,
408,
734,
29901,
13,
4706,
736,
4390,
29889,
29881,
17204,
29898,
3126,
29918,
15550,
13902,
29918,
11739,
29898,
371,
876,
13,
13,
1753,
931,
29918,
3166,
29918,
3318,
333,
710,
29898,
3398,
1125,
13,
1678,
736,
4669,
1204,
29898,
3398,
467,
4738,
362,
29918,
2230,
29889,
10718,
4830,
580,
13,
13,
1753,
338,
29918,
15550,
2133,
29918,
7662,
29898,
7662,
1125,
13,
1678,
565,
3414,
14352,
29906,
17531,
1275,
11119,
29879,
1115,
13,
4706,
736,
5852,
13,
1678,
736,
7700,
13,
13,
13,
1990,
7399,
29076,
29898,
3318,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
22950,
29922,
29947,
29892,
18392,
2311,
29922,
29896,
29900,
29906,
29946,
1125,
13,
4706,
1583,
29889,
29939,
353,
5462,
434,
29898,
9721,
2311,
29897,
13,
4706,
1583,
29889,
16400,
353,
6571,
13,
4706,
1583,
3032,
4882,
353,
8853,
4230,
29918,
3398,
1115,
6213,
29892,
376,
5014,
287,
1115,
29871,
29900,
29892,
376,
2704,
287,
1115,
29871,
29900,
29892,
376,
9990,
29918,
2311,
1115,
1583,
29889,
29939,
29889,
29939,
2311,
28296,
13,
4706,
1583,
29889,
303,
1179,
353,
22950,
13,
4706,
1583,
3032,
29881,
808,
353,
6213,
13,
4706,
1583,
3032,
3972,
1017,
353,
5852,
13,
4706,
1583,
3032,
657,
357,
353,
7687,
29898,
657,
29892,
954,
29918,
1287,
414,
29922,
29896,
29897,
13,
13,
4706,
1583,
29889,
643,
6646,
29918,
9144,
353,
4390,
29918,
643,
6646,
13,
13,
4706,
1583,
29889,
25866,
1001,
1430,
4741,
29918,
29928,
3289,
29968,
353,
426,
13,
9651,
376,
3398,
29918,
29879,
1115,
313,
710,
29892,
376,
3398,
4968,
13,
9651,
376,
262,
29918,
29879,
1115,
313,
1311,
29889,
643,
6646,
29918,
9144,
29892,
376,
262,
1159,
13,
4706,
500,
13,
4706,
1583,
29889,
25866,
1001,
1430,
4741,
29918,
29928,
3289,
29968,
29889,
5504,
3319,
29908,
29888,
29912,
2403,
29879,
1642,
4830,
29898,
29875,
1125,
313,
1311,
29889,
643,
6646,
29918,
9144,
29892,
376,
29888,
8875,
1642,
4830,
29898,
29875,
876,
363,
474,
297,
921,
3881,
29898,
1311,
29889,
303,
1179,
26972,
13,
13,
1678,
822,
1925,
29898,
1311,
29892,
10191,
1125,
13,
4706,
396,
6058,
29923,
29901,
10050,
29899,
1271,
292,
13,
4706,
1583,
29889,
29939,
29889,
649,
29898,
7645,
29892,
7700,
29897,
13,
13,
1678,
822,
679,
29898,
1311,
29892,
2908,
29922,
8824,
29892,
11815,
29922,
29900,
29889,
29945,
1125,
13,
4706,
270,
808,
353,
9657,
29898,
1311,
29889,
29881,
808,
29897,
13,
4706,
270,
808,
3366,
262,
3108,
353,
313,
1311,
29889,
29939,
29889,
657,
29892,
2908,
29892,
11815,
29897,
13,
4706,
1962,
353,
1583,
3032,
657,
357,
29898,
29881,
808,
29892,
6796,
3398,
29918,
29879,
613,
376,
262,
29918,
29879,
3108,
718,
6796,
29888,
29912,
2403,
29879,
1642,
4830,
29898,
29875,
29897,
363,
474,
297,
921,
3881,
29898,
1311,
29889,
303,
1179,
29897,
2314,
13,
4706,
736,
1962,
13,
13,
1678,
822,
2479,
29918,
4882,
29898,
1311,
29892,
7292,
29922,
29896,
1125,
13,
4706,
1583,
3032,
4990,
353,
17440,
29898,
1311,
29892,
7292,
29922,
19207,
29897,
13,
13,
1678,
822,
12569,
3377,
29898,
1311,
1125,
13,
4706,
1583,
3032,
14592,
3377,
353,
360,
1161,
3377,
29898,
1311,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
4660,
29898,
1311,
1125,
13,
4706,
1583,
3032,
4882,
3366,
4230,
29918,
5014,
287,
29918,
2230,
3108,
353,
931,
29918,
3166,
29918,
3318,
333,
710,
29898,
1311,
3032,
4882,
3366,
4230,
29918,
3398,
20068,
13,
4706,
1583,
3032,
4882,
3366,
9990,
29918,
2311,
3108,
353,
1583,
29889,
29939,
29889,
29939,
2311,
580,
13,
4706,
736,
1583,
3032,
4882,
13,
13,
1678,
822,
4770,
2435,
12035,
1311,
1125,
13,
4706,
736,
1583,
29889,
303,
1179,
13,
13,
1678,
822,
4770,
842,
667,
12035,
1311,
29892,
926,
29892,
7876,
1125,
13,
4706,
4974,
338,
8758,
29898,
1066,
29892,
313,
524,
29892,
1472,
876,
13,
4706,
4974,
926,
6736,
29900,
322,
926,
529,
1583,
29889,
303,
1179,
13,
4706,
21021,
29918,
9144,
353,
12244,
29918,
9067,
29898,
9144,
29897,
13,
4706,
1583,
29889,
16400,
3366,
29888,
8875,
1642,
4830,
29898,
1066,
4638,
353,
21021,
29918,
9144,
13,
4706,
1583,
29889,
3972,
1017,
353,
5852,
13,
13,
1678,
822,
4770,
657,
667,
12035,
1311,
29892,
926,
1125,
13,
4706,
4974,
338,
8758,
29898,
1066,
29892,
313,
524,
29892,
1472,
876,
13,
4706,
4974,
926,
6736,
29900,
322,
926,
529,
1583,
29889,
303,
1179,
13,
4706,
736,
1583,
29889,
16400,
3366,
29888,
8875,
1642,
4830,
29898,
1066,
4638,
13,
13,
1678,
822,
4770,
27259,
12035,
1311,
29892,
926,
1125,
13,
4706,
736,
12244,
29918,
9067,
29898,
22350,
29897,
13,
13,
1678,
822,
4770,
6144,
667,
12035,
1311,
29892,
926,
1125,
13,
4706,
4974,
338,
8758,
29898,
1066,
29892,
313,
524,
29892,
1472,
876,
13,
4706,
4974,
926,
6736,
29900,
322,
926,
529,
1583,
29889,
303,
1179,
13,
4706,
628,
1583,
29889,
16400,
3366,
29888,
8875,
1642,
4830,
29898,
1066,
4638,
13,
4706,
1583,
29889,
3972,
1017,
353,
5852,
13,
13,
1678,
822,
4770,
4804,
12035,
1311,
29892,
848,
29892,
3160,
29918,
15550,
1891,
29922,
8824,
1125,
13,
4706,
270,
808,
353,
9657,
29898,
1311,
29889,
29881,
808,
29897,
13,
4706,
270,
808,
3366,
262,
3108,
353,
848,
13,
4706,
6389,
353,
6796,
3398,
613,
376,
262,
3108,
718,
6796,
29888,
8875,
1642,
4830,
29898,
29875,
29897,
363,
474,
297,
921,
3881,
29898,
1311,
29889,
303,
1179,
4638,
13,
4706,
565,
3160,
29918,
15550,
1891,
29901,
13,
9651,
6389,
29889,
21843,
29898,
3366,
3398,
29918,
29879,
613,
376,
262,
29918,
29879,
3108,
718,
6796,
29888,
29912,
2403,
29879,
1642,
4830,
29898,
29875,
29897,
363,
474,
297,
921,
3881,
29898,
1311,
29889,
303,
1179,
29897,
2314,
13,
13,
4706,
1962,
353,
1583,
3032,
657,
357,
29898,
29881,
808,
29892,
6389,
29897,
13,
4706,
736,
1962,
13,
13,
1678,
732,
6799,
13,
1678,
822,
270,
808,
29898,
1311,
1125,
13,
4706,
565,
1583,
3032,
29881,
808,
338,
6213,
470,
1583,
29889,
3972,
1017,
29901,
13,
9651,
1583,
3032,
29881,
808,
353,
6571,
13,
9651,
1583,
3032,
29881,
808,
3366,
3398,
3108,
353,
313,
2061,
1204,
29892,
29897,
13,
9651,
363,
474,
297,
921,
3881,
29898,
1311,
29889,
303,
1179,
1125,
13,
18884,
285,
1989,
353,
376,
29888,
8875,
1642,
4830,
29898,
29875,
29897,
13,
18884,
9920,
353,
518,
1311,
29889,
16400,
29889,
657,
29898,
29888,
1989,
29892,
12244,
29918,
9067,
29898,
22350,
28166,
13,
18884,
9920,
29889,
21843,
29898,
3366,
29888,
8875,
1642,
4830,
29898,
29926,
29897,
363,
432,
297,
18764,
287,
29898,
29916,
3881,
29898,
29875,
876,
565,
474,
1405,
29871,
29900,
2314,
13,
18884,
9920,
29889,
4397,
703,
262,
1159,
13,
18884,
9920,
29889,
21843,
29898,
3366,
29888,
29912,
2403,
29879,
1642,
4830,
29898,
29926,
29897,
363,
432,
297,
18764,
287,
29898,
29916,
3881,
29898,
29875,
876,
565,
474,
1405,
29871,
29900,
2314,
13,
18884,
9920,
29889,
4397,
703,
262,
29918,
29879,
1159,
13,
18884,
1583,
3032,
29881,
808,
29961,
29888,
1989,
29962,
353,
18761,
29898,
9006,
29897,
13,
9651,
1583,
3032,
29881,
808,
29889,
5504,
29898,
1311,
29889,
25866,
1001,
1430,
4741,
29918,
29928,
3289,
29968,
29897,
13,
9651,
1583,
29889,
3972,
1017,
353,
7700,
13,
4706,
736,
1583,
3032,
29881,
808,
13,
13,
1678,
822,
3402,
29918,
4882,
29898,
1311,
1125,
13,
4706,
22663,
353,
1583,
29889,
4882,
13,
4706,
298,
1958,
353,
426,
29895,
29901,
376,
11393,
7122,
29898,
29895,
29889,
5451,
703,
29918,
1159,
467,
21064,
580,
363,
413,
297,
22663,
29889,
8149,
28296,
13,
4706,
269,
353,
5124,
13,
4706,
363,
298,
297,
12705,
29898,
16202,
29889,
8149,
580,
1125,
13,
9651,
269,
4619,
376,
25641,
29966,
29945,
29913,
11474,
12365,
29966,
29945,
1012,
29876,
29905,
29876,
1642,
4830,
29898,
29882,
1958,
29961,
29882,
1402,
22663,
29961,
29882,
2314,
13,
4706,
736,
269,
13,
13,
1678,
822,
1596,
29918,
4882,
29898,
1311,
1125,
13,
4706,
1596,
29898,
1311,
29889,
4830,
29918,
4882,
3101,
268,
13,
2
] |
apps/organization/urls.py | stormsha/StormOnline | 18 | 1922 | # _*_ coding: utf-8 _*_
# ---------------------------
__author__ = 'StormSha'
__date__ = '2018/3/28 18:01'
# ---------------------------
# -------------------------django----------------------
from django.conf.urls import url
from .views import OrgView, AddUserAskView, OrgHomeView, OrgCourseView, OrgDescView, OrgTeacherView, AddFavView
from .views import TeacherListView, TeacherDetailView
urlpatterns = [
url(r'^list/$', OrgView.as_view(), name="org_list"),
url(r'^add_ask/$', AddUserAskView.as_view(), name="add_ask"),
url(r'^home/(?P<org_id>\d+)/$', OrgHomeView.as_view(), name="org_home"),
url(r'^course/(?P<org_id>\d+)/$', OrgCourseView.as_view(), name="org_course"),
url(r'^desc/(?P<org_id>\d+)/$', OrgDescView.as_view(), name="org_desc"),
url(r'^org_teacher/(?P<org_id>\d+)/$', OrgTeacherView.as_view(), name="org_teacher"),
# --------------机构收藏-------------------------
url(r'^add_fav/$', AddFavView.as_view(), name="add_fav"),
# -----------------------teacher------------------------------
url(r'^teacher/list/$', TeacherListView.as_view(), name="teacher_list"),
url(r'^teacher/detail/(?P<teacher_id>\d+)/$', TeacherDetailView.as_view(), name="teacher_detail")
] | [
1,
396,
903,
29930,
29918,
14137,
29901,
23616,
29899,
29947,
903,
29930,
29918,
13,
29937,
448,
2683,
28400,
13,
1649,
8921,
1649,
353,
525,
855,
555,
29903,
2350,
29915,
13,
1649,
1256,
1649,
353,
525,
29906,
29900,
29896,
29947,
29914,
29941,
29914,
29906,
29947,
29871,
29896,
29947,
29901,
29900,
29896,
29915,
13,
29937,
448,
2683,
28400,
13,
13,
29937,
448,
2683,
1378,
14095,
2683,
22158,
13,
3166,
9557,
29889,
5527,
29889,
26045,
1053,
3142,
13,
3166,
869,
7406,
1053,
1394,
29887,
1043,
29892,
3462,
2659,
29909,
808,
1043,
29892,
1394,
29887,
11184,
1043,
29892,
1394,
29887,
29907,
10242,
1043,
29892,
1394,
29887,
19617,
1043,
29892,
1394,
29887,
29911,
4204,
261,
1043,
29892,
3462,
29943,
485,
1043,
13,
3166,
869,
7406,
1053,
1920,
11665,
15660,
29892,
1920,
11665,
16570,
1043,
13,
13,
2271,
11037,
29879,
353,
518,
13,
1678,
3142,
29898,
29878,
29915,
29985,
1761,
13346,
742,
1394,
29887,
1043,
29889,
294,
29918,
1493,
3285,
1024,
543,
990,
29918,
1761,
4968,
13,
1678,
3142,
29898,
29878,
29915,
29985,
1202,
29918,
1278,
13346,
742,
3462,
2659,
29909,
808,
1043,
29889,
294,
29918,
1493,
3285,
1024,
543,
1202,
29918,
1278,
4968,
13,
1678,
3142,
29898,
29878,
29915,
29985,
5184,
29914,
10780,
29925,
29966,
990,
29918,
333,
14247,
29881,
29974,
6802,
29938,
742,
1394,
29887,
11184,
1043,
29889,
294,
29918,
1493,
3285,
1024,
543,
990,
29918,
5184,
4968,
13,
1678,
3142,
29898,
29878,
29915,
29985,
15775,
29914,
10780,
29925,
29966,
990,
29918,
333,
14247,
29881,
29974,
6802,
29938,
742,
1394,
29887,
29907,
10242,
1043,
29889,
294,
29918,
1493,
3285,
1024,
543,
990,
29918,
15775,
4968,
13,
1678,
3142,
29898,
29878,
29915,
29985,
14273,
29914,
10780,
29925,
29966,
990,
29918,
333,
14247,
29881,
29974,
6802,
29938,
742,
1394,
29887,
19617,
1043,
29889,
294,
29918,
1493,
3285,
1024,
543,
990,
29918,
14273,
4968,
13,
1678,
3142,
29898,
29878,
29915,
29985,
990,
29918,
371,
11665,
29914,
10780,
29925,
29966,
990,
29918,
333,
14247,
29881,
29974,
6802,
29938,
742,
1394,
29887,
29911,
4204,
261,
1043,
29889,
294,
29918,
1493,
3285,
1024,
543,
990,
29918,
371,
11665,
4968,
13,
13,
1678,
396,
448,
9072,
29899,
31429,
31901,
31997,
31707,
2683,
1378,
29899,
13,
1678,
3142,
29898,
29878,
29915,
29985,
1202,
29918,
29888,
485,
13346,
742,
3462,
29943,
485,
1043,
29889,
294,
29918,
1493,
3285,
1024,
543,
1202,
29918,
29888,
485,
4968,
13,
1678,
396,
448,
2683,
22158,
371,
11665,
2683,
9072,
489,
13,
1678,
3142,
29898,
29878,
29915,
29985,
371,
11665,
29914,
1761,
13346,
742,
1920,
11665,
15660,
29889,
294,
29918,
1493,
3285,
1024,
543,
371,
11665,
29918,
1761,
4968,
13,
1678,
3142,
29898,
29878,
29915,
29985,
371,
11665,
29914,
16432,
29914,
10780,
29925,
29966,
371,
11665,
29918,
333,
14247,
29881,
29974,
6802,
29938,
742,
1920,
11665,
16570,
1043,
29889,
294,
29918,
1493,
3285,
1024,
543,
371,
11665,
29918,
16432,
1159,
13,
29962,
2
] |
gen_phone.py | jfsantos/ift6266h14 | 8 | 198605 | import cPickle as pickle
import numpy as np
import theano
_mean = 0.0035805809921434142
_std = 542.48824133746177
def gen_phone(mdl, phones, noise_level):
terr_monitor = mdl.monitor.channels['test_objective']
terr = min(terr_monitor.val_record)
X = theano.tensor.dmatrix('X')
P = theano.tensor.dmatrix('P')
y = mdl.fprop([X,P])
predict = theano.function([X, P], y)
# Let's start with a all zero vector, then use the prediction to populate the next sample
duration = 3
fs = 16000
frame_length = mdl.input_space.components[0].dim
x0 = np.asmatrix(np.zeros((1,duration*fs)))
# phones = np.load('test_phones.npy')
phone_code = np.asmatrix(np.zeros((duration*fs,3*62)))
for pi, p in enumerate(phones):
phone_code[pi,[p, p+62, p+2*62]] = 1 # code for 'aw'
for k in np.arange(frame_length,duration*fs):
frame = x0[:,k-frame_length:k]
x0[0,k] = np.random.normal(predict(frame + np.random.normal(0, noise_level[0]*np.sqrt(terr), frame.shape), phone_code[k]), noise_level[1]*np.sqrt(terr))
x0 = x0.T
x0_scaled = x0*_std + _mean
x0a = np.asarray(x0_scaled, dtype=np.int16)
return x0a
if __name__ == "__main__":
from sys import argv
from scipy.io import wavfile
mdl = pickle.load(open(argv[1]))
x0a = gen_phone(mdl)
wavfile.write(argv[2], 16000, x0a)
| [
1,
1053,
274,
29925,
860,
280,
408,
5839,
280,
13,
5215,
12655,
408,
7442,
13,
5215,
278,
1562,
13,
13,
29918,
12676,
353,
29871,
29900,
29889,
29900,
29900,
29941,
29945,
29947,
29900,
29945,
29947,
29900,
29929,
29929,
29906,
29896,
29946,
29941,
29946,
29896,
29946,
29906,
13,
29918,
4172,
353,
29871,
29945,
29946,
29906,
29889,
29946,
29947,
29947,
29906,
29946,
29896,
29941,
29941,
29955,
29946,
29953,
29896,
29955,
29955,
13,
13,
1753,
2531,
29918,
6710,
29898,
3487,
29880,
29892,
1374,
2873,
29892,
11462,
29918,
5563,
1125,
13,
1678,
1935,
29878,
29918,
3712,
2105,
353,
286,
11671,
29889,
3712,
2105,
29889,
305,
12629,
1839,
1688,
29918,
3318,
573,
2033,
13,
1678,
1935,
29878,
353,
1375,
29898,
357,
29878,
29918,
3712,
2105,
29889,
791,
29918,
11651,
29897,
13,
13,
1678,
1060,
353,
278,
1562,
29889,
20158,
29889,
29881,
5344,
877,
29990,
1495,
13,
1678,
349,
353,
278,
1562,
29889,
20158,
29889,
29881,
5344,
877,
29925,
1495,
13,
1678,
343,
353,
286,
11671,
29889,
29888,
7728,
4197,
29990,
29892,
29925,
2314,
13,
1678,
8500,
353,
278,
1562,
29889,
2220,
4197,
29990,
29892,
349,
1402,
343,
29897,
13,
13,
1678,
396,
2803,
29915,
29879,
1369,
411,
263,
599,
5225,
4608,
29892,
769,
671,
278,
18988,
304,
19450,
278,
2446,
4559,
13,
1678,
14385,
353,
29871,
29941,
13,
1678,
18920,
353,
29871,
29896,
29953,
29900,
29900,
29900,
13,
1678,
3515,
29918,
2848,
353,
286,
11671,
29889,
2080,
29918,
3493,
29889,
14036,
29961,
29900,
1822,
6229,
13,
13,
1678,
921,
29900,
353,
7442,
29889,
294,
5344,
29898,
9302,
29889,
3298,
359,
3552,
29896,
29892,
19708,
29930,
5847,
4961,
13,
1678,
396,
1374,
2873,
353,
7442,
29889,
1359,
877,
1688,
29918,
561,
2873,
29889,
29876,
2272,
1495,
13,
1678,
9008,
29918,
401,
353,
7442,
29889,
294,
5344,
29898,
9302,
29889,
3298,
359,
3552,
19708,
29930,
5847,
29892,
29941,
29930,
29953,
29906,
4961,
13,
13,
1678,
363,
2930,
29892,
282,
297,
26985,
29898,
561,
2873,
1125,
13,
4706,
9008,
29918,
401,
29961,
1631,
17094,
29886,
29892,
282,
29974,
29953,
29906,
29892,
282,
29974,
29906,
29930,
29953,
29906,
5262,
353,
29871,
29896,
396,
775,
363,
525,
1450,
29915,
13,
13,
1678,
363,
413,
297,
7442,
29889,
279,
927,
29898,
2557,
29918,
2848,
29892,
19708,
29930,
5847,
1125,
13,
4706,
3515,
353,
921,
29900,
7503,
29892,
29895,
29899,
2557,
29918,
2848,
29901,
29895,
29962,
13,
4706,
921,
29900,
29961,
29900,
29892,
29895,
29962,
353,
7442,
29889,
8172,
29889,
8945,
29898,
27711,
29898,
2557,
718,
7442,
29889,
8172,
29889,
8945,
29898,
29900,
29892,
11462,
29918,
5563,
29961,
29900,
14178,
9302,
29889,
3676,
29898,
357,
29878,
511,
3515,
29889,
12181,
511,
9008,
29918,
401,
29961,
29895,
11724,
11462,
29918,
5563,
29961,
29896,
14178,
9302,
29889,
3676,
29898,
357,
29878,
876,
13,
13,
1678,
921,
29900,
353,
921,
29900,
29889,
29911,
13,
1678,
921,
29900,
29918,
7052,
29881,
353,
921,
29900,
29930,
29918,
4172,
718,
903,
12676,
13,
13,
1678,
921,
29900,
29874,
353,
7442,
29889,
294,
2378,
29898,
29916,
29900,
29918,
7052,
29881,
29892,
26688,
29922,
9302,
29889,
524,
29896,
29953,
29897,
13,
1678,
736,
921,
29900,
29874,
13,
632,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
515,
10876,
1053,
1852,
29894,
13,
1678,
515,
4560,
2272,
29889,
601,
1053,
281,
485,
1445,
13,
1678,
286,
11671,
353,
5839,
280,
29889,
1359,
29898,
3150,
29898,
19218,
29961,
29896,
12622,
13,
1678,
921,
29900,
29874,
353,
2531,
29918,
6710,
29898,
3487,
29880,
29897,
13,
1678,
281,
485,
1445,
29889,
3539,
29898,
19218,
29961,
29906,
1402,
29871,
29896,
29953,
29900,
29900,
29900,
29892,
921,
29900,
29874,
29897,
13,
2
] |
aldryn_redirects/middleware.py | chaosk/aldryn-redirects | 1 | 1617895 | from __future__ import unicode_literals
from django import http
from django.conf import settings
from django.contrib.sites.models import Site
from django.db.models import Q
from .models import Redirect, StaticRedirect
class RedirectFallbackMiddleware(object):
def process_request(self, request):
static_redirect = StaticRedirect.objects.get_for_request(request)
if static_redirect:
full_domain = '{}://{}'.format(request.scheme, Site.objects.get(id=settings.SITE_ID).domain)
return http.HttpResponsePermanentRedirect(static_redirect.get_outbound_url(full_domain))
path = request.path_info
path_with_queries = request.get_full_path()
queries = (
Q(old_path__iexact=path)
| Q(old_path__iexact=path_with_queries)
)
if settings.APPEND_SLASH and path.endswith('/'):
path_with_queries_no_slash = path[:-1] + path_with_queries[len(path):]
queries |= (
Q(old_path__iexact=path[:-1])
| Q(old_path__iexact=path_with_queries_no_slash)
)
try:
r = Redirect.objects.filter(
queries,
site__id__exact=settings.SITE_ID
).distinct().get()
except Redirect.DoesNotExist:
return
new_path = r.safe_translation_getter('new_path', any_language=True)
if new_path in (None, ''):
return http.HttpResponseGone()
return http.HttpResponsePermanentRedirect(new_path)
| [
1,
515,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
3166,
9557,
1053,
1732,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
21570,
29889,
16315,
29889,
9794,
1053,
10781,
13,
3166,
9557,
29889,
2585,
29889,
9794,
1053,
660,
13,
13,
3166,
869,
9794,
1053,
4367,
1088,
29892,
624,
2454,
24735,
13,
13,
13,
1990,
4367,
1088,
29943,
497,
1627,
25411,
2519,
29898,
3318,
1125,
13,
1678,
822,
1889,
29918,
3827,
29898,
1311,
29892,
2009,
1125,
13,
4706,
2294,
29918,
17886,
353,
624,
2454,
24735,
29889,
12650,
29889,
657,
29918,
1454,
29918,
3827,
29898,
3827,
29897,
13,
4706,
565,
2294,
29918,
17886,
29901,
13,
9651,
2989,
29918,
7247,
353,
525,
8875,
597,
8875,
4286,
4830,
29898,
3827,
29889,
816,
2004,
29892,
10781,
29889,
12650,
29889,
657,
29898,
333,
29922,
11027,
29889,
29903,
9094,
29918,
1367,
467,
7247,
29897,
13,
9651,
736,
1732,
29889,
5506,
5103,
29925,
3504,
296,
24735,
29898,
7959,
29918,
17886,
29889,
657,
29918,
449,
9917,
29918,
2271,
29898,
8159,
29918,
7247,
876,
13,
13,
4706,
2224,
353,
2009,
29889,
2084,
29918,
3888,
13,
4706,
2224,
29918,
2541,
29918,
339,
6358,
353,
2009,
29889,
657,
29918,
8159,
29918,
2084,
580,
13,
4706,
9365,
353,
313,
13,
9651,
660,
29898,
1025,
29918,
2084,
1649,
347,
29916,
627,
29922,
2084,
29897,
13,
9651,
891,
660,
29898,
1025,
29918,
2084,
1649,
347,
29916,
627,
29922,
2084,
29918,
2541,
29918,
339,
6358,
29897,
13,
4706,
1723,
13,
13,
4706,
565,
6055,
29889,
20576,
11794,
29918,
12750,
24943,
322,
2224,
29889,
1975,
2541,
11219,
29374,
13,
9651,
2224,
29918,
2541,
29918,
339,
6358,
29918,
1217,
29918,
17057,
353,
2224,
7503,
29899,
29896,
29962,
718,
2224,
29918,
2541,
29918,
339,
6358,
29961,
2435,
29898,
2084,
1125,
29962,
13,
9651,
9365,
891,
29922,
313,
13,
18884,
660,
29898,
1025,
29918,
2084,
1649,
347,
29916,
627,
29922,
2084,
7503,
29899,
29896,
2314,
13,
18884,
891,
660,
29898,
1025,
29918,
2084,
1649,
347,
29916,
627,
29922,
2084,
29918,
2541,
29918,
339,
6358,
29918,
1217,
29918,
17057,
29897,
13,
9651,
1723,
13,
13,
4706,
1018,
29901,
13,
9651,
364,
353,
4367,
1088,
29889,
12650,
29889,
4572,
29898,
13,
18884,
9365,
29892,
13,
18884,
3268,
1649,
333,
1649,
735,
627,
29922,
11027,
29889,
29903,
9094,
29918,
1367,
13,
9651,
13742,
5721,
5562,
2141,
657,
580,
13,
4706,
5174,
4367,
1088,
29889,
25125,
3664,
1252,
391,
29901,
13,
9651,
736,
13,
13,
4706,
716,
29918,
2084,
353,
364,
29889,
11177,
29918,
3286,
18411,
29918,
657,
357,
877,
1482,
29918,
2084,
742,
738,
29918,
11675,
29922,
5574,
29897,
13,
13,
4706,
565,
716,
29918,
2084,
297,
313,
8516,
29892,
6629,
1125,
13,
9651,
736,
1732,
29889,
5506,
5103,
29954,
650,
580,
13,
4706,
736,
1732,
29889,
5506,
5103,
29925,
3504,
296,
24735,
29898,
1482,
29918,
2084,
29897,
13,
2
] |
magmap/cv/colocalizer.py | kaparna126/magellanmapper | 10 | 165376 | <reponame>kaparna126/magellanmapper<gh_stars>1-10
# Object colocalization
# Copyright The MagellanMapper Contributors
"""Colocalize objects in an image, typically in separate channels."""
from enum import Enum
import multiprocessing as mp
import pandas as pd
import numpy as np
from skimage import morphology
from magmap.cv import chunking, detector, stack_detect, verifier
from magmap.io import cli, df_io, libmag, sqlite
from magmap.settings import config
class BlobMatch:
"""Blob match storage class as a wrapper for a data frame of matches.
Attributes:
df (:class:`pandas.DataFrame`): Data frame of matches with column
names given by :class:`BlobMatch.Cols`.
"""
class Cols(Enum):
"""Blob match column names."""
MATCH_ID = "MatchID"
ROI_ID = "RoiID"
BLOB1_ID = "Blob1ID"
BLOB1 = "Blob1"
BLOB2_ID = "Blob2ID"
BLOB2 = "Blob2"
DIST = "Distance"
def __init__(self, matches=None, match_id=None, roi_id=None, blob1_id=None,
blob2_id=None, df=None):
"""Initialize blob match object.
Args:
matches (list[list[
:class:`numpy.ndarray`, :class:`numpy.ndarray`, float]]:
List of blob match lists, which each contain,
``blob1, blob2, distance``. Defaults to None, which
sets the data frame to None.
match_id (Sequence[int]): Sequence of match IDs, which should be
of the same length as ``matches``; defaults to None.
roi_id (Sequence[int]): Sequence of ROI IDs, which should be
of the same length as ``matches``; defaults to None.
blob1_id (Sequence[int]): Sequence of blob 1 IDs, which should be
of the same length as ``matches``; defaults to None.
blob2_id (Sequence[int]): Sequence of blob2 IDs, which should be
of the same length as ``matches``; defaults to None.
df (:class:`pandas.DataFrame`): Pandas data frame to set in
place of any other arguments; defaults to None.
"""
if df is not None:
# set data frame directly and ignore any other arguments
self.df = df
return
if matches is None:
# set data frame to None and return since any other arguments
# must correspond to matches
self.df = None
return
matches_dict = {}
for i, match in enumerate(matches):
# assumes that all first sequences are of the same length
vals = {
BlobMatch.Cols.BLOB1: match[0],
BlobMatch.Cols.BLOB2: match[1],
BlobMatch.Cols.DIST: match[2],
}
if match_id is not None:
vals[BlobMatch.Cols.MATCH_ID] = match_id[i]
if roi_id is not None:
vals[BlobMatch.Cols.ROI_ID] = roi_id[i]
if blob1_id is not None:
vals[BlobMatch.Cols.BLOB1_ID] = blob1_id[i]
if blob2_id is not None:
vals[BlobMatch.Cols.BLOB2_ID] = blob2_id[i]
for key in BlobMatch.Cols:
matches_dict.setdefault(key, []).append(
vals[key] if key in vals else None)
self.df = df_io.dict_to_data_frame(matches_dict)
def __repr__(self):
"""Format the underlying data frame."""
if self.df is None:
return "Empty blob matches"
return df_io.print_data_frame(self.df, show=False)
def get_blobs(self, n):
"""Get blobs as a numpy array.
Args:
n (int): 1 for blob1, otherwise blob 2.
Returns:
:class:`numpy.ndarray`: Numpy array of the given blob type, or
None if the :attr:`df` is None or the blob column does not exist.
"""
col = BlobMatch.Cols.BLOB1 if n == 1 else BlobMatch.Cols.BLOB2
if self.df is None or col.value not in self.df:
return None
return np.vstack(self.df[col.value])
def get_blobs_all(self):
"""Get all blobs in the blob matches.
Returns:
tuple[:class:`numpy.ndarray`, :class:`numpy.ndarray`]:
Tuple of ``(blobs1, blobs2)``, or None if either are None.
"""
blobs_all = []
for n in (1, 2):
blobs = self.get_blobs(n)
if blobs is None:
return None
blobs_all.append(blobs)
return blobs_all
def update_blobs(self, fn, *args):
"""Update all blobs with the given function.
Args:
fn (func): Function that accepts the output of :meth:`get_blobs`
separately for each set of blobs.
*args (Any): Additional arguments to ``fn``.
"""
if self.df is None: return
for i, col in enumerate((BlobMatch.Cols.BLOB1, BlobMatch.Cols.BLOB2)):
blobs = self.get_blobs(i + 1)
if blobs is not None:
self.df[col.value] = fn(blobs, *args).tolist()
class StackColocalizer(object):
"""Colocalize blobs in blocks based on matching blobs across channels.
Support shared memory for spawned multiprocessing, with fallback to
pickling in forked multiprocessing.
"""
blobs = None
match_tol = None
@classmethod
def colocalize_block(cls, coord, offset, shape, blobs=None,
tol=None, setup_cli=False):
"""Colocalize blobs from different channels within a block.
Args:
coord (Tuple[int]): Block coordinate.
offset (List[int]): Block offset within the full image in z,y,x.
shape (List[int]): Block shape in z,y,x.
blobs (:obj:`np.ndarray`): 2D blobs array; defaults to None to
use :attr:`blobs`.
tol (List[float]): Tolerance for colocalizing blobs; defaults
to None to use :attr:`match_tol`.
setup_cli (bool): True to set up CLI arguments, typically for
a spawned (rather than forked) environment; defaults to False.
Returns:
Tuple[int], dict[Tuple[int], Tuple]: ``coord`` for tracking
multiprocessing and the dictionary of matches.
"""
if blobs is None:
blobs = cls.blobs
if tol is None:
tol = cls.match_tol
if setup_cli:
# reload command-line parameters
cli.process_cli_args()
matches = colocalize_blobs_match(blobs, offset[::-1], shape[::-1], tol)
return coord, matches
@classmethod
def colocalize_stack(cls, shape, blobs):
"""Entry point to colocalizing blobs within a stack.
Args:
shape (List[int]): Image shape in z,y,x.
blobs (:obj:`np.ndarray`): 2D Numpy array of blobs.
Returns:
dict[tuple[int, int], :class:`BlobMatch`]: The
dictionary of matches, where keys are tuples of the channel pairs,
and values are blob match objects.
"""
print("Colocalizing blobs based on matching blobs in each pair of "
"channels")
# set up ROI blocks from which to select blobs in each block
sub_roi_slices, sub_rois_offsets, _, _, _, overlap_base, _, _ \
= stack_detect.setup_blocks(config.roi_profile, shape)
match_tol = np.multiply(
overlap_base, config.roi_profile["verify_tol_factor"])
is_fork = chunking.is_fork()
if is_fork:
# set shared data in forked multiprocessing
cls.blobs = blobs
cls.match_tol = match_tol
pool = mp.Pool(processes=config.cpus)
pool_results = []
for z in range(sub_roi_slices.shape[0]):
for y in range(sub_roi_slices.shape[1]):
for x in range(sub_roi_slices.shape[2]):
coord = (z, y, x)
offset = sub_rois_offsets[coord]
slices = sub_roi_slices[coord]
shape = [s.stop - s.start for s in slices]
if is_fork:
# use variables stored as class attributes
pool_results.append(pool.apply_async(
StackColocalizer.colocalize_block,
args=(coord, offset, shape)))
else:
# pickle full set of variables
pool_results.append(pool.apply_async(
StackColocalizer.colocalize_block,
args=(coord, offset, shape,
detector.get_blobs_in_roi(
blobs, offset, shape)[0], match_tol,
True)))
# dict of channel combos to blob matches data frame
matches_all = {}
for result in pool_results:
coord, matches = result.get()
count = 0
for key, val in matches.items():
matches_all.setdefault(key, []).append(val.df)
count += len(val.df)
print("adding {} matches from block at {} of {}"
.format(count, coord, np.add(sub_roi_slices.shape, -1)))
pool.close()
pool.join()
# prune duplicates by taking matches with shortest distance
for key in matches_all.keys():
matches_all[key] = pd.concat(matches_all[key])
for blobi in (BlobMatch.Cols.BLOB1, BlobMatch.Cols.BLOB2):
# convert blob column to ndarray to extract coords by column
matches = matches_all[key]
matches_uniq, matches_i, matches_inv, matches_cts = np.unique(
np.vstack(matches[blobi.value])[:, :3], axis=0,
return_index=True, return_inverse=True, return_counts=True)
if np.sum(matches_cts > 1) > 0:
# prune if at least one blob has been matched to multiple
# other blobs
singles = matches.iloc[matches_i[matches_cts == 1]]
dups = []
for i, ct in enumerate(matches_cts):
# include non-duplicates to retain index
if ct <= 1: continue
# get indices in orig matches at given unique array
# index and take match with lowest dist
matches_mult = matches.loc[matches_inv == i]
dists = matches_mult[BlobMatch.Cols.DIST.value]
min_dist = np.amin(dists)
num_matches = len(matches_mult)
if config.verbose and num_matches > 1:
print("pruning from", num_matches,
"matches of dist:", dists)
matches_mult = matches_mult.loc[dists == min_dist]
# take first in case of any ties
dups.append(matches_mult.iloc[[0]])
matches_all[key] = pd.concat((singles, pd.concat(dups)))
print("Colocalization matches for channels {}: {}"
.format(key, len(matches_all[key])))
libmag.printv(print(matches_all[key]))
# store data frame in BlobMatch object
matches_all[key] = BlobMatch(df=matches_all[key])
return matches_all
def colocalize_blobs(roi, blobs, thresh=None):
"""Co-localize blobs from different channels based on surrounding
intensities.
Thresholds for detection are first identified in each channel by taking
the blobs in the given channel, finding the surrounding intensities,
and taking a low (5th) percentile. Then for each channel, the
surrounding intensities of blobs in that channel are compared with
the thresholds in the other channels. Blobs exceeding any given
threshold are considered to co-localize in that channel.
Args:
roi (:obj:`np.ndarray`): Region of interest as a 3D+channel array.
blobs (:obj:`np.ndarray`): Blobs as a 2D array in the format
``[[z, y, x, radius, confirmation, truth, channel...], ...]``.
thresh (int, float, str): Threshold percentile of intensities from
pixels surrounding each blob in the given channel. Use "min"
to instead take the mininimum average intensity of all blobs
in the channel. Defaults to None to use "min".
Returns:
:obj:`np.ndarray`: 2D Numpy array of same length as ``blobs`` with
a column for each channel where 1 indicates that the corresponding
blob has signal is present in the given channels at the blob's
location, and 0 indicates insufficient signal.
"""
if blobs is None or roi is None or len(roi.shape) < 4:
return None
if thresh is None:
thresh = "min"
print("Colocalizing blobs based on image intensity across channels")
threshs = []
selem = morphology.ball(2)
# find only blobs in ROI since blobs list may include blobs from immediate
# surrounds, but ROI is not available for them
blobs_roi, blobs_roi_mask = detector.get_blobs_in_roi(
blobs, (0, 0, 0), roi.shape[:3], reverse=False)
blobs_chl = detector.get_blobs_channel(blobs_roi)
blobs_range_chls = []
# get labeled masks of blobs for each channel and threshold intensities
mask_roi = np.ones(roi.shape[:3], dtype=int)
mask_roi_chls = []
for chl in range(roi.shape[3]):
# label a mask with blob indices surrounding each blob
blobs_chl_mask = np.isin(blobs_chl, chl)
blobs_range = np.where(blobs_chl_mask)[0]
blobs_range_chls.append(blobs_range)
mask = np.copy(mask_roi) * -1
mask[tuple(libmag.coords_for_indexing(
blobs_roi[blobs_chl_mask, :3].astype(int)))] = blobs_range
mask = morphology.dilation(mask, selem=selem)
mask_roi_chls.append(mask)
if thresh == "min":
# set minimum average surrounding intensity of all blobs as thresh
threshs.append(
None if len(blobs_range) == 0 else np.amin([
np.mean(roi[mask == b, chl]) for b in blobs_range]))
else:
# set a percentile of intensities surrounding all blobs in channel
# as threshold for that channel, or the whole ROI if no blobs
mask_blobs = mask >= 0
roi_mask = roi if np.sum(mask_blobs) < 1 else roi[mask_blobs, chl]
threshs.append(np.percentile(roi_mask, thresh))
channels = np.unique(detector.get_blobs_channel(blobs_roi)).astype(int)
colocs_roi = np.zeros((blobs_roi.shape[0], roi.shape[3]), dtype=np.uint8)
for chl in channels:
# get labeled mask of blobs in the given channel
mask = mask_roi_chls[chl]
blobs_range = blobs_range_chls[chl]
for chl_other in channels:
if threshs[chl_other] is None: continue
for blobi in blobs_range:
# find surrounding intensity of blob in another channel
mask_blob = mask == blobi
blob_avg = np.mean(roi[mask_blob, chl_other])
if config.verbose:
print(blobi, detector.get_blob_channel(blobs_roi[blobi]),
blobs_roi[blobi, :3], blob_avg, threshs[chl_other])
if blob_avg >= threshs[chl_other]:
# intensities in another channel around blob's position
# is above that channel's threshold
colocs_roi[blobi, chl_other] = 1
# create array for all blobs including those outside ROI
colocs = np.zeros((blobs.shape[0], roi.shape[3]), dtype=np.uint8)
colocs[blobs_roi_mask] = colocs_roi
if config.verbose:
for i, (blob, coloc) in enumerate(zip(blobs_roi, colocs)):
print(i, detector.get_blob_channel(blob), blob[:3], coloc)
return colocs
def colocalize_blobs_match(blobs, offset, size, tol, inner_padding=None):
"""Co-localize blobs in separate channels but the same ROI by finding
optimal blob matches.
Args:
blobs (:obj:`np.ndarray`): Blobs from separate channels.
offset (List[int]): ROI offset given as x,y,z.
size (List[int]): ROI shape given as x,y,z.
tol (List[float]): Tolerances for matching given as x,y,z
inner_padding (List[int]): ROI padding given as x,y,z; defaults
to None to use the padding based on ``tol``.
Returns:
dict[tuple[int, int], :class:`BlobMatch`]:
Dictionary where keys are tuples of the two channels compared and
values are blob matches objects.
"""
if blobs is None:
return None
thresh, scaling, inner_pad, resize, blobs = verifier.setup_match_blobs_roi(
blobs, tol)
if inner_padding is None:
inner_padding = inner_pad
matches_chls = {}
channels = np.unique(detector.get_blobs_channel(blobs)).astype(int)
for chl in channels:
# pair channels
blobs_chl = detector.blobs_in_channel(blobs, chl)
for chl_other in channels:
# prevent duplicates by skipping other channels below given channel
if chl >= chl_other: continue
# find colocalizations between blobs from one channel to blobs
# in another channel
blobs_chl_other = detector.blobs_in_channel(blobs, chl_other)
blobs_inner_plus, blobs_truth_inner_plus, offset_inner, \
size_inner, matches = verifier.match_blobs_roi(
blobs_chl_other, blobs_chl, offset, size, thresh, scaling,
inner_padding, resize)
# reset truth and confirmation blob flags in matches
chl_combo = (chl, chl_other)
matches.update_blobs(detector.set_blob_truth, -1)
matches.update_blobs(detector.set_blob_confirmed, -1)
matches_chls[chl_combo] = matches
return matches_chls
def _get_roi_id(db, offset, shape, exp_name=None):
"""Get database ROI ID for the given ROI position within the main image5d.
Args:
db (:obj:`sqlite.ClrDB`): Database object.
offset (List[int]): ROI offset in z,y,x.
shape (List[int]): ROI shape in z,y,x.
exp_name (str): Name of experiment; defaults to None to attempt
discovery through any image loaded to :attr:`config.img5d`.
Returns:
int: ROI ID or found or inserted ROI.
"""
if exp_name is None:
exp_name = sqlite.get_exp_name(
config.img5d.path_img if config.img5d else None)
exp_id = sqlite.select_or_insert_experiment(
db.conn, db.cur, exp_name, None)
roi_id = sqlite.select_or_insert_roi(
db.conn, db.cur, exp_id, config.series, offset, shape)[0]
return roi_id
def insert_matches(db, matches):
"""Insert matches into database for a whole image.
Args:
db (:obj:`sqlite.ClrDB`): Database object.
matches (dict[tuple[int, int], :class:`BlobMatch`):
Dictionary of channel combo tuples to blob match objects.
"""
# use size of 0 for each dimension for whole-image ROI, which avoids
# the need to discover the image size
roi_id = _get_roi_id(db, (0, 0, 0), (0, 0, 0))
for chl_matches in matches.values():
# insert blobs and matches for the given channel combo
blobs = chl_matches.get_blobs_all()
if blobs is not None:
sqlite.insert_blobs(db.conn, db.cur, roi_id, np.vstack(blobs))
config.db.insert_blob_matches(roi_id, chl_matches)
def select_matches(db, channels, offset=None, shape=None, exp_name=None):
"""Select blob matches for the given region from a database.
Blob matches are assumed to have been processed from the whole image.
To retrieve matches from a selected ROI, use
:meth:`magmap.io.sqlite.ClrDB.select_blob_matches` instead.
Args:
db (:obj:`sqlite.ClrDB`): Database object.
channels (list[int]): List of channels.
offset (list[int]): ROI offset in z,y,x; defaults to None to use
``(0, 0, 0)``.
shape (list[int]): ROI shape in z,y,x; defaults to None to use
``(0, 0, 0)``.
exp_name (str): Name of experiment in ``db``.
Returns:
dict[tuple[int, int], list[:obj:`BlobMatch`]: Dictionary where
keys are tuples of the two channels compared and values are a list
of blob matches. None if no blob matches are found.
"""
# get ROI for whole image
roi_id = _get_roi_id(db, (0, 0, 0), (0, 0, 0), exp_name)
if offset is not None and shape is not None:
# get blob from matches within ROI
blobs, blob_ids = db.select_blobs_by_position(
roi_id, offset[::-1], shape[::-1])
else:
# get blobs from matches within the whole image
blobs, blob_ids = db.select_blobs_by_roi(roi_id)
if blobs is None or len(blobs) == 0:
print("No blob matches found")
return None
blob_ids = np.array(blob_ids)
matches = {}
for chl in channels:
# pair channels
for chl_other in channels:
if chl >= chl_other: continue
# select matches for blobs in the given first channel of the pair
# of channels, assuming chls were paired this way during insertion
chl_matches = db.select_blob_matches_by_blob_id(
roi_id, 1,
blob_ids[detector.get_blobs_channel(blobs) == chl])
blobs2 = chl_matches.get_blobs(2)
if blobs2 is not None:
chl_matches = chl_matches.df.loc[detector.get_blobs_channel(
blobs2) == chl_other]
matches[(chl, chl_other)] = BlobMatch(df=chl_matches)
return matches
| [
1,
529,
276,
1112,
420,
29958,
21474,
11441,
29896,
29906,
29953,
29914,
11082,
18663,
655,
2496,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
29937,
4669,
784,
18642,
2133,
13,
29937,
14187,
1266,
450,
3561,
18663,
19968,
2866,
1091,
29560,
13,
15945,
29908,
1625,
18642,
675,
3618,
297,
385,
1967,
29892,
12234,
297,
5004,
18196,
1213,
15945,
13,
13,
3166,
14115,
1053,
1174,
398,
13,
5215,
6674,
307,
985,
292,
408,
22326,
13,
13,
5215,
11701,
408,
10518,
13,
5215,
12655,
408,
7442,
13,
3166,
2071,
3027,
1053,
18131,
3002,
13,
13,
3166,
2320,
1958,
29889,
11023,
1053,
19875,
292,
29892,
1439,
3019,
29892,
5096,
29918,
4801,
522,
29892,
1147,
3709,
13,
3166,
2320,
1958,
29889,
601,
1053,
9335,
29892,
4489,
29918,
601,
29892,
4303,
11082,
29892,
21120,
13,
3166,
2320,
1958,
29889,
11027,
1053,
2295,
13,
13,
13,
1990,
350,
2127,
9652,
29901,
13,
1678,
9995,
29933,
2127,
1993,
8635,
770,
408,
263,
14476,
363,
263,
848,
3515,
310,
7087,
29889,
13,
13,
1678,
6212,
5026,
29901,
13,
4706,
4489,
13940,
1990,
18078,
15112,
29889,
17271,
29952,
1125,
3630,
3515,
310,
7087,
411,
1897,
13,
9651,
2983,
2183,
491,
584,
1990,
18078,
29933,
2127,
9652,
29889,
1625,
29879,
1412,
13,
13,
1678,
9995,
13,
268,
13,
1678,
770,
1530,
29879,
29898,
16854,
1125,
13,
4706,
9995,
29933,
2127,
1993,
1897,
2983,
1213,
15945,
13,
4706,
341,
14789,
29918,
1367,
353,
376,
9652,
1367,
29908,
13,
4706,
16641,
29902,
29918,
1367,
353,
376,
29934,
7768,
1367,
29908,
13,
4706,
350,
28902,
29896,
29918,
1367,
353,
376,
29933,
2127,
29896,
1367,
29908,
13,
4706,
350,
28902,
29896,
353,
376,
29933,
2127,
29896,
29908,
13,
4706,
350,
28902,
29906,
29918,
1367,
353,
376,
29933,
2127,
29906,
1367,
29908,
13,
4706,
350,
28902,
29906,
353,
376,
29933,
2127,
29906,
29908,
13,
4706,
360,
9047,
353,
376,
27469,
29908,
13,
268,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
7087,
29922,
8516,
29892,
1993,
29918,
333,
29922,
8516,
29892,
14100,
29918,
333,
29922,
8516,
29892,
23755,
29896,
29918,
333,
29922,
8516,
29892,
13,
462,
23755,
29906,
29918,
333,
29922,
8516,
29892,
4489,
29922,
8516,
1125,
13,
4706,
9995,
6644,
6646,
23755,
1993,
1203,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
7087,
313,
1761,
29961,
1761,
29961,
13,
18884,
584,
1990,
18078,
23749,
29889,
299,
2378,
1673,
584,
1990,
18078,
23749,
29889,
299,
2378,
1673,
5785,
5262,
29901,
13,
18884,
2391,
310,
23755,
1993,
8857,
29892,
607,
1269,
1712,
29892,
13,
18884,
4954,
10054,
29896,
29892,
23755,
29906,
29892,
5418,
29952,
1412,
13109,
29879,
304,
6213,
29892,
607,
13,
18884,
6166,
278,
848,
3515,
304,
6213,
29889,
13,
9651,
1993,
29918,
333,
313,
20529,
29961,
524,
29962,
1125,
922,
3910,
310,
1993,
23481,
29892,
607,
881,
367,
13,
18884,
310,
278,
1021,
3309,
408,
4954,
20317,
16159,
29936,
21274,
304,
6213,
29889,
13,
9651,
14100,
29918,
333,
313,
20529,
29961,
524,
29962,
1125,
922,
3910,
310,
16641,
29902,
23481,
29892,
607,
881,
367,
13,
18884,
310,
278,
1021,
3309,
408,
4954,
20317,
16159,
29936,
21274,
304,
6213,
29889,
13,
9651,
23755,
29896,
29918,
333,
313,
20529,
29961,
524,
29962,
1125,
922,
3910,
310,
23755,
29871,
29896,
23481,
29892,
607,
881,
367,
13,
18884,
310,
278,
1021,
3309,
408,
4954,
20317,
16159,
29936,
21274,
304,
6213,
29889,
13,
9651,
23755,
29906,
29918,
333,
313,
20529,
29961,
524,
29962,
1125,
922,
3910,
310,
23755,
29906,
23481,
29892,
607,
881,
367,
13,
18884,
310,
278,
1021,
3309,
408,
4954,
20317,
16159,
29936,
21274,
304,
6213,
29889,
13,
9651,
4489,
13940,
1990,
18078,
15112,
29889,
17271,
29952,
1125,
349,
7086,
848,
3515,
304,
731,
297,
13,
18884,
2058,
310,
738,
916,
6273,
29936,
21274,
304,
6213,
29889,
13,
4706,
9995,
13,
4706,
565,
4489,
338,
451,
6213,
29901,
13,
9651,
396,
731,
848,
3515,
4153,
322,
11455,
738,
916,
6273,
13,
9651,
1583,
29889,
2176,
353,
4489,
13,
9651,
736,
13,
4706,
565,
7087,
338,
6213,
29901,
13,
9651,
396,
731,
848,
3515,
304,
6213,
322,
736,
1951,
738,
916,
6273,
13,
9651,
396,
1818,
3928,
304,
7087,
13,
9651,
1583,
29889,
2176,
353,
6213,
13,
9651,
736,
13,
308,
13,
4706,
7087,
29918,
8977,
353,
6571,
13,
4706,
363,
474,
29892,
1993,
297,
26985,
29898,
20317,
1125,
13,
9651,
396,
15894,
393,
599,
937,
15602,
526,
310,
278,
1021,
3309,
13,
9651,
659,
29879,
353,
426,
13,
18884,
350,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29896,
29901,
1993,
29961,
29900,
1402,
13,
18884,
350,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29906,
29901,
1993,
29961,
29896,
1402,
13,
18884,
350,
2127,
9652,
29889,
1625,
29879,
29889,
4571,
1254,
29901,
1993,
29961,
29906,
1402,
13,
9651,
500,
13,
9651,
565,
1993,
29918,
333,
338,
451,
6213,
29901,
13,
18884,
659,
29879,
29961,
29933,
2127,
9652,
29889,
1625,
29879,
29889,
29924,
14789,
29918,
1367,
29962,
353,
1993,
29918,
333,
29961,
29875,
29962,
13,
9651,
565,
14100,
29918,
333,
338,
451,
6213,
29901,
13,
18884,
659,
29879,
29961,
29933,
2127,
9652,
29889,
1625,
29879,
29889,
1672,
29902,
29918,
1367,
29962,
353,
14100,
29918,
333,
29961,
29875,
29962,
13,
9651,
565,
23755,
29896,
29918,
333,
338,
451,
6213,
29901,
13,
18884,
659,
29879,
29961,
29933,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29896,
29918,
1367,
29962,
353,
23755,
29896,
29918,
333,
29961,
29875,
29962,
13,
9651,
565,
23755,
29906,
29918,
333,
338,
451,
6213,
29901,
13,
18884,
659,
29879,
29961,
29933,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29906,
29918,
1367,
29962,
353,
23755,
29906,
29918,
333,
29961,
29875,
29962,
13,
9651,
363,
1820,
297,
350,
2127,
9652,
29889,
1625,
29879,
29901,
13,
18884,
7087,
29918,
8977,
29889,
842,
4381,
29898,
1989,
29892,
5159,
467,
4397,
29898,
13,
462,
1678,
659,
29879,
29961,
1989,
29962,
565,
1820,
297,
659,
29879,
1683,
6213,
29897,
13,
4706,
1583,
29889,
2176,
353,
4489,
29918,
601,
29889,
8977,
29918,
517,
29918,
1272,
29918,
2557,
29898,
20317,
29918,
8977,
29897,
13,
268,
13,
1678,
822,
4770,
276,
558,
12035,
1311,
1125,
13,
4706,
9995,
5809,
278,
14407,
848,
3515,
1213,
15945,
13,
4706,
565,
1583,
29889,
2176,
338,
6213,
29901,
13,
9651,
736,
376,
8915,
23755,
7087,
29908,
13,
4706,
736,
4489,
29918,
601,
29889,
2158,
29918,
1272,
29918,
2557,
29898,
1311,
29889,
2176,
29892,
1510,
29922,
8824,
29897,
13,
268,
13,
1678,
822,
679,
29918,
10054,
29879,
29898,
1311,
29892,
302,
1125,
13,
4706,
9995,
2577,
23755,
29879,
408,
263,
12655,
1409,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
302,
313,
524,
1125,
29871,
29896,
363,
23755,
29896,
29892,
6467,
23755,
29871,
29906,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
584,
1990,
18078,
23749,
29889,
299,
2378,
6998,
11848,
2272,
1409,
310,
278,
2183,
23755,
1134,
29892,
470,
13,
9651,
6213,
565,
278,
584,
5552,
18078,
2176,
29952,
338,
6213,
470,
278,
23755,
1897,
947,
451,
1863,
29889,
13,
13,
4706,
9995,
13,
4706,
784,
353,
350,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29896,
565,
302,
1275,
29871,
29896,
1683,
350,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29906,
13,
4706,
565,
1583,
29889,
2176,
338,
6213,
470,
784,
29889,
1767,
451,
297,
1583,
29889,
2176,
29901,
13,
9651,
736,
6213,
13,
4706,
736,
7442,
29889,
29894,
1429,
29898,
1311,
29889,
2176,
29961,
1054,
29889,
1767,
2314,
13,
268,
13,
1678,
822,
679,
29918,
10054,
29879,
29918,
497,
29898,
1311,
1125,
13,
4706,
9995,
2577,
599,
23755,
29879,
297,
278,
23755,
7087,
29889,
13,
308,
13,
4706,
16969,
29901,
13,
9651,
18761,
7503,
1990,
18078,
23749,
29889,
299,
2378,
1673,
584,
1990,
18078,
23749,
29889,
299,
2378,
29952,
5387,
13,
9651,
12603,
552,
310,
4954,
29898,
10054,
29879,
29896,
29892,
23755,
29879,
29906,
3569,
1673,
470,
6213,
565,
2845,
526,
6213,
29889,
13,
13,
4706,
9995,
13,
4706,
23755,
29879,
29918,
497,
353,
5159,
13,
4706,
363,
302,
297,
313,
29896,
29892,
29871,
29906,
1125,
13,
9651,
23755,
29879,
353,
1583,
29889,
657,
29918,
10054,
29879,
29898,
29876,
29897,
13,
9651,
565,
23755,
29879,
338,
6213,
29901,
13,
18884,
736,
6213,
13,
9651,
23755,
29879,
29918,
497,
29889,
4397,
29898,
10054,
29879,
29897,
13,
4706,
736,
23755,
29879,
29918,
497,
13,
268,
13,
1678,
822,
2767,
29918,
10054,
29879,
29898,
1311,
29892,
7876,
29892,
334,
5085,
1125,
13,
4706,
9995,
6422,
599,
23755,
29879,
411,
278,
2183,
740,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
7876,
313,
9891,
1125,
6680,
393,
21486,
278,
1962,
310,
584,
29885,
621,
18078,
657,
29918,
10054,
29879,
29952,
13,
18884,
16949,
363,
1269,
731,
310,
23755,
29879,
29889,
13,
9651,
334,
5085,
313,
10773,
1125,
3462,
3245,
6273,
304,
4954,
9144,
29952,
1412,
13,
13,
4706,
9995,
13,
4706,
565,
1583,
29889,
2176,
338,
6213,
29901,
736,
13,
4706,
363,
474,
29892,
784,
297,
26985,
3552,
29933,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29896,
29892,
350,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29906,
22164,
13,
9651,
23755,
29879,
353,
1583,
29889,
657,
29918,
10054,
29879,
29898,
29875,
718,
29871,
29896,
29897,
13,
9651,
565,
23755,
29879,
338,
451,
6213,
29901,
13,
18884,
1583,
29889,
2176,
29961,
1054,
29889,
1767,
29962,
353,
7876,
29898,
10054,
29879,
29892,
334,
5085,
467,
25027,
391,
580,
13,
13,
13,
1990,
10292,
1625,
18642,
3950,
29898,
3318,
1125,
13,
1678,
9995,
1625,
18642,
675,
23755,
29879,
297,
10930,
2729,
373,
9686,
23755,
29879,
4822,
18196,
29889,
13,
268,
13,
1678,
18601,
7258,
3370,
363,
29178,
287,
6674,
307,
985,
292,
29892,
411,
6416,
1627,
304,
13,
1678,
5839,
1847,
297,
363,
17713,
6674,
307,
985,
292,
29889,
13,
13,
1678,
9995,
13,
1678,
23755,
29879,
353,
6213,
13,
1678,
1993,
29918,
25027,
353,
6213,
13,
268,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
784,
18642,
675,
29918,
1271,
29898,
25932,
29892,
29311,
29892,
9210,
29892,
8267,
29892,
23755,
29879,
29922,
8516,
29892,
13,
462,
308,
304,
29880,
29922,
8516,
29892,
6230,
29918,
11303,
29922,
8824,
1125,
13,
4706,
9995,
1625,
18642,
675,
23755,
29879,
515,
1422,
18196,
2629,
263,
2908,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
29311,
313,
23215,
552,
29961,
524,
29962,
1125,
15658,
14821,
29889,
13,
9651,
9210,
313,
1293,
29961,
524,
29962,
1125,
15658,
9210,
2629,
278,
2989,
1967,
297,
503,
29892,
29891,
29892,
29916,
29889,
13,
9651,
8267,
313,
1293,
29961,
524,
29962,
1125,
15658,
8267,
297,
503,
29892,
29891,
29892,
29916,
29889,
13,
9651,
23755,
29879,
13940,
5415,
18078,
9302,
29889,
299,
2378,
29952,
1125,
29871,
29906,
29928,
23755,
29879,
1409,
29936,
21274,
304,
6213,
304,
13,
18884,
671,
584,
5552,
18078,
10054,
29879,
1412,
13,
9651,
304,
29880,
313,
1293,
29961,
7411,
29962,
1125,
16977,
261,
749,
363,
784,
18642,
5281,
23755,
29879,
29936,
21274,
13,
18884,
304,
6213,
304,
671,
584,
5552,
18078,
4352,
29918,
25027,
1412,
13,
9651,
6230,
29918,
11303,
313,
11227,
1125,
5852,
304,
731,
701,
24492,
6273,
29892,
12234,
363,
13,
18884,
263,
29178,
287,
313,
29878,
1624,
1135,
363,
17713,
29897,
5177,
29936,
21274,
304,
7700,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
12603,
552,
29961,
524,
1402,
9657,
29961,
23215,
552,
29961,
524,
1402,
12603,
552,
5387,
4954,
1111,
536,
16159,
363,
23110,
13,
9651,
6674,
307,
985,
292,
322,
278,
8600,
310,
7087,
29889,
13,
13,
4706,
9995,
13,
4706,
565,
23755,
29879,
338,
6213,
29901,
13,
9651,
23755,
29879,
353,
1067,
29879,
29889,
10054,
29879,
13,
4706,
565,
304,
29880,
338,
6213,
29901,
13,
9651,
304,
29880,
353,
1067,
29879,
29889,
4352,
29918,
25027,
13,
4706,
565,
6230,
29918,
11303,
29901,
13,
9651,
396,
19763,
1899,
29899,
1220,
4128,
13,
9651,
9335,
29889,
5014,
29918,
11303,
29918,
5085,
580,
13,
4706,
7087,
353,
784,
18642,
675,
29918,
10054,
29879,
29918,
4352,
29898,
10054,
29879,
29892,
9210,
29961,
1057,
29899,
29896,
1402,
8267,
29961,
1057,
29899,
29896,
1402,
304,
29880,
29897,
13,
4706,
736,
29311,
29892,
7087,
13,
268,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
784,
18642,
675,
29918,
1429,
29898,
25932,
29892,
8267,
29892,
23755,
29879,
1125,
13,
4706,
9995,
9634,
1298,
304,
784,
18642,
5281,
23755,
29879,
2629,
263,
5096,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
8267,
313,
1293,
29961,
524,
29962,
1125,
7084,
8267,
297,
503,
29892,
29891,
29892,
29916,
29889,
13,
9651,
23755,
29879,
13940,
5415,
18078,
9302,
29889,
299,
2378,
29952,
1125,
29871,
29906,
29928,
11848,
2272,
1409,
310,
23755,
29879,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
9657,
29961,
23583,
29961,
524,
29892,
938,
1402,
584,
1990,
18078,
29933,
2127,
9652,
29952,
5387,
450,
13,
9651,
8600,
310,
7087,
29892,
988,
6611,
526,
5291,
2701,
310,
278,
8242,
11000,
29892,
13,
9651,
322,
1819,
526,
23755,
1993,
3618,
29889,
29871,
13,
13,
4706,
9995,
13,
4706,
1596,
703,
1625,
18642,
5281,
23755,
29879,
2729,
373,
9686,
23755,
29879,
297,
1269,
5101,
310,
376,
13,
795,
376,
305,
12629,
1159,
13,
4706,
396,
731,
701,
16641,
29902,
10930,
515,
607,
304,
1831,
23755,
29879,
297,
1269,
2908,
13,
4706,
1014,
29918,
307,
29875,
29918,
29879,
29399,
29892,
1014,
29918,
307,
275,
29918,
2696,
7224,
29892,
17117,
17117,
17117,
25457,
29918,
3188,
29892,
17117,
903,
320,
13,
9651,
353,
5096,
29918,
4801,
522,
29889,
14669,
29918,
1271,
29879,
29898,
2917,
29889,
307,
29875,
29918,
10185,
29892,
8267,
29897,
13,
4706,
1993,
29918,
25027,
353,
7442,
29889,
18056,
368,
29898,
13,
9651,
25457,
29918,
3188,
29892,
2295,
29889,
307,
29875,
29918,
10185,
3366,
27902,
29918,
25027,
29918,
19790,
20068,
13,
308,
13,
4706,
338,
29918,
29888,
548,
353,
19875,
292,
29889,
275,
29918,
29888,
548,
580,
13,
4706,
565,
338,
29918,
29888,
548,
29901,
13,
9651,
396,
731,
7258,
848,
297,
363,
17713,
6674,
307,
985,
292,
13,
9651,
1067,
29879,
29889,
10054,
29879,
353,
23755,
29879,
13,
9651,
1067,
29879,
29889,
4352,
29918,
25027,
353,
1993,
29918,
25027,
13,
4706,
11565,
353,
22326,
29889,
11426,
29898,
5014,
267,
29922,
2917,
29889,
6814,
375,
29897,
13,
4706,
11565,
29918,
9902,
353,
5159,
13,
4706,
363,
503,
297,
3464,
29898,
1491,
29918,
307,
29875,
29918,
29879,
29399,
29889,
12181,
29961,
29900,
29962,
1125,
13,
9651,
363,
343,
297,
3464,
29898,
1491,
29918,
307,
29875,
29918,
29879,
29399,
29889,
12181,
29961,
29896,
29962,
1125,
13,
18884,
363,
921,
297,
3464,
29898,
1491,
29918,
307,
29875,
29918,
29879,
29399,
29889,
12181,
29961,
29906,
29962,
1125,
13,
462,
1678,
29311,
353,
313,
29920,
29892,
343,
29892,
921,
29897,
13,
462,
1678,
9210,
353,
1014,
29918,
307,
275,
29918,
2696,
7224,
29961,
1111,
536,
29962,
13,
462,
1678,
269,
29399,
353,
1014,
29918,
307,
29875,
29918,
29879,
29399,
29961,
1111,
536,
29962,
13,
462,
1678,
8267,
353,
518,
29879,
29889,
9847,
448,
269,
29889,
2962,
363,
269,
297,
269,
29399,
29962,
13,
462,
1678,
565,
338,
29918,
29888,
548,
29901,
13,
462,
4706,
396,
671,
3651,
6087,
408,
770,
8393,
13,
462,
4706,
11565,
29918,
9902,
29889,
4397,
29898,
10109,
29889,
7302,
29918,
12674,
29898,
13,
462,
9651,
10292,
1625,
18642,
3950,
29889,
1054,
18642,
675,
29918,
1271,
29892,
13,
462,
9651,
6389,
7607,
1111,
536,
29892,
9210,
29892,
8267,
4961,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
396,
5839,
280,
2989,
731,
310,
3651,
13,
462,
4706,
11565,
29918,
9902,
29889,
4397,
29898,
10109,
29889,
7302,
29918,
12674,
29898,
13,
462,
9651,
10292,
1625,
18642,
3950,
29889,
1054,
18642,
675,
29918,
1271,
29892,
13,
462,
9651,
6389,
7607,
1111,
536,
29892,
9210,
29892,
8267,
29892,
13,
462,
462,
29871,
1439,
3019,
29889,
657,
29918,
10054,
29879,
29918,
262,
29918,
307,
29875,
29898,
13,
462,
462,
418,
23755,
29879,
29892,
9210,
29892,
8267,
9601,
29900,
1402,
1993,
29918,
25027,
29892,
13,
462,
462,
29871,
5852,
4961,
13,
308,
13,
4706,
396,
9657,
310,
8242,
4145,
359,
304,
23755,
7087,
848,
3515,
13,
4706,
7087,
29918,
497,
353,
6571,
13,
4706,
363,
1121,
297,
11565,
29918,
9902,
29901,
13,
9651,
29311,
29892,
7087,
353,
1121,
29889,
657,
580,
13,
9651,
2302,
353,
29871,
29900,
13,
9651,
363,
1820,
29892,
659,
297,
7087,
29889,
7076,
7295,
13,
18884,
7087,
29918,
497,
29889,
842,
4381,
29898,
1989,
29892,
5159,
467,
4397,
29898,
791,
29889,
2176,
29897,
13,
18884,
2302,
4619,
7431,
29898,
791,
29889,
2176,
29897,
13,
9651,
1596,
703,
4676,
6571,
7087,
515,
2908,
472,
6571,
310,
426,
5038,
13,
462,
29871,
869,
4830,
29898,
2798,
29892,
29311,
29892,
7442,
29889,
1202,
29898,
1491,
29918,
307,
29875,
29918,
29879,
29399,
29889,
12181,
29892,
448,
29896,
4961,
13,
308,
13,
4706,
11565,
29889,
5358,
580,
13,
4706,
11565,
29889,
7122,
580,
13,
308,
13,
4706,
396,
544,
1540,
20955,
491,
5622,
7087,
411,
3273,
342,
5418,
13,
4706,
363,
1820,
297,
7087,
29918,
497,
29889,
8149,
7295,
13,
9651,
7087,
29918,
497,
29961,
1989,
29962,
353,
10518,
29889,
17685,
29898,
20317,
29918,
497,
29961,
1989,
2314,
13,
9651,
363,
23755,
29875,
297,
313,
29933,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29896,
29892,
350,
2127,
9652,
29889,
1625,
29879,
29889,
29933,
28902,
29906,
1125,
13,
18884,
396,
3588,
23755,
1897,
304,
29871,
299,
2378,
304,
6597,
1302,
4339,
491,
1897,
13,
18884,
7087,
353,
7087,
29918,
497,
29961,
1989,
29962,
13,
18884,
7087,
29918,
3909,
29939,
29892,
7087,
29918,
29875,
29892,
7087,
29918,
11569,
29892,
7087,
29918,
312,
29879,
353,
7442,
29889,
13092,
29898,
13,
462,
1678,
7442,
29889,
29894,
1429,
29898,
20317,
29961,
10054,
29875,
29889,
1767,
2314,
7503,
29892,
584,
29941,
1402,
9685,
29922,
29900,
29892,
13,
462,
1678,
736,
29918,
2248,
29922,
5574,
29892,
736,
29918,
262,
3901,
29922,
5574,
29892,
736,
29918,
2798,
29879,
29922,
5574,
29897,
13,
18884,
565,
7442,
29889,
2083,
29898,
20317,
29918,
312,
29879,
1405,
29871,
29896,
29897,
1405,
29871,
29900,
29901,
13,
462,
1678,
396,
544,
1540,
565,
472,
3203,
697,
23755,
756,
1063,
19228,
304,
2999,
13,
462,
1678,
396,
916,
23755,
29879,
13,
462,
1678,
22102,
353,
7087,
29889,
309,
542,
29961,
20317,
29918,
29875,
29961,
20317,
29918,
312,
29879,
1275,
29871,
29896,
5262,
13,
462,
1678,
868,
567,
353,
5159,
13,
462,
1678,
363,
474,
29892,
274,
29873,
297,
26985,
29898,
20317,
29918,
312,
29879,
1125,
13,
462,
4706,
396,
3160,
1661,
29899,
20908,
15815,
304,
11551,
2380,
13,
462,
4706,
565,
274,
29873,
5277,
29871,
29896,
29901,
6773,
13,
462,
4706,
396,
679,
16285,
297,
1677,
7087,
472,
2183,
5412,
1409,
13,
462,
4706,
396,
2380,
322,
2125,
1993,
411,
19604,
1320,
13,
462,
4706,
7087,
29918,
4713,
353,
7087,
29889,
2029,
29961,
20317,
29918,
11569,
1275,
474,
29962,
13,
462,
4706,
1320,
29879,
353,
7087,
29918,
4713,
29961,
29933,
2127,
9652,
29889,
1625,
29879,
29889,
4571,
1254,
29889,
1767,
29962,
13,
462,
4706,
1375,
29918,
5721,
353,
7442,
29889,
9103,
29898,
29881,
2879,
29897,
13,
462,
4706,
954,
29918,
20317,
353,
7431,
29898,
20317,
29918,
4713,
29897,
13,
462,
4706,
565,
2295,
29889,
369,
15828,
322,
954,
29918,
20317,
1405,
29871,
29896,
29901,
13,
462,
9651,
1596,
703,
558,
27964,
515,
613,
954,
29918,
20317,
29892,
13,
462,
462,
29871,
376,
20317,
310,
1320,
29901,
613,
1320,
29879,
29897,
13,
462,
4706,
7087,
29918,
4713,
353,
7087,
29918,
4713,
29889,
2029,
29961,
29881,
2879,
1275,
1375,
29918,
5721,
29962,
13,
462,
4706,
396,
2125,
937,
297,
1206,
310,
738,
260,
583,
13,
462,
4706,
868,
567,
29889,
4397,
29898,
20317,
29918,
4713,
29889,
309,
542,
8999,
29900,
24960,
13,
462,
1678,
7087,
29918,
497,
29961,
1989,
29962,
353,
10518,
29889,
17685,
3552,
2976,
793,
29892,
10518,
29889,
17685,
29898,
700,
567,
4961,
13,
9651,
1596,
703,
1625,
18642,
2133,
7087,
363,
18196,
426,
6177,
426,
5038,
13,
462,
29871,
869,
4830,
29898,
1989,
29892,
7431,
29898,
20317,
29918,
497,
29961,
1989,
29962,
4961,
13,
9651,
4303,
11082,
29889,
2158,
29894,
29898,
2158,
29898,
20317,
29918,
497,
29961,
1989,
12622,
13,
9651,
396,
3787,
848,
3515,
297,
350,
2127,
9652,
1203,
13,
9651,
7087,
29918,
497,
29961,
1989,
29962,
353,
350,
2127,
9652,
29898,
2176,
29922,
20317,
29918,
497,
29961,
1989,
2314,
13,
308,
13,
4706,
736,
7087,
29918,
497,
13,
13,
13,
1753,
784,
18642,
675,
29918,
10054,
29879,
29898,
307,
29875,
29892,
23755,
29879,
29892,
266,
3781,
29922,
8516,
1125,
13,
1678,
9995,
7967,
29899,
2997,
675,
23755,
29879,
515,
1422,
18196,
2729,
373,
18830,
13,
1678,
12838,
1907,
29889,
13,
268,
13,
1678,
498,
3781,
3361,
363,
15326,
526,
937,
15659,
297,
1269,
8242,
491,
5622,
13,
1678,
278,
23755,
29879,
297,
278,
2183,
8242,
29892,
9138,
278,
18830,
12838,
1907,
29892,
13,
1678,
322,
5622,
263,
4482,
313,
29945,
386,
29897,
10151,
488,
29889,
1987,
363,
1269,
8242,
29892,
278,
13,
1678,
18830,
12838,
1907,
310,
23755,
29879,
297,
393,
8242,
526,
9401,
411,
13,
1678,
278,
266,
3781,
3361,
297,
278,
916,
18196,
29889,
350,
2127,
29879,
13461,
292,
738,
2183,
13,
1678,
16897,
526,
5545,
304,
1302,
29899,
2997,
675,
297,
393,
8242,
29889,
13,
268,
13,
1678,
826,
3174,
29901,
13,
4706,
14100,
13940,
5415,
18078,
9302,
29889,
299,
2378,
29952,
1125,
11069,
310,
4066,
408,
263,
29871,
29941,
29928,
29974,
12719,
1409,
29889,
13,
4706,
23755,
29879,
13940,
5415,
18078,
9302,
29889,
299,
2378,
29952,
1125,
350,
2127,
29879,
408,
263,
29871,
29906,
29928,
1409,
297,
278,
3402,
13,
9651,
4954,
8999,
29920,
29892,
343,
29892,
921,
29892,
11855,
29892,
9659,
362,
29892,
8760,
29892,
8242,
856,
1402,
2023,
7961,
1412,
13,
4706,
266,
3781,
313,
524,
29892,
5785,
29892,
851,
1125,
498,
12268,
10151,
488,
310,
12838,
1907,
515,
13,
9651,
17036,
18830,
1269,
23755,
297,
278,
2183,
8242,
29889,
4803,
376,
1195,
29908,
13,
9651,
304,
2012,
2125,
278,
1375,
262,
12539,
6588,
26171,
310,
599,
23755,
29879,
13,
9651,
297,
278,
8242,
29889,
13109,
29879,
304,
6213,
304,
671,
376,
1195,
1642,
13,
13,
1678,
16969,
29901,
13,
4706,
584,
5415,
18078,
9302,
29889,
299,
2378,
6998,
29871,
29906,
29928,
11848,
2272,
1409,
310,
1021,
3309,
408,
4954,
10054,
29879,
16159,
411,
13,
4706,
263,
1897,
363,
1269,
8242,
988,
29871,
29896,
14088,
393,
278,
6590,
13,
4706,
23755,
756,
7182,
338,
2198,
297,
278,
2183,
18196,
472,
278,
23755,
29915,
29879,
13,
4706,
4423,
29892,
322,
29871,
29900,
14088,
1663,
29884,
4543,
7182,
29889,
13,
13,
1678,
9995,
13,
1678,
565,
23755,
29879,
338,
6213,
470,
14100,
338,
6213,
470,
7431,
29898,
307,
29875,
29889,
12181,
29897,
529,
29871,
29946,
29901,
13,
4706,
736,
6213,
13,
1678,
565,
266,
3781,
338,
6213,
29901,
13,
4706,
266,
3781,
353,
376,
1195,
29908,
13,
1678,
1596,
703,
1625,
18642,
5281,
23755,
29879,
2729,
373,
1967,
26171,
4822,
18196,
1159,
13,
1678,
266,
3781,
29879,
353,
5159,
13,
1678,
409,
2409,
353,
18131,
3002,
29889,
2135,
29898,
29906,
29897,
13,
268,
13,
1678,
396,
1284,
871,
23755,
29879,
297,
16641,
29902,
1951,
23755,
29879,
1051,
1122,
3160,
23755,
29879,
515,
16800,
13,
1678,
396,
8388,
3885,
29892,
541,
16641,
29902,
338,
451,
3625,
363,
963,
13,
1678,
23755,
29879,
29918,
307,
29875,
29892,
23755,
29879,
29918,
307,
29875,
29918,
13168,
353,
1439,
3019,
29889,
657,
29918,
10054,
29879,
29918,
262,
29918,
307,
29875,
29898,
13,
4706,
23755,
29879,
29892,
313,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
511,
14100,
29889,
12181,
7503,
29941,
1402,
11837,
29922,
8824,
29897,
13,
1678,
23755,
29879,
29918,
305,
29880,
353,
1439,
3019,
29889,
657,
29918,
10054,
29879,
29918,
12719,
29898,
10054,
29879,
29918,
307,
29875,
29897,
13,
1678,
23755,
29879,
29918,
3881,
29918,
305,
3137,
353,
5159,
13,
268,
13,
1678,
396,
679,
301,
24025,
11105,
29879,
310,
23755,
29879,
363,
1269,
8242,
322,
16897,
12838,
1907,
13,
1678,
11105,
29918,
307,
29875,
353,
7442,
29889,
2873,
29898,
307,
29875,
29889,
12181,
7503,
29941,
1402,
26688,
29922,
524,
29897,
13,
1678,
11105,
29918,
307,
29875,
29918,
305,
3137,
353,
5159,
13,
1678,
363,
521,
29880,
297,
3464,
29898,
307,
29875,
29889,
12181,
29961,
29941,
29962,
1125,
13,
4706,
396,
3858,
263,
11105,
411,
23755,
16285,
18830,
1269,
23755,
13,
4706,
23755,
29879,
29918,
305,
29880,
29918,
13168,
353,
7442,
29889,
275,
262,
29898,
10054,
29879,
29918,
305,
29880,
29892,
521,
29880,
29897,
13,
4706,
23755,
29879,
29918,
3881,
353,
7442,
29889,
3062,
29898,
10054,
29879,
29918,
305,
29880,
29918,
13168,
9601,
29900,
29962,
13,
4706,
23755,
29879,
29918,
3881,
29918,
305,
3137,
29889,
4397,
29898,
10054,
29879,
29918,
3881,
29897,
13,
4706,
11105,
353,
7442,
29889,
8552,
29898,
13168,
29918,
307,
29875,
29897,
334,
448,
29896,
13,
4706,
11105,
29961,
23583,
29898,
1982,
11082,
29889,
1111,
4339,
29918,
1454,
29918,
2248,
292,
29898,
13,
9651,
23755,
29879,
29918,
307,
29875,
29961,
10054,
29879,
29918,
305,
29880,
29918,
13168,
29892,
584,
29941,
1822,
579,
668,
29898,
524,
876,
4638,
353,
23755,
29879,
29918,
3881,
13,
4706,
11105,
353,
18131,
3002,
29889,
29881,
8634,
29898,
13168,
29892,
409,
2409,
29922,
344,
2409,
29897,
13,
4706,
11105,
29918,
307,
29875,
29918,
305,
3137,
29889,
4397,
29898,
13168,
29897,
13,
308,
13,
4706,
565,
266,
3781,
1275,
376,
1195,
1115,
13,
9651,
396,
731,
9212,
6588,
18830,
26171,
310,
599,
23755,
29879,
408,
266,
3781,
13,
9651,
266,
3781,
29879,
29889,
4397,
29898,
13,
18884,
6213,
565,
7431,
29898,
10054,
29879,
29918,
3881,
29897,
1275,
29871,
29900,
1683,
7442,
29889,
9103,
4197,
13,
462,
1678,
7442,
29889,
12676,
29898,
307,
29875,
29961,
13168,
1275,
289,
29892,
521,
29880,
2314,
363,
289,
297,
23755,
29879,
29918,
3881,
12622,
13,
4706,
1683,
29901,
13,
9651,
396,
731,
263,
10151,
488,
310,
12838,
1907,
18830,
599,
23755,
29879,
297,
8242,
13,
9651,
396,
408,
16897,
363,
393,
8242,
29892,
470,
278,
3353,
16641,
29902,
565,
694,
23755,
29879,
13,
9651,
11105,
29918,
10054,
29879,
353,
11105,
6736,
29871,
29900,
13,
9651,
14100,
29918,
13168,
353,
14100,
565,
7442,
29889,
2083,
29898,
13168,
29918,
10054,
29879,
29897,
529,
29871,
29896,
1683,
14100,
29961,
13168,
29918,
10054,
29879,
29892,
521,
29880,
29962,
13,
9651,
266,
3781,
29879,
29889,
4397,
29898,
9302,
29889,
25376,
488,
29898,
307,
29875,
29918,
13168,
29892,
266,
3781,
876,
13,
13,
1678,
18196,
353,
7442,
29889,
13092,
29898,
4801,
3019,
29889,
657,
29918,
10054,
29879,
29918,
12719,
29898,
10054,
29879,
29918,
307,
29875,
8106,
579,
668,
29898,
524,
29897,
13,
1678,
784,
12332,
29918,
307,
29875,
353,
7442,
29889,
3298,
359,
3552,
10054,
29879,
29918,
307,
29875,
29889,
12181,
29961,
29900,
1402,
14100,
29889,
12181,
29961,
29941,
11724,
26688,
29922,
9302,
29889,
13470,
29947,
29897,
13,
1678,
363,
521,
29880,
297,
18196,
29901,
13,
4706,
396,
679,
301,
24025,
11105,
310,
23755,
29879,
297,
278,
2183,
8242,
13,
4706,
11105,
353,
11105,
29918,
307,
29875,
29918,
305,
3137,
29961,
305,
29880,
29962,
13,
4706,
23755,
29879,
29918,
3881,
353,
23755,
29879,
29918,
3881,
29918,
305,
3137,
29961,
305,
29880,
29962,
13,
4706,
363,
521,
29880,
29918,
1228,
297,
18196,
29901,
13,
9651,
565,
266,
3781,
29879,
29961,
305,
29880,
29918,
1228,
29962,
338,
6213,
29901,
6773,
13,
9651,
363,
23755,
29875,
297,
23755,
29879,
29918,
3881,
29901,
13,
18884,
396,
1284,
18830,
26171,
310,
23755,
297,
1790,
8242,
13,
18884,
11105,
29918,
10054,
353,
11105,
1275,
23755,
29875,
13,
18884,
23755,
29918,
485,
29887,
353,
7442,
29889,
12676,
29898,
307,
29875,
29961,
13168,
29918,
10054,
29892,
521,
29880,
29918,
1228,
2314,
13,
18884,
565,
2295,
29889,
369,
15828,
29901,
13,
462,
1678,
1596,
29898,
10054,
29875,
29892,
1439,
3019,
29889,
657,
29918,
10054,
29918,
12719,
29898,
10054,
29879,
29918,
307,
29875,
29961,
10054,
29875,
11724,
13,
462,
3986,
23755,
29879,
29918,
307,
29875,
29961,
10054,
29875,
29892,
584,
29941,
1402,
23755,
29918,
485,
29887,
29892,
266,
3781,
29879,
29961,
305,
29880,
29918,
1228,
2314,
13,
18884,
565,
23755,
29918,
485,
29887,
6736,
266,
3781,
29879,
29961,
305,
29880,
29918,
1228,
5387,
13,
462,
1678,
396,
12838,
1907,
297,
1790,
8242,
2820,
23755,
29915,
29879,
2602,
13,
462,
1678,
396,
338,
2038,
393,
8242,
29915,
29879,
16897,
13,
462,
1678,
784,
12332,
29918,
307,
29875,
29961,
10054,
29875,
29892,
521,
29880,
29918,
1228,
29962,
353,
29871,
29896,
13,
268,
13,
1678,
396,
1653,
1409,
363,
599,
23755,
29879,
3704,
1906,
5377,
16641,
29902,
13,
1678,
784,
12332,
353,
7442,
29889,
3298,
359,
3552,
10054,
29879,
29889,
12181,
29961,
29900,
1402,
14100,
29889,
12181,
29961,
29941,
11724,
26688,
29922,
9302,
29889,
13470,
29947,
29897,
13,
1678,
784,
12332,
29961,
10054,
29879,
29918,
307,
29875,
29918,
13168,
29962,
353,
784,
12332,
29918,
307,
29875,
13,
1678,
565,
2295,
29889,
369,
15828,
29901,
13,
4706,
363,
474,
29892,
313,
10054,
29892,
28853,
29897,
297,
26985,
29898,
7554,
29898,
10054,
29879,
29918,
307,
29875,
29892,
784,
12332,
22164,
13,
9651,
1596,
29898,
29875,
29892,
1439,
3019,
29889,
657,
29918,
10054,
29918,
12719,
29898,
10054,
511,
23755,
7503,
29941,
1402,
28853,
29897,
13,
1678,
736,
784,
12332,
13,
13,
13,
1753,
784,
18642,
675,
29918,
10054,
29879,
29918,
4352,
29898,
10054,
29879,
29892,
9210,
29892,
2159,
29892,
304,
29880,
29892,
6426,
29918,
12791,
29922,
8516,
1125,
13,
1678,
9995,
7967,
29899,
2997,
675,
23755,
29879,
297,
5004,
18196,
541,
278,
1021,
16641,
29902,
491,
9138,
13,
1678,
14413,
23755,
7087,
29889,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
23755,
29879,
13940,
5415,
18078,
9302,
29889,
299,
2378,
29952,
1125,
350,
2127,
29879,
515,
5004,
18196,
29889,
13,
4706,
9210,
313,
1293,
29961,
524,
29962,
1125,
16641,
29902,
9210,
2183,
408,
921,
29892,
29891,
29892,
29920,
29889,
13,
4706,
2159,
313,
1293,
29961,
524,
29962,
1125,
16641,
29902,
8267,
2183,
408,
921,
29892,
29891,
29892,
29920,
29889,
13,
4706,
304,
29880,
313,
1293,
29961,
7411,
29962,
1125,
16977,
261,
2925,
363,
9686,
2183,
408,
921,
29892,
29891,
29892,
29920,
13,
4706,
6426,
29918,
12791,
313,
1293,
29961,
524,
29962,
1125,
16641,
29902,
7164,
2183,
408,
921,
29892,
29891,
29892,
29920,
29936,
21274,
13,
9651,
304,
6213,
304,
671,
278,
7164,
2729,
373,
4954,
25027,
29952,
1412,
13,
13,
1678,
16969,
29901,
13,
4706,
9657,
29961,
23583,
29961,
524,
29892,
938,
1402,
584,
1990,
18078,
29933,
2127,
9652,
29952,
5387,
13,
4706,
13343,
988,
6611,
526,
5291,
2701,
310,
278,
1023,
18196,
9401,
322,
13,
4706,
1819,
526,
23755,
7087,
3618,
29889,
13,
13,
1678,
9995,
13,
1678,
565,
23755,
29879,
338,
6213,
29901,
13,
4706,
736,
6213,
13,
1678,
266,
3781,
29892,
21640,
29892,
6426,
29918,
8305,
29892,
19490,
29892,
23755,
29879,
353,
1147,
3709,
29889,
14669,
29918,
4352,
29918,
10054,
29879,
29918,
307,
29875,
29898,
13,
4706,
23755,
29879,
29892,
304,
29880,
29897,
13,
1678,
565,
6426,
29918,
12791,
338,
6213,
29901,
13,
4706,
6426,
29918,
12791,
353,
6426,
29918,
8305,
13,
1678,
7087,
29918,
305,
3137,
353,
6571,
13,
1678,
18196,
353,
7442,
29889,
13092,
29898,
4801,
3019,
29889,
657,
29918,
10054,
29879,
29918,
12719,
29898,
10054,
29879,
8106,
579,
668,
29898,
524,
29897,
13,
1678,
363,
521,
29880,
297,
18196,
29901,
13,
4706,
396,
5101,
18196,
13,
4706,
23755,
29879,
29918,
305,
29880,
353,
1439,
3019,
29889,
10054,
29879,
29918,
262,
29918,
12719,
29898,
10054,
29879,
29892,
521,
29880,
29897,
13,
4706,
363,
521,
29880,
29918,
1228,
297,
18196,
29901,
13,
9651,
396,
5557,
20955,
491,
14993,
3262,
916,
18196,
2400,
2183,
8242,
13,
9651,
565,
521,
29880,
6736,
521,
29880,
29918,
1228,
29901,
6773,
13,
9651,
396,
1284,
784,
18642,
17063,
1546,
23755,
29879,
515,
697,
8242,
304,
23755,
29879,
13,
9651,
396,
297,
1790,
8242,
13,
9651,
23755,
29879,
29918,
305,
29880,
29918,
1228,
353,
1439,
3019,
29889,
10054,
29879,
29918,
262,
29918,
12719,
29898,
10054,
29879,
29892,
521,
29880,
29918,
1228,
29897,
13,
9651,
23755,
29879,
29918,
3993,
29918,
11242,
29892,
23755,
29879,
29918,
509,
2806,
29918,
3993,
29918,
11242,
29892,
9210,
29918,
3993,
29892,
320,
13,
18884,
2159,
29918,
3993,
29892,
7087,
353,
1147,
3709,
29889,
4352,
29918,
10054,
29879,
29918,
307,
29875,
29898,
13,
462,
1678,
23755,
29879,
29918,
305,
29880,
29918,
1228,
29892,
23755,
29879,
29918,
305,
29880,
29892,
9210,
29892,
2159,
29892,
266,
3781,
29892,
21640,
29892,
13,
462,
1678,
6426,
29918,
12791,
29892,
19490,
29897,
13,
632,
13,
9651,
396,
10092,
8760,
322,
9659,
362,
23755,
13449,
297,
7087,
13,
9651,
521,
29880,
29918,
510,
833,
353,
313,
305,
29880,
29892,
521,
29880,
29918,
1228,
29897,
13,
9651,
7087,
29889,
5504,
29918,
10054,
29879,
29898,
4801,
3019,
29889,
842,
29918,
10054,
29918,
509,
2806,
29892,
448,
29896,
29897,
13,
9651,
7087,
29889,
5504,
29918,
10054,
29879,
29898,
4801,
3019,
29889,
842,
29918,
10054,
29918,
5527,
381,
2168,
29892,
448,
29896,
29897,
13,
9651,
7087,
29918,
305,
3137,
29961,
305,
29880,
29918,
510,
833,
29962,
353,
7087,
13,
1678,
736,
7087,
29918,
305,
3137,
13,
13,
13,
1753,
903,
657,
29918,
307,
29875,
29918,
333,
29898,
2585,
29892,
9210,
29892,
8267,
29892,
1518,
29918,
978,
29922,
8516,
1125,
13,
1678,
9995,
2577,
2566,
16641,
29902,
3553,
363,
278,
2183,
16641,
29902,
2602,
2629,
278,
1667,
1967,
29945,
29881,
29889,
13,
268,
13,
1678,
826,
3174,
29901,
13,
4706,
4833,
13940,
5415,
18078,
22793,
29889,
6821,
29878,
4051,
29952,
1125,
5470,
1203,
29889,
13,
4706,
9210,
313,
1293,
29961,
524,
29962,
1125,
16641,
29902,
9210,
297,
503,
29892,
29891,
29892,
29916,
29889,
13,
4706,
8267,
313,
1293,
29961,
524,
29962,
1125,
16641,
29902,
8267,
297,
503,
29892,
29891,
29892,
29916,
29889,
13,
4706,
1518,
29918,
978,
313,
710,
1125,
4408,
310,
7639,
29936,
21274,
304,
6213,
304,
4218,
13,
9651,
20699,
1549,
738,
1967,
7500,
304,
584,
5552,
18078,
2917,
29889,
2492,
29945,
29881,
1412,
13,
13,
1678,
16969,
29901,
13,
4706,
938,
29901,
16641,
29902,
3553,
470,
1476,
470,
15478,
16641,
29902,
29889,
13,
13,
1678,
9995,
13,
1678,
565,
1518,
29918,
978,
338,
6213,
29901,
13,
4706,
1518,
29918,
978,
353,
21120,
29889,
657,
29918,
4548,
29918,
978,
29898,
13,
9651,
2295,
29889,
2492,
29945,
29881,
29889,
2084,
29918,
2492,
565,
2295,
29889,
2492,
29945,
29881,
1683,
6213,
29897,
13,
1678,
1518,
29918,
333,
353,
21120,
29889,
2622,
29918,
272,
29918,
7851,
29918,
735,
15362,
29898,
13,
4706,
4833,
29889,
13082,
29892,
4833,
29889,
2764,
29892,
1518,
29918,
978,
29892,
6213,
29897,
13,
1678,
14100,
29918,
333,
353,
21120,
29889,
2622,
29918,
272,
29918,
7851,
29918,
307,
29875,
29898,
13,
4706,
4833,
29889,
13082,
29892,
4833,
29889,
2764,
29892,
1518,
29918,
333,
29892,
2295,
29889,
13757,
29892,
9210,
29892,
8267,
9601,
29900,
29962,
13,
1678,
736,
14100,
29918,
333,
13,
13,
13,
1753,
4635,
29918,
20317,
29898,
2585,
29892,
7087,
1125,
13,
1678,
9995,
17491,
7087,
964,
2566,
363,
263,
3353,
1967,
29889,
13,
268,
13,
1678,
826,
3174,
29901,
13,
4706,
4833,
13940,
5415,
18078,
22793,
29889,
6821,
29878,
4051,
29952,
1125,
5470,
1203,
29889,
13,
4706,
7087,
313,
8977,
29961,
23583,
29961,
524,
29892,
938,
1402,
584,
1990,
18078,
29933,
2127,
9652,
29952,
1125,
13,
9651,
13343,
310,
8242,
419,
833,
5291,
2701,
304,
23755,
1993,
3618,
29889,
13,
13,
1678,
9995,
13,
1678,
396,
671,
2159,
310,
29871,
29900,
363,
1269,
9927,
363,
3353,
29899,
3027,
16641,
29902,
29892,
607,
4772,
29879,
13,
1678,
396,
278,
817,
304,
6523,
278,
1967,
2159,
13,
1678,
14100,
29918,
333,
353,
903,
657,
29918,
307,
29875,
29918,
333,
29898,
2585,
29892,
313,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
511,
313,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
876,
13,
268,
13,
1678,
363,
521,
29880,
29918,
20317,
297,
7087,
29889,
5975,
7295,
13,
4706,
396,
4635,
23755,
29879,
322,
7087,
363,
278,
2183,
8242,
419,
833,
13,
4706,
23755,
29879,
353,
521,
29880,
29918,
20317,
29889,
657,
29918,
10054,
29879,
29918,
497,
580,
13,
4706,
565,
23755,
29879,
338,
451,
6213,
29901,
13,
9651,
21120,
29889,
7851,
29918,
10054,
29879,
29898,
2585,
29889,
13082,
29892,
4833,
29889,
2764,
29892,
14100,
29918,
333,
29892,
7442,
29889,
29894,
1429,
29898,
10054,
29879,
876,
13,
9651,
2295,
29889,
2585,
29889,
7851,
29918,
10054,
29918,
20317,
29898,
307,
29875,
29918,
333,
29892,
521,
29880,
29918,
20317,
29897,
13,
13,
13,
1753,
1831,
29918,
20317,
29898,
2585,
29892,
18196,
29892,
9210,
29922,
8516,
29892,
8267,
29922,
8516,
29892,
1518,
29918,
978,
29922,
8516,
1125,
13,
1678,
9995,
3549,
23755,
7087,
363,
278,
2183,
5120,
515,
263,
2566,
29889,
13,
268,
13,
1678,
350,
2127,
7087,
526,
12023,
304,
505,
1063,
19356,
515,
278,
3353,
1967,
29889,
13,
1678,
1763,
10563,
7087,
515,
263,
4629,
16641,
29902,
29892,
671,
13,
1678,
584,
29885,
621,
18078,
11082,
1958,
29889,
601,
29889,
22793,
29889,
6821,
29878,
4051,
29889,
2622,
29918,
10054,
29918,
20317,
29952,
2012,
29889,
13,
268,
13,
1678,
826,
3174,
29901,
13,
4706,
4833,
13940,
5415,
18078,
22793,
29889,
6821,
29878,
4051,
29952,
1125,
5470,
1203,
29889,
13,
4706,
18196,
313,
1761,
29961,
524,
29962,
1125,
2391,
310,
18196,
29889,
13,
4706,
9210,
313,
1761,
29961,
524,
29962,
1125,
16641,
29902,
9210,
297,
503,
29892,
29891,
29892,
29916,
29936,
21274,
304,
6213,
304,
671,
13,
9651,
4954,
29898,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
3569,
1412,
13,
4706,
8267,
313,
1761,
29961,
524,
29962,
1125,
16641,
29902,
8267,
297,
503,
29892,
29891,
29892,
29916,
29936,
21274,
304,
6213,
304,
671,
13,
9651,
4954,
29898,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
3569,
1412,
13,
4706,
1518,
29918,
978,
313,
710,
1125,
4408,
310,
7639,
297,
4954,
2585,
29952,
1412,
13,
13,
1678,
16969,
29901,
13,
4706,
9657,
29961,
23583,
29961,
524,
29892,
938,
1402,
1051,
7503,
5415,
18078,
29933,
2127,
9652,
29952,
5387,
13343,
988,
13,
4706,
6611,
526,
5291,
2701,
310,
278,
1023,
18196,
9401,
322,
1819,
526,
263,
1051,
13,
4706,
310,
23755,
7087,
29889,
6213,
565,
694,
23755,
7087,
526,
1476,
29889,
13,
13,
1678,
9995,
13,
1678,
396,
679,
16641,
29902,
363,
3353,
1967,
13,
1678,
14100,
29918,
333,
353,
903,
657,
29918,
307,
29875,
29918,
333,
29898,
2585,
29892,
313,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
511,
313,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
511,
1518,
29918,
978,
29897,
13,
1678,
565,
9210,
338,
451,
6213,
322,
8267,
338,
451,
6213,
29901,
13,
4706,
396,
679,
23755,
515,
7087,
2629,
16641,
29902,
13,
4706,
23755,
29879,
29892,
23755,
29918,
4841,
353,
4833,
29889,
2622,
29918,
10054,
29879,
29918,
1609,
29918,
3283,
29898,
13,
9651,
14100,
29918,
333,
29892,
9210,
29961,
1057,
29899,
29896,
1402,
8267,
29961,
1057,
29899,
29896,
2314,
13,
1678,
1683,
29901,
13,
4706,
396,
679,
23755,
29879,
515,
7087,
2629,
278,
3353,
1967,
13,
4706,
23755,
29879,
29892,
23755,
29918,
4841,
353,
4833,
29889,
2622,
29918,
10054,
29879,
29918,
1609,
29918,
307,
29875,
29898,
307,
29875,
29918,
333,
29897,
13,
1678,
565,
23755,
29879,
338,
6213,
470,
7431,
29898,
10054,
29879,
29897,
1275,
29871,
29900,
29901,
13,
4706,
1596,
703,
3782,
23755,
7087,
1476,
1159,
13,
4706,
736,
6213,
13,
268,
13,
1678,
23755,
29918,
4841,
353,
7442,
29889,
2378,
29898,
10054,
29918,
4841,
29897,
13,
1678,
7087,
353,
6571,
13,
1678,
363,
521,
29880,
297,
18196,
29901,
13,
4706,
396,
5101,
18196,
13,
4706,
363,
521,
29880,
29918,
1228,
297,
18196,
29901,
13,
9651,
565,
521,
29880,
6736,
521,
29880,
29918,
1228,
29901,
6773,
13,
9651,
396,
1831,
7087,
363,
23755,
29879,
297,
278,
2183,
937,
8242,
310,
278,
5101,
13,
9651,
396,
310,
18196,
29892,
10241,
521,
3137,
892,
3300,
2859,
445,
982,
2645,
4635,
291,
13,
9651,
521,
29880,
29918,
20317,
353,
4833,
29889,
2622,
29918,
10054,
29918,
20317,
29918,
1609,
29918,
10054,
29918,
333,
29898,
13,
18884,
14100,
29918,
333,
29892,
29871,
29896,
29892,
13,
18884,
23755,
29918,
4841,
29961,
4801,
3019,
29889,
657,
29918,
10054,
29879,
29918,
12719,
29898,
10054,
29879,
29897,
1275,
521,
29880,
2314,
13,
9651,
23755,
29879,
29906,
353,
521,
29880,
29918,
20317,
29889,
657,
29918,
10054,
29879,
29898,
29906,
29897,
13,
9651,
565,
23755,
29879,
29906,
338,
451,
6213,
29901,
13,
18884,
521,
29880,
29918,
20317,
353,
521,
29880,
29918,
20317,
29889,
2176,
29889,
2029,
29961,
4801,
3019,
29889,
657,
29918,
10054,
29879,
29918,
12719,
29898,
13,
462,
1678,
23755,
29879,
29906,
29897,
1275,
521,
29880,
29918,
1228,
29962,
13,
18884,
7087,
15625,
305,
29880,
29892,
521,
29880,
29918,
1228,
4638,
353,
350,
2127,
9652,
29898,
2176,
29922,
305,
29880,
29918,
20317,
29897,
13,
1678,
736,
7087,
13,
2
] |
app.py | fdoliveira/infosystem-seed | 1 | 161225 | <filename>app.py
import os
import app
if __name__ == '__main__':
app_host = os.environ.get('HOST', '0.0.0.0')
app_port = int(os.environ.get('PORT', 5000))
system = app.System()
system.run(host=app_host, port=app_port)
| [
1,
529,
9507,
29958,
932,
29889,
2272,
13,
5215,
2897,
13,
5215,
623,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
623,
29918,
3069,
353,
2897,
29889,
21813,
29889,
657,
877,
20832,
742,
525,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
1495,
13,
1678,
623,
29918,
637,
353,
938,
29898,
359,
29889,
21813,
29889,
657,
877,
15082,
742,
29871,
29945,
29900,
29900,
29900,
876,
13,
1678,
1788,
353,
623,
29889,
3924,
580,
13,
1678,
1788,
29889,
3389,
29898,
3069,
29922,
932,
29918,
3069,
29892,
2011,
29922,
932,
29918,
637,
29897,
13,
2
] |
irspack/split/userwise.py | tnakae/irspack | 0 | 131831 | <reponame>tnakae/irspack
from typing import Any, Dict, List, Optional, Tuple
import numpy as np
import pandas as pd
from numpy.lib.arraysetops import unique
from scipy import sparse as sps
from irspack.definitions import InteractionMatrix, OptionalRandomState
from irspack.split.time import split_last_n_interaction_df
from irspack.utils import df_to_sparse, rowwise_train_test_split
from irspack.utils.random import convert_randomstate
def _split_list(
ids: List[Any], test_size: int, rns: np.random.RandomState
) -> Tuple[List[Any], List[Any]]:
rns.shuffle(ids)
return ids[test_size:], ids[:test_size]
class UserTrainTestInteractionPair:
"""A class to hold users' train & test (if any) interactions and their ids.
Args:
user_ids:
List of user ids. Its ``i``-th element should correspond to ``i``-th row
of ``X_train``.
X_train:
The train part of interactions.
X_test:
The test part of interactions (if any).
If ``None``, an empty matrix with the shape of ``X_train``
will be created. Defaults to None.
Raises:
ValueError:
when ``X_train`` and ``user_ids`` have inconsistent size.
ValueError:
when ``X_train`` and ``X_test`` have inconsistent size.
"""
X_train: sps.csr_matrix
"""The train part of users' interactions."""
X_test: sps.csr_matrix
"""The test part of users' interactions."""
n_users: int
"""The number of users"""
n_items: int
"""The number of items"""
X_all: sps.csr_matrix
"""If ``X_test`` is not ``None``, equal to ``X_train + X_test``.Otherwise equals X_train."""
def __init__(
self,
user_ids: List[Any],
X_train: InteractionMatrix,
X_test: Optional[InteractionMatrix],
item_ids: Optional[List[Any]] = None,
):
if len(user_ids) != X_train.shape[0]:
raise ValueError("user_ids and X_train have different shapes.")
if X_test is not None:
if X_train.shape != X_test.shape:
raise ValueError("X_train and X_test have different shapes.")
X_test = sps.csr_matrix(X_test)
else:
X_test = sps.csr_matrix(X_train.shape, dtype=X_train.dtype)
self.user_ids = [x for x in user_ids]
self.X_train = sps.csr_matrix(X_train)
self.X_test = X_test
self.n_users = self.X_train.shape[0]
self.n_items = self.X_train.shape[1]
self.X_all = sps.csr_matrix(self.X_train + self.X_test)
if item_ids is not None:
if len(item_ids) != self.X_test.shape[1]:
raise ValueError("X_train.shape[1] != len(item_ids)")
self.item_ids = item_ids
def _X_to_df(self, X: sps.csr_matrix, user_ids: List[Any]) -> pd.DataFrame:
if self.item_ids is None:
raise RuntimeError("Setting item_ids is required to use this method.")
X.sort_indices()
row, col = X.nonzero()
data = X.data
return pd.DataFrame(
dict(
user_id=[user_ids[r] for r in row],
item_id=[self.item_ids[c] for c in col],
rating=data,
)
)
def df_train(self) -> pd.DataFrame:
return self._X_to_df(self.X_train, self.user_ids)
def df_test(self) -> pd.DataFrame:
return self._X_to_df(self.X_test, self.user_ids)
def concat(
self, other: "UserTrainTestInteractionPair"
) -> "UserTrainTestInteractionPair":
"""Concatenate the users data.
user_id will be ``self.user_ids + self.item_ids``.
Returns:
[type]: [description]
ValueError:
when ``self`` and ``other`` have unequal ``n_items``.
"""
if self.n_items != other.n_items:
raise ValueError("inconsistent n_items.")
return UserTrainTestInteractionPair(
self.user_ids + other.user_ids,
sps.vstack([self.X_train, other.X_train], format="csr"),
sps.vstack([self.X_test, other.X_test], format="csr"),
)
def split_train_test_userwise_random(
df_: pd.DataFrame,
user_colname: str,
item_colname: str,
item_ids: List[Any],
heldout_ratio: float,
n_heldout: Optional[int],
rns: np.random.RandomState,
rating_column: Optional[str] = None,
) -> UserTrainTestInteractionPair:
"""Split the user x item data frame into a pair of sparse matrix (represented as a UserDataSet).
Parameters
----------
df_:
user x item interaction matrix.
user_colname:
The column name for the users.
item_colname:
The column name for the items.
item_id_to_iid:
The mapper from item id to item index. If not supplied, create own mapping from df_.
heldout_ratio:
The percentage of items (per-user) to be held out as a test(validation) ones.
n_heldout:
The maximal number of items (per-user) to be held out as a test(validation) ones.
rns:
The random state
rating_column:
The column for the rating values. If None, the rating values will be all equal (1), by default None
Returns
-------
UserDataSet
Resulting train-test split dataset.
"""
X_all, user_ids, _ = df_to_sparse(
df_,
user_colname=user_colname,
item_colname=item_colname,
item_ids=item_ids,
rating_colname=rating_column,
)
X_learn, X_predict = rowwise_train_test_split(
X_all,
heldout_ratio,
n_heldout,
random_state=rns,
)
return UserTrainTestInteractionPair(
user_ids, X_learn.tocsr(), X_predict.tocsr(), item_ids
)
def split_train_test_userwise_time(
df_: pd.DataFrame,
user_colname: str,
item_colname: str,
time_colname: str,
item_ids: List[Any],
heldout_ratio: float,
n_heldout: Optional[int],
rating_column: Optional[str] = None,
) -> UserTrainTestInteractionPair:
unique_user_ids = np.asarray(list(set(df_[user_colname])))
df_train, df_test = split_last_n_interaction_df(
df_[[user_colname, item_colname, time_colname]],
user_colname,
time_colname,
n_heldout=n_heldout,
heldout_ratio=heldout_ratio,
)
X_train, _, __ = df_to_sparse(
df_train,
user_colname,
item_colname,
user_ids=unique_user_ids,
item_ids=item_ids,
rating_colname=rating_column,
)
X_test, _, __ = df_to_sparse(
df_test,
user_colname,
item_colname,
user_ids=unique_user_ids,
item_ids=item_ids,
rating_colname=rating_column,
)
return UserTrainTestInteractionPair(unique_user_ids, X_train, X_test, item_ids)
def split_dataframe_partial_user_holdout(
df_all: pd.DataFrame,
user_column: str,
item_column: str,
time_column: Optional[str] = None,
rating_column: Optional[str] = None,
n_val_user: Optional[int] = None,
n_test_user: Optional[int] = None,
val_user_ratio: float = 0.1,
test_user_ratio: float = 0.1,
heldout_ratio_val: float = 0.5,
n_heldout_val: Optional[int] = None,
heldout_ratio_test: float = 0.5,
n_heldout_test: Optional[int] = None,
random_state: OptionalRandomState = None,
) -> Tuple[Dict[str, UserTrainTestInteractionPair], List[Any]]:
"""Splits the DataFrame and build an interaction matrix,
holding out random interactions for a subset of randomly selected users
(whom we call "validation users" and "test users").
Args:
df_all:
The user-item interaction event log.
user_column:
The column name for user_id.
item_column:
The column name for movie_id.
time_column:
The column name (if any) specifying the time of the interaction.
If this is set, the split will be based on time, and some of the most recent interactions will be held out for each user.
Defaults to None.
rating_column:
The column name for ratings. If ``None``, the rating will be treated as
``1`` for all interactions. Defaults to None.
n_val_user:
The number of "validation users". Defaults to None.
n_test_user:
The number of "test users". Defaults to None.
val_user_ratio:
The percentage of "validation users" with respect to all users.
Ignored when ``n_val_user`` is set. Defaults to 0.1.
test_user_ratio:
The percentage of "test users" with respect to all users.
Ignored when ``n_text_user`` is set. Defaults to 0.1.
heldout_ratio_val:
The percentage of held-out interactions for "validation users".
Ignored if ``n_heldout_val`` is specified. Defaults to 0.5.
n_heldout_val:
The maximal number of held-out interactions for "validation users".
heldout_ratio_test:
The percentage of held-out interactions for "test users".
Ignored if ``n_heldout_test`` is specified. Defaults to 0.5.
n_heldout_val:
The maximal number of held-out interactions for "test users".
random_state:
The random state for this procedure. Defaults to `None`.
Raises:
ValueError: When ``n_val_user + n_test_user`` is greater than the number of total users.
Returns:
A tuple consisting of:
1. A dictionary with ``"train"``, ``"val"``, ``"test"`` as its keys and the
coressponding dataset as its values.
2. List of unique item ids (which corresponds to the columns of the datasets).
"""
assert (test_user_ratio <= 1) and (test_user_ratio >= 0)
assert (val_user_ratio <= 1) and (val_user_ratio >= 0)
uids: List[Any] = df_all[user_column].unique()
n_users_all = len(uids)
if n_val_user is None:
n_val_user = int(n_users_all * val_user_ratio)
val_user_ratio = n_val_user / n_users_all
else:
if n_val_user > n_users_all:
raise ValueError("n_val_user exceeds the number of total users.")
if n_test_user is None:
n_test_user = int(n_users_all * test_user_ratio)
test_user_ratio = n_test_user / n_users_all
else:
if (n_test_user + n_val_user) > n_users_all:
raise ValueError(
"n_val_user + n_test_users exceeds the number of total users."
)
df_all = df_all.drop_duplicates([user_column, item_column])
rns = convert_randomstate(random_state)
train_uids, val_test_uids = _split_list(uids, (n_val_user + n_test_user), rns)
if (test_user_ratio * len(uids)) >= 1:
val_uids, test_uids = _split_list(
val_test_uids,
n_test_user,
rns,
)
else:
val_uids = val_test_uids
test_uids = np.asarray([])
df_train = df_all[df_all[user_column].isin(train_uids)].copy()
df_val = df_all[df_all[user_column].isin(val_uids)].copy()
df_test = df_all[df_all[user_column].isin(test_uids)].copy()
item_all: List[Any] = list(set(df_all[item_column]))
train_user_interactions, _, __ = df_to_sparse(
df_train, user_column, item_column, user_ids=train_uids, item_ids=item_all
)
valid_data: Dict[str, UserTrainTestInteractionPair] = dict(
train=UserTrainTestInteractionPair(train_uids, train_user_interactions, None)
)
val_test_info_: List[Tuple[pd.DataFrame, str, float, Optional[int]]] = [
(df_val, "val", heldout_ratio_val, n_heldout_val),
(df_test, "test", heldout_ratio_test, n_heldout_test),
]
for df_, dataset_name, heldout_ratio, n_heldout in val_test_info_:
if time_column is None:
valid_data[dataset_name] = split_train_test_userwise_random(
df_,
user_column,
item_column,
item_all,
heldout_ratio,
n_heldout,
rns,
rating_column=rating_column,
)
else:
valid_data[dataset_name] = split_train_test_userwise_time(
df_,
user_column,
item_column,
time_column,
item_all,
heldout_ratio,
n_heldout,
rating_column=rating_column,
)
return valid_data, item_all
| [
1,
529,
276,
1112,
420,
29958,
6277,
557,
3660,
29914,
381,
1028,
547,
13,
3166,
19229,
1053,
3139,
29892,
360,
919,
29892,
2391,
29892,
28379,
29892,
12603,
552,
13,
13,
5215,
12655,
408,
7442,
13,
5215,
11701,
408,
10518,
13,
3166,
12655,
29889,
1982,
29889,
2378,
842,
3554,
1053,
5412,
13,
3166,
4560,
2272,
1053,
29234,
408,
269,
567,
13,
13,
3166,
3805,
1028,
547,
29889,
25476,
2187,
1053,
4124,
2467,
14609,
29892,
28379,
17875,
2792,
13,
3166,
3805,
1028,
547,
29889,
5451,
29889,
2230,
1053,
6219,
29918,
4230,
29918,
29876,
29918,
1639,
2467,
29918,
2176,
13,
3166,
3805,
1028,
547,
29889,
13239,
1053,
4489,
29918,
517,
29918,
29879,
5510,
29892,
696,
1615,
895,
29918,
14968,
29918,
1688,
29918,
5451,
13,
3166,
3805,
1028,
547,
29889,
13239,
29889,
8172,
1053,
3588,
29918,
8172,
3859,
13,
13,
13,
1753,
903,
5451,
29918,
1761,
29898,
13,
1678,
18999,
29901,
2391,
29961,
10773,
1402,
1243,
29918,
2311,
29901,
938,
29892,
364,
1983,
29901,
7442,
29889,
8172,
29889,
17875,
2792,
13,
29897,
1599,
12603,
552,
29961,
1293,
29961,
10773,
1402,
2391,
29961,
10773,
5262,
29901,
13,
1678,
364,
1983,
29889,
845,
21897,
29898,
4841,
29897,
13,
1678,
736,
18999,
29961,
1688,
29918,
2311,
29901,
1402,
18999,
7503,
1688,
29918,
2311,
29962,
13,
13,
13,
1990,
4911,
5323,
262,
3057,
4074,
2467,
20547,
29901,
13,
1678,
9995,
29909,
770,
304,
4808,
4160,
29915,
7945,
669,
1243,
313,
361,
738,
29897,
22060,
322,
1009,
18999,
29889,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
1404,
29918,
4841,
29901,
13,
9651,
2391,
310,
1404,
18999,
29889,
8011,
4954,
29875,
16159,
29899,
386,
1543,
881,
3928,
304,
4954,
29875,
16159,
29899,
386,
1948,
13,
9651,
310,
4954,
29990,
29918,
14968,
29952,
1412,
13,
4706,
1060,
29918,
14968,
29901,
13,
9651,
450,
7945,
760,
310,
22060,
29889,
13,
4706,
1060,
29918,
1688,
29901,
13,
9651,
450,
1243,
760,
310,
22060,
313,
361,
738,
467,
13,
9651,
960,
4954,
8516,
29952,
1673,
385,
4069,
4636,
411,
278,
8267,
310,
4954,
29990,
29918,
14968,
16159,
13,
9651,
674,
367,
2825,
29889,
13109,
29879,
304,
6213,
29889,
13,
13,
1678,
390,
1759,
267,
29901,
13,
4706,
7865,
2392,
29901,
13,
9651,
746,
4954,
29990,
29918,
14968,
16159,
322,
4954,
1792,
29918,
4841,
16159,
505,
22435,
9696,
2159,
29889,
13,
4706,
7865,
2392,
29901,
13,
9651,
746,
4954,
29990,
29918,
14968,
16159,
322,
4954,
29990,
29918,
1688,
16159,
505,
22435,
9696,
2159,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
1060,
29918,
14968,
29901,
269,
567,
29889,
2395,
29878,
29918,
5344,
13,
1678,
9995,
1576,
7945,
760,
310,
4160,
29915,
22060,
1213,
15945,
13,
1678,
1060,
29918,
1688,
29901,
269,
567,
29889,
2395,
29878,
29918,
5344,
13,
1678,
9995,
1576,
1243,
760,
310,
4160,
29915,
22060,
1213,
15945,
13,
1678,
302,
29918,
7193,
29901,
938,
13,
1678,
9995,
1576,
1353,
310,
4160,
15945,
29908,
13,
1678,
302,
29918,
7076,
29901,
938,
13,
1678,
9995,
1576,
1353,
310,
4452,
15945,
29908,
13,
1678,
1060,
29918,
497,
29901,
269,
567,
29889,
2395,
29878,
29918,
5344,
13,
1678,
9995,
3644,
4954,
29990,
29918,
1688,
16159,
338,
451,
4954,
8516,
29952,
1673,
5186,
304,
4954,
29990,
29918,
14968,
718,
1060,
29918,
1688,
29952,
1412,
16107,
3538,
15743,
1060,
29918,
14968,
1213,
15945,
13,
13,
1678,
822,
4770,
2344,
12035,
13,
4706,
1583,
29892,
13,
4706,
1404,
29918,
4841,
29901,
2391,
29961,
10773,
1402,
13,
4706,
1060,
29918,
14968,
29901,
4124,
2467,
14609,
29892,
13,
4706,
1060,
29918,
1688,
29901,
28379,
29961,
4074,
2467,
14609,
1402,
13,
4706,
2944,
29918,
4841,
29901,
28379,
29961,
1293,
29961,
10773,
5262,
353,
6213,
29892,
13,
268,
1125,
13,
13,
4706,
565,
7431,
29898,
1792,
29918,
4841,
29897,
2804,
1060,
29918,
14968,
29889,
12181,
29961,
29900,
5387,
13,
9651,
12020,
7865,
2392,
703,
1792,
29918,
4841,
322,
1060,
29918,
14968,
505,
1422,
25834,
23157,
13,
13,
4706,
565,
1060,
29918,
1688,
338,
451,
6213,
29901,
13,
9651,
565,
1060,
29918,
14968,
29889,
12181,
2804,
1060,
29918,
1688,
29889,
12181,
29901,
13,
18884,
12020,
7865,
2392,
703,
29990,
29918,
14968,
322,
1060,
29918,
1688,
505,
1422,
25834,
23157,
13,
9651,
1060,
29918,
1688,
353,
269,
567,
29889,
2395,
29878,
29918,
5344,
29898,
29990,
29918,
1688,
29897,
13,
4706,
1683,
29901,
13,
9651,
1060,
29918,
1688,
353,
269,
567,
29889,
2395,
29878,
29918,
5344,
29898,
29990,
29918,
14968,
29889,
12181,
29892,
26688,
29922,
29990,
29918,
14968,
29889,
29881,
1853,
29897,
13,
4706,
1583,
29889,
1792,
29918,
4841,
353,
518,
29916,
363,
921,
297,
1404,
29918,
4841,
29962,
13,
4706,
1583,
29889,
29990,
29918,
14968,
353,
269,
567,
29889,
2395,
29878,
29918,
5344,
29898,
29990,
29918,
14968,
29897,
13,
4706,
1583,
29889,
29990,
29918,
1688,
353,
1060,
29918,
1688,
13,
4706,
1583,
29889,
29876,
29918,
7193,
353,
1583,
29889,
29990,
29918,
14968,
29889,
12181,
29961,
29900,
29962,
13,
4706,
1583,
29889,
29876,
29918,
7076,
353,
1583,
29889,
29990,
29918,
14968,
29889,
12181,
29961,
29896,
29962,
13,
4706,
1583,
29889,
29990,
29918,
497,
353,
269,
567,
29889,
2395,
29878,
29918,
5344,
29898,
1311,
29889,
29990,
29918,
14968,
718,
1583,
29889,
29990,
29918,
1688,
29897,
13,
4706,
565,
2944,
29918,
4841,
338,
451,
6213,
29901,
13,
9651,
565,
7431,
29898,
667,
29918,
4841,
29897,
2804,
1583,
29889,
29990,
29918,
1688,
29889,
12181,
29961,
29896,
5387,
13,
18884,
12020,
7865,
2392,
703,
29990,
29918,
14968,
29889,
12181,
29961,
29896,
29962,
2804,
7431,
29898,
667,
29918,
4841,
25760,
13,
4706,
1583,
29889,
667,
29918,
4841,
353,
2944,
29918,
4841,
13,
13,
1678,
822,
903,
29990,
29918,
517,
29918,
2176,
29898,
1311,
29892,
1060,
29901,
269,
567,
29889,
2395,
29878,
29918,
5344,
29892,
1404,
29918,
4841,
29901,
2391,
29961,
10773,
2314,
1599,
10518,
29889,
17271,
29901,
13,
4706,
565,
1583,
29889,
667,
29918,
4841,
338,
6213,
29901,
13,
9651,
12020,
24875,
2392,
703,
29020,
2944,
29918,
4841,
338,
3734,
304,
671,
445,
1158,
23157,
13,
4706,
1060,
29889,
6605,
29918,
513,
1575,
580,
13,
4706,
1948,
29892,
784,
353,
1060,
29889,
5464,
9171,
580,
13,
4706,
848,
353,
1060,
29889,
1272,
13,
4706,
736,
10518,
29889,
17271,
29898,
13,
9651,
9657,
29898,
13,
18884,
1404,
29918,
333,
11759,
1792,
29918,
4841,
29961,
29878,
29962,
363,
364,
297,
1948,
1402,
13,
18884,
2944,
29918,
333,
11759,
1311,
29889,
667,
29918,
4841,
29961,
29883,
29962,
363,
274,
297,
784,
1402,
13,
18884,
21700,
29922,
1272,
29892,
13,
9651,
1723,
13,
4706,
1723,
13,
13,
1678,
822,
4489,
29918,
14968,
29898,
1311,
29897,
1599,
10518,
29889,
17271,
29901,
13,
4706,
736,
1583,
3032,
29990,
29918,
517,
29918,
2176,
29898,
1311,
29889,
29990,
29918,
14968,
29892,
1583,
29889,
1792,
29918,
4841,
29897,
13,
13,
1678,
822,
4489,
29918,
1688,
29898,
1311,
29897,
1599,
10518,
29889,
17271,
29901,
13,
4706,
736,
1583,
3032,
29990,
29918,
517,
29918,
2176,
29898,
1311,
29889,
29990,
29918,
1688,
29892,
1583,
29889,
1792,
29918,
4841,
29897,
13,
13,
1678,
822,
3022,
271,
29898,
13,
4706,
1583,
29892,
916,
29901,
376,
2659,
5323,
262,
3057,
4074,
2467,
20547,
29908,
13,
1678,
1723,
1599,
376,
2659,
5323,
262,
3057,
4074,
2467,
20547,
1115,
13,
4706,
9995,
1168,
29883,
2579,
403,
278,
4160,
848,
29889,
13,
4706,
1404,
29918,
333,
674,
367,
4954,
1311,
29889,
1792,
29918,
4841,
718,
1583,
29889,
667,
29918,
4841,
29952,
1412,
13,
13,
4706,
16969,
29901,
13,
9651,
518,
1853,
5387,
518,
8216,
29962,
13,
13,
4706,
7865,
2392,
29901,
13,
9651,
746,
4954,
1311,
16159,
322,
4954,
1228,
16159,
505,
1597,
15380,
4954,
29876,
29918,
7076,
29952,
1412,
13,
4706,
9995,
13,
4706,
565,
1583,
29889,
29876,
29918,
7076,
2804,
916,
29889,
29876,
29918,
7076,
29901,
13,
9651,
12020,
7865,
2392,
703,
262,
3200,
9696,
302,
29918,
7076,
23157,
13,
4706,
736,
4911,
5323,
262,
3057,
4074,
2467,
20547,
29898,
13,
9651,
1583,
29889,
1792,
29918,
4841,
718,
916,
29889,
1792,
29918,
4841,
29892,
13,
9651,
269,
567,
29889,
29894,
1429,
4197,
1311,
29889,
29990,
29918,
14968,
29892,
916,
29889,
29990,
29918,
14968,
1402,
3402,
543,
2395,
29878,
4968,
13,
9651,
269,
567,
29889,
29894,
1429,
4197,
1311,
29889,
29990,
29918,
1688,
29892,
916,
29889,
29990,
29918,
1688,
1402,
3402,
543,
2395,
29878,
4968,
13,
4706,
1723,
13,
13,
13,
1753,
6219,
29918,
14968,
29918,
1688,
29918,
1792,
3538,
29918,
8172,
29898,
13,
1678,
4489,
29918,
29901,
10518,
29889,
17271,
29892,
13,
1678,
1404,
29918,
1054,
978,
29901,
851,
29892,
13,
1678,
2944,
29918,
1054,
978,
29901,
851,
29892,
13,
1678,
2944,
29918,
4841,
29901,
2391,
29961,
10773,
1402,
13,
1678,
4934,
449,
29918,
3605,
601,
29901,
5785,
29892,
13,
1678,
302,
29918,
29882,
2495,
449,
29901,
28379,
29961,
524,
1402,
13,
1678,
364,
1983,
29901,
7442,
29889,
8172,
29889,
17875,
2792,
29892,
13,
1678,
21700,
29918,
4914,
29901,
28379,
29961,
710,
29962,
353,
6213,
29892,
13,
29897,
1599,
4911,
5323,
262,
3057,
4074,
2467,
20547,
29901,
13,
1678,
9995,
18772,
278,
1404,
921,
2944,
848,
3515,
964,
263,
5101,
310,
29234,
4636,
313,
276,
6338,
287,
408,
263,
4911,
28449,
467,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
4489,
29918,
29901,
13,
4706,
1404,
921,
2944,
14881,
4636,
29889,
13,
1678,
1404,
29918,
1054,
978,
29901,
13,
4706,
450,
1897,
1024,
363,
278,
4160,
29889,
13,
1678,
2944,
29918,
1054,
978,
29901,
13,
4706,
450,
1897,
1024,
363,
278,
4452,
29889,
13,
1678,
2944,
29918,
333,
29918,
517,
29918,
29875,
333,
29901,
13,
4706,
450,
611,
2496,
515,
2944,
1178,
304,
2944,
2380,
29889,
960,
451,
19056,
29892,
1653,
1914,
10417,
515,
4489,
5396,
13,
1678,
4934,
449,
29918,
3605,
601,
29901,
13,
4706,
450,
19649,
310,
4452,
313,
546,
29899,
1792,
29897,
304,
367,
4934,
714,
408,
263,
1243,
29898,
18157,
29897,
6743,
29889,
13,
1678,
302,
29918,
29882,
2495,
449,
29901,
13,
4706,
450,
23183,
1353,
310,
4452,
313,
546,
29899,
1792,
29897,
304,
367,
4934,
714,
408,
263,
1243,
29898,
18157,
29897,
6743,
29889,
13,
1678,
364,
1983,
29901,
13,
4706,
450,
4036,
2106,
13,
1678,
21700,
29918,
4914,
29901,
13,
4706,
450,
1897,
363,
278,
21700,
1819,
29889,
960,
6213,
29892,
278,
21700,
1819,
674,
367,
599,
5186,
313,
29896,
511,
491,
2322,
6213,
13,
1678,
16969,
13,
1678,
448,
22158,
13,
1678,
4911,
28449,
13,
4706,
7867,
292,
7945,
29899,
1688,
6219,
8783,
29889,
13,
1678,
9995,
13,
1678,
1060,
29918,
497,
29892,
1404,
29918,
4841,
29892,
903,
353,
4489,
29918,
517,
29918,
29879,
5510,
29898,
13,
4706,
4489,
3383,
13,
4706,
1404,
29918,
1054,
978,
29922,
1792,
29918,
1054,
978,
29892,
13,
4706,
2944,
29918,
1054,
978,
29922,
667,
29918,
1054,
978,
29892,
13,
4706,
2944,
29918,
4841,
29922,
667,
29918,
4841,
29892,
13,
4706,
21700,
29918,
1054,
978,
29922,
29741,
29918,
4914,
29892,
13,
1678,
1723,
13,
13,
1678,
1060,
29918,
19668,
29892,
1060,
29918,
27711,
353,
696,
1615,
895,
29918,
14968,
29918,
1688,
29918,
5451,
29898,
13,
4706,
1060,
29918,
497,
29892,
13,
4706,
4934,
449,
29918,
3605,
601,
29892,
13,
4706,
302,
29918,
29882,
2495,
449,
29892,
13,
4706,
4036,
29918,
3859,
29922,
29878,
1983,
29892,
13,
1678,
1723,
13,
13,
1678,
736,
4911,
5323,
262,
3057,
4074,
2467,
20547,
29898,
13,
4706,
1404,
29918,
4841,
29892,
1060,
29918,
19668,
29889,
517,
2395,
29878,
3285,
1060,
29918,
27711,
29889,
517,
2395,
29878,
3285,
2944,
29918,
4841,
13,
1678,
1723,
13,
13,
13,
1753,
6219,
29918,
14968,
29918,
1688,
29918,
1792,
3538,
29918,
2230,
29898,
13,
1678,
4489,
29918,
29901,
10518,
29889,
17271,
29892,
13,
1678,
1404,
29918,
1054,
978,
29901,
851,
29892,
13,
1678,
2944,
29918,
1054,
978,
29901,
851,
29892,
13,
1678,
931,
29918,
1054,
978,
29901,
851,
29892,
13,
1678,
2944,
29918,
4841,
29901,
2391,
29961,
10773,
1402,
13,
1678,
4934,
449,
29918,
3605,
601,
29901,
5785,
29892,
13,
1678,
302,
29918,
29882,
2495,
449,
29901,
28379,
29961,
524,
1402,
13,
1678,
21700,
29918,
4914,
29901,
28379,
29961,
710,
29962,
353,
6213,
29892,
13,
29897,
1599,
4911,
5323,
262,
3057,
4074,
2467,
20547,
29901,
13,
1678,
5412,
29918,
1792,
29918,
4841,
353,
7442,
29889,
294,
2378,
29898,
1761,
29898,
842,
29898,
2176,
29918,
29961,
1792,
29918,
1054,
978,
29962,
4961,
13,
1678,
4489,
29918,
14968,
29892,
4489,
29918,
1688,
353,
6219,
29918,
4230,
29918,
29876,
29918,
1639,
2467,
29918,
2176,
29898,
13,
4706,
4489,
29918,
8999,
1792,
29918,
1054,
978,
29892,
2944,
29918,
1054,
978,
29892,
931,
29918,
1054,
978,
20526,
13,
4706,
1404,
29918,
1054,
978,
29892,
13,
4706,
931,
29918,
1054,
978,
29892,
13,
4706,
302,
29918,
29882,
2495,
449,
29922,
29876,
29918,
29882,
2495,
449,
29892,
13,
4706,
4934,
449,
29918,
3605,
601,
29922,
29882,
2495,
449,
29918,
3605,
601,
29892,
13,
1678,
1723,
13,
1678,
1060,
29918,
14968,
29892,
17117,
4770,
353,
4489,
29918,
517,
29918,
29879,
5510,
29898,
13,
4706,
4489,
29918,
14968,
29892,
13,
4706,
1404,
29918,
1054,
978,
29892,
13,
4706,
2944,
29918,
1054,
978,
29892,
13,
4706,
1404,
29918,
4841,
29922,
13092,
29918,
1792,
29918,
4841,
29892,
13,
4706,
2944,
29918,
4841,
29922,
667,
29918,
4841,
29892,
13,
4706,
21700,
29918,
1054,
978,
29922,
29741,
29918,
4914,
29892,
13,
1678,
1723,
13,
1678,
1060,
29918,
1688,
29892,
17117,
4770,
353,
4489,
29918,
517,
29918,
29879,
5510,
29898,
13,
4706,
4489,
29918,
1688,
29892,
13,
4706,
1404,
29918,
1054,
978,
29892,
13,
4706,
2944,
29918,
1054,
978,
29892,
13,
4706,
1404,
29918,
4841,
29922,
13092,
29918,
1792,
29918,
4841,
29892,
13,
4706,
2944,
29918,
4841,
29922,
667,
29918,
4841,
29892,
13,
4706,
21700,
29918,
1054,
978,
29922,
29741,
29918,
4914,
29892,
13,
1678,
1723,
13,
13,
1678,
736,
4911,
5323,
262,
3057,
4074,
2467,
20547,
29898,
13092,
29918,
1792,
29918,
4841,
29892,
1060,
29918,
14968,
29892,
1060,
29918,
1688,
29892,
2944,
29918,
4841,
29897,
13,
13,
13,
1753,
6219,
29918,
1272,
2557,
29918,
3846,
29918,
1792,
29918,
8948,
449,
29898,
13,
1678,
4489,
29918,
497,
29901,
10518,
29889,
17271,
29892,
13,
1678,
1404,
29918,
4914,
29901,
851,
29892,
13,
1678,
2944,
29918,
4914,
29901,
851,
29892,
13,
1678,
931,
29918,
4914,
29901,
28379,
29961,
710,
29962,
353,
6213,
29892,
13,
1678,
21700,
29918,
4914,
29901,
28379,
29961,
710,
29962,
353,
6213,
29892,
13,
1678,
302,
29918,
791,
29918,
1792,
29901,
28379,
29961,
524,
29962,
353,
6213,
29892,
13,
1678,
302,
29918,
1688,
29918,
1792,
29901,
28379,
29961,
524,
29962,
353,
6213,
29892,
13,
1678,
659,
29918,
1792,
29918,
3605,
601,
29901,
5785,
353,
29871,
29900,
29889,
29896,
29892,
13,
1678,
1243,
29918,
1792,
29918,
3605,
601,
29901,
5785,
353,
29871,
29900,
29889,
29896,
29892,
13,
1678,
4934,
449,
29918,
3605,
601,
29918,
791,
29901,
5785,
353,
29871,
29900,
29889,
29945,
29892,
13,
1678,
302,
29918,
29882,
2495,
449,
29918,
791,
29901,
28379,
29961,
524,
29962,
353,
6213,
29892,
13,
1678,
4934,
449,
29918,
3605,
601,
29918,
1688,
29901,
5785,
353,
29871,
29900,
29889,
29945,
29892,
13,
1678,
302,
29918,
29882,
2495,
449,
29918,
1688,
29901,
28379,
29961,
524,
29962,
353,
6213,
29892,
13,
1678,
4036,
29918,
3859,
29901,
28379,
17875,
2792,
353,
6213,
29892,
13,
29897,
1599,
12603,
552,
29961,
21533,
29961,
710,
29892,
4911,
5323,
262,
3057,
4074,
2467,
20547,
1402,
2391,
29961,
10773,
5262,
29901,
13,
1678,
9995,
29903,
572,
1169,
278,
3630,
4308,
322,
2048,
385,
14881,
4636,
29892,
13,
1678,
13587,
714,
4036,
22060,
363,
263,
11306,
310,
20459,
4629,
4160,
13,
1678,
313,
1332,
290,
591,
1246,
376,
18157,
4160,
29908,
322,
376,
1688,
4160,
2564,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
4489,
29918,
497,
29901,
13,
9651,
450,
1404,
29899,
667,
14881,
1741,
1480,
29889,
13,
4706,
1404,
29918,
4914,
29901,
13,
9651,
450,
1897,
1024,
363,
1404,
29918,
333,
29889,
13,
4706,
2944,
29918,
4914,
29901,
13,
9651,
450,
1897,
1024,
363,
14064,
29918,
333,
29889,
13,
4706,
931,
29918,
4914,
29901,
13,
9651,
450,
1897,
1024,
313,
361,
738,
29897,
22146,
278,
931,
310,
278,
14881,
29889,
13,
9651,
960,
445,
338,
731,
29892,
278,
6219,
674,
367,
2729,
373,
931,
29892,
322,
777,
310,
278,
1556,
7786,
22060,
674,
367,
4934,
714,
363,
1269,
1404,
29889,
13,
9651,
13109,
29879,
304,
6213,
29889,
13,
4706,
21700,
29918,
4914,
29901,
13,
9651,
450,
1897,
1024,
363,
26838,
29889,
960,
4954,
8516,
29952,
1673,
278,
21700,
674,
367,
14914,
408,
13,
9651,
4954,
29896,
16159,
363,
599,
22060,
29889,
13109,
29879,
304,
6213,
29889,
13,
4706,
302,
29918,
791,
29918,
1792,
29901,
13,
9651,
450,
1353,
310,
376,
18157,
4160,
1642,
13109,
29879,
304,
6213,
29889,
13,
4706,
302,
29918,
1688,
29918,
1792,
29901,
13,
9651,
450,
1353,
310,
376,
1688,
4160,
1642,
13109,
29879,
304,
6213,
29889,
13,
4706,
659,
29918,
1792,
29918,
3605,
601,
29901,
13,
9651,
450,
19649,
310,
376,
18157,
4160,
29908,
411,
3390,
304,
599,
4160,
29889,
13,
9651,
18076,
4395,
746,
4954,
29876,
29918,
791,
29918,
1792,
16159,
338,
731,
29889,
13109,
29879,
304,
29871,
29900,
29889,
29896,
29889,
13,
4706,
1243,
29918,
1792,
29918,
3605,
601,
29901,
13,
9651,
450,
19649,
310,
376,
1688,
4160,
29908,
411,
3390,
304,
599,
4160,
29889,
13,
9651,
18076,
4395,
746,
4954,
29876,
29918,
726,
29918,
1792,
16159,
338,
731,
29889,
13109,
29879,
304,
29871,
29900,
29889,
29896,
29889,
13,
4706,
4934,
449,
29918,
3605,
601,
29918,
791,
29901,
13,
9651,
450,
19649,
310,
4934,
29899,
449,
22060,
363,
376,
18157,
4160,
1642,
13,
9651,
18076,
4395,
565,
4954,
29876,
29918,
29882,
2495,
449,
29918,
791,
16159,
338,
6790,
29889,
13109,
29879,
304,
29871,
29900,
29889,
29945,
29889,
13,
4706,
302,
29918,
29882,
2495,
449,
29918,
791,
29901,
13,
9651,
450,
23183,
1353,
310,
4934,
29899,
449,
22060,
363,
376,
18157,
4160,
1642,
13,
4706,
4934,
449,
29918,
3605,
601,
29918,
1688,
29901,
13,
9651,
450,
19649,
310,
4934,
29899,
449,
22060,
363,
376,
1688,
4160,
1642,
13,
9651,
18076,
4395,
565,
4954,
29876,
29918,
29882,
2495,
449,
29918,
1688,
16159,
338,
6790,
29889,
13109,
29879,
304,
29871,
29900,
29889,
29945,
29889,
13,
4706,
302,
29918,
29882,
2495,
449,
29918,
791,
29901,
13,
9651,
450,
23183,
1353,
310,
4934,
29899,
449,
22060,
363,
376,
1688,
4160,
1642,
13,
4706,
4036,
29918,
3859,
29901,
13,
9651,
450,
4036,
2106,
363,
445,
8792,
29889,
13109,
29879,
304,
421,
8516,
1412,
13,
13,
1678,
390,
1759,
267,
29901,
13,
4706,
7865,
2392,
29901,
1932,
4954,
29876,
29918,
791,
29918,
1792,
718,
302,
29918,
1688,
29918,
1792,
16159,
338,
7621,
1135,
278,
1353,
310,
3001,
4160,
29889,
13,
13,
1678,
16969,
29901,
13,
4706,
319,
18761,
19849,
310,
29901,
13,
13,
632,
29896,
29889,
319,
8600,
411,
4954,
29908,
14968,
6937,
1673,
4954,
29908,
791,
6937,
1673,
4954,
29908,
1688,
6937,
29952,
408,
967,
6611,
322,
278,
13,
1669,
1034,
404,
2818,
292,
8783,
408,
967,
1819,
29889,
13,
632,
29906,
29889,
2391,
310,
5412,
2944,
18999,
313,
4716,
16161,
304,
278,
4341,
310,
278,
20035,
467,
13,
1678,
9995,
13,
1678,
4974,
313,
1688,
29918,
1792,
29918,
3605,
601,
5277,
29871,
29896,
29897,
322,
313,
1688,
29918,
1792,
29918,
3605,
601,
6736,
29871,
29900,
29897,
13,
1678,
4974,
313,
791,
29918,
1792,
29918,
3605,
601,
5277,
29871,
29896,
29897,
322,
313,
791,
29918,
1792,
29918,
3605,
601,
6736,
29871,
29900,
29897,
13,
13,
1678,
318,
4841,
29901,
2391,
29961,
10773,
29962,
353,
4489,
29918,
497,
29961,
1792,
29918,
4914,
1822,
13092,
580,
13,
1678,
302,
29918,
7193,
29918,
497,
353,
7431,
29898,
29884,
4841,
29897,
13,
1678,
565,
302,
29918,
791,
29918,
1792,
338,
6213,
29901,
13,
4706,
302,
29918,
791,
29918,
1792,
353,
938,
29898,
29876,
29918,
7193,
29918,
497,
334,
659,
29918,
1792,
29918,
3605,
601,
29897,
13,
4706,
659,
29918,
1792,
29918,
3605,
601,
353,
302,
29918,
791,
29918,
1792,
847,
302,
29918,
7193,
29918,
497,
13,
1678,
1683,
29901,
13,
4706,
565,
302,
29918,
791,
29918,
1792,
1405,
302,
29918,
7193,
29918,
497,
29901,
13,
9651,
12020,
7865,
2392,
703,
29876,
29918,
791,
29918,
1792,
13461,
29879,
278,
1353,
310,
3001,
4160,
23157,
13,
13,
1678,
565,
302,
29918,
1688,
29918,
1792,
338,
6213,
29901,
13,
4706,
302,
29918,
1688,
29918,
1792,
353,
938,
29898,
29876,
29918,
7193,
29918,
497,
334,
1243,
29918,
1792,
29918,
3605,
601,
29897,
13,
4706,
1243,
29918,
1792,
29918,
3605,
601,
353,
302,
29918,
1688,
29918,
1792,
847,
302,
29918,
7193,
29918,
497,
13,
1678,
1683,
29901,
13,
4706,
565,
313,
29876,
29918,
1688,
29918,
1792,
718,
302,
29918,
791,
29918,
1792,
29897,
1405,
302,
29918,
7193,
29918,
497,
29901,
13,
9651,
12020,
7865,
2392,
29898,
13,
18884,
376,
29876,
29918,
791,
29918,
1792,
718,
302,
29918,
1688,
29918,
7193,
13461,
29879,
278,
1353,
310,
3001,
4160,
1213,
13,
9651,
1723,
13,
13,
1678,
4489,
29918,
497,
353,
4489,
29918,
497,
29889,
8865,
29918,
20908,
15815,
4197,
1792,
29918,
4914,
29892,
2944,
29918,
4914,
2314,
13,
1678,
364,
1983,
353,
3588,
29918,
8172,
3859,
29898,
8172,
29918,
3859,
29897,
13,
13,
1678,
7945,
29918,
29884,
4841,
29892,
659,
29918,
1688,
29918,
29884,
4841,
353,
903,
5451,
29918,
1761,
29898,
29884,
4841,
29892,
313,
29876,
29918,
791,
29918,
1792,
718,
302,
29918,
1688,
29918,
1792,
511,
364,
1983,
29897,
13,
13,
1678,
565,
313,
1688,
29918,
1792,
29918,
3605,
601,
334,
7431,
29898,
29884,
4841,
876,
6736,
29871,
29896,
29901,
13,
4706,
659,
29918,
29884,
4841,
29892,
1243,
29918,
29884,
4841,
353,
903,
5451,
29918,
1761,
29898,
13,
9651,
659,
29918,
1688,
29918,
29884,
4841,
29892,
13,
9651,
302,
29918,
1688,
29918,
1792,
29892,
13,
9651,
364,
1983,
29892,
13,
4706,
1723,
13,
1678,
1683,
29901,
13,
4706,
659,
29918,
29884,
4841,
353,
659,
29918,
1688,
29918,
29884,
4841,
13,
4706,
1243,
29918,
29884,
4841,
353,
7442,
29889,
294,
2378,
4197,
2314,
13,
1678,
4489,
29918,
14968,
353,
4489,
29918,
497,
29961,
2176,
29918,
497,
29961,
1792,
29918,
4914,
1822,
275,
262,
29898,
14968,
29918,
29884,
4841,
29897,
1822,
8552,
580,
13,
1678,
4489,
29918,
791,
353,
4489,
29918,
497,
29961,
2176,
29918,
497,
29961,
1792,
29918,
4914,
1822,
275,
262,
29898,
791,
29918,
29884,
4841,
29897,
1822,
8552,
580,
13,
1678,
4489,
29918,
1688,
353,
4489,
29918,
497,
29961,
2176,
29918,
497,
29961,
1792,
29918,
4914,
1822,
275,
262,
29898,
1688,
29918,
29884,
4841,
29897,
1822,
8552,
580,
13,
1678,
2944,
29918,
497,
29901,
2391,
29961,
10773,
29962,
353,
1051,
29898,
842,
29898,
2176,
29918,
497,
29961,
667,
29918,
4914,
12622,
13,
13,
1678,
7945,
29918,
1792,
29918,
1639,
7387,
29892,
17117,
4770,
353,
4489,
29918,
517,
29918,
29879,
5510,
29898,
13,
4706,
4489,
29918,
14968,
29892,
1404,
29918,
4914,
29892,
2944,
29918,
4914,
29892,
1404,
29918,
4841,
29922,
14968,
29918,
29884,
4841,
29892,
2944,
29918,
4841,
29922,
667,
29918,
497,
13,
1678,
1723,
13,
13,
1678,
2854,
29918,
1272,
29901,
360,
919,
29961,
710,
29892,
4911,
5323,
262,
3057,
4074,
2467,
20547,
29962,
353,
9657,
29898,
13,
4706,
7945,
29922,
2659,
5323,
262,
3057,
4074,
2467,
20547,
29898,
14968,
29918,
29884,
4841,
29892,
7945,
29918,
1792,
29918,
1639,
7387,
29892,
6213,
29897,
13,
1678,
1723,
13,
1678,
659,
29918,
1688,
29918,
3888,
29918,
29901,
2391,
29961,
23215,
552,
29961,
15926,
29889,
17271,
29892,
851,
29892,
5785,
29892,
28379,
29961,
524,
5262,
29962,
353,
518,
13,
4706,
313,
2176,
29918,
791,
29892,
376,
791,
613,
4934,
449,
29918,
3605,
601,
29918,
791,
29892,
302,
29918,
29882,
2495,
449,
29918,
791,
511,
13,
4706,
313,
2176,
29918,
1688,
29892,
376,
1688,
613,
4934,
449,
29918,
3605,
601,
29918,
1688,
29892,
302,
29918,
29882,
2495,
449,
29918,
1688,
511,
13,
1678,
4514,
13,
1678,
363,
4489,
3383,
8783,
29918,
978,
29892,
4934,
449,
29918,
3605,
601,
29892,
302,
29918,
29882,
2495,
449,
297,
659,
29918,
1688,
29918,
3888,
29918,
29901,
13,
4706,
565,
931,
29918,
4914,
338,
6213,
29901,
13,
9651,
2854,
29918,
1272,
29961,
24713,
29918,
978,
29962,
353,
6219,
29918,
14968,
29918,
1688,
29918,
1792,
3538,
29918,
8172,
29898,
13,
18884,
4489,
3383,
13,
18884,
1404,
29918,
4914,
29892,
13,
18884,
2944,
29918,
4914,
29892,
13,
18884,
2944,
29918,
497,
29892,
13,
18884,
4934,
449,
29918,
3605,
601,
29892,
13,
18884,
302,
29918,
29882,
2495,
449,
29892,
13,
18884,
364,
1983,
29892,
13,
18884,
21700,
29918,
4914,
29922,
29741,
29918,
4914,
29892,
13,
9651,
1723,
13,
4706,
1683,
29901,
13,
9651,
2854,
29918,
1272,
29961,
24713,
29918,
978,
29962,
353,
6219,
29918,
14968,
29918,
1688,
29918,
1792,
3538,
29918,
2230,
29898,
13,
18884,
4489,
3383,
13,
18884,
1404,
29918,
4914,
29892,
13,
18884,
2944,
29918,
4914,
29892,
13,
18884,
931,
29918,
4914,
29892,
13,
18884,
2944,
29918,
497,
29892,
13,
18884,
4934,
449,
29918,
3605,
601,
29892,
13,
18884,
302,
29918,
29882,
2495,
449,
29892,
13,
18884,
21700,
29918,
4914,
29922,
29741,
29918,
4914,
29892,
13,
9651,
1723,
13,
1678,
736,
2854,
29918,
1272,
29892,
2944,
29918,
497,
13,
2
] |
src/pyon/util/poller.py | scionrep/scioncc_new | 2 | 94429 | #!/usr/bin/env python
'''
@author <NAME> <<EMAIL>>
@date Thu Oct 25 15:41:44 EDT 2012
@file pyon/util/poller.py
@brief Utility for polling
'''
import gevent
import functools
def poll(poller, *args, **kwargs):
'''
Polls a callback (poller) until success is met
poller must be a valid callback and returns True on success
'''
timeout = 10
if 'timeout' in kwargs:
timeout = kwargs['timeout']
kwargs.pop('timeout')
success = False
with gevent.timeout.Timeout(timeout):
while not success:
success = poller(*args, **kwargs)
gevent.sleep(0.2)
return success
def poll_wrapper(timeout):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
success = False
with gevent.timeout.Timeout(timeout):
while not success:
success = func(*args, **kwargs)
gevent.sleep(0.2)
return success
return wrapper
return decorator
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
12008,
13,
29992,
8921,
529,
5813,
29958,
3532,
26862,
6227,
6778,
13,
29992,
1256,
498,
29884,
4756,
29871,
29906,
29945,
29871,
29896,
29945,
29901,
29946,
29896,
29901,
29946,
29946,
9408,
29911,
29871,
29906,
29900,
29896,
29906,
13,
29992,
1445,
11451,
265,
29914,
4422,
29914,
3733,
1358,
29889,
2272,
13,
29992,
1182,
2575,
22310,
537,
363,
1248,
1847,
13,
12008,
13,
13,
5215,
1737,
794,
13,
5215,
2090,
312,
8789,
13,
13,
1753,
21180,
29898,
3733,
1358,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
1678,
14550,
13,
1678,
2043,
3137,
263,
6939,
313,
3733,
1358,
29897,
2745,
2551,
338,
1539,
13,
1678,
1248,
1358,
1818,
367,
263,
2854,
6939,
322,
3639,
5852,
373,
2551,
13,
1678,
14550,
13,
1678,
11815,
353,
29871,
29896,
29900,
13,
1678,
565,
525,
15619,
29915,
297,
9049,
5085,
29901,
13,
4706,
11815,
353,
9049,
5085,
1839,
15619,
2033,
13,
4706,
9049,
5085,
29889,
7323,
877,
15619,
1495,
13,
1678,
2551,
353,
7700,
13,
1678,
411,
1737,
794,
29889,
15619,
29889,
10851,
29898,
15619,
1125,
13,
4706,
1550,
451,
2551,
29901,
13,
9651,
2551,
353,
1248,
1358,
10456,
5085,
29892,
3579,
19290,
29897,
13,
9651,
1737,
794,
29889,
17059,
29898,
29900,
29889,
29906,
29897,
13,
1678,
736,
2551,
13,
13,
1753,
21180,
29918,
17699,
29898,
15619,
1125,
13,
1678,
822,
10200,
1061,
29898,
9891,
1125,
13,
4706,
732,
7692,
312,
8789,
29889,
29893,
336,
567,
29898,
9891,
29897,
13,
4706,
822,
14476,
10456,
5085,
29892,
3579,
19290,
1125,
13,
9651,
2551,
353,
7700,
13,
9651,
411,
1737,
794,
29889,
15619,
29889,
10851,
29898,
15619,
1125,
13,
18884,
1550,
451,
2551,
29901,
13,
462,
1678,
2551,
353,
3653,
10456,
5085,
29892,
3579,
19290,
29897,
13,
462,
1678,
1737,
794,
29889,
17059,
29898,
29900,
29889,
29906,
29897,
13,
9651,
736,
2551,
13,
4706,
736,
14476,
13,
1678,
736,
10200,
1061,
13,
13,
13,
2
] |
marconi/tests/queues/storage/base.py | andrew-vant/marconi | 0 | 1613600 | <reponame>andrew-vant/marconi
# Copyright (c) 2013 Red Hat, Inc.
#
# 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 applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import datetime
import time
import uuid
import ddt
import six
from testtools import matchers
from marconi.openstack.common.cache import cache as oslo_cache
from marconi.openstack.common import timeutils
from marconi.queues import storage
from marconi.queues.storage import errors
from marconi import tests as testing
from marconi.tests import helpers
class ControllerBaseTest(testing.TestBase):
project = 'project'
driver_class = None
controller_class = None
controller_base_class = None
def setUp(self):
super(ControllerBaseTest, self).setUp()
if not self.driver_class:
self.skipTest('No driver class specified')
if not issubclass(self.controller_class, self.controller_base_class):
self.skipTest('{0} is not an instance of {1}. '
'Tests not supported'.format(
self.controller_class,
self.controller_base_class))
oslo_cache.register_oslo_configs(self.conf)
cache = oslo_cache.get_cache(self.conf.cache_url)
# pylint: disable=not-callable
self.driver = self.driver_class(self.conf, cache)
self._prepare_conf()
self.addCleanup(self._purge_databases)
# pylint: disable=not-callable
self.controller = self.controller_class(self.driver)
def _prepare_conf(self):
"""Prepare the conf before running tests
Classes overriding this method, must use
the `self.conf` instance and alter its state.
"""
def _purge_databases(self):
"""Override to clean databases."""
@ddt.ddt
class QueueControllerTest(ControllerBaseTest):
"""Queue Controller base tests."""
controller_base_class = storage.Queue
def setUp(self):
super(QueueControllerTest, self).setUp()
self.queue_controller = self.driver.queue_controller
self.message_controller = self.driver.message_controller
self.claim_controller = self.driver.claim_controller
@ddt.data(None, ControllerBaseTest.project)
def test_list(self, project):
# NOTE(kgriffs): Ensure we mix global and scoped queues
# in order to verify that queue records are exluded that
# are not at the same level.
project_alt = self.project if project is None else None
num = 15
for queue in six.moves.xrange(num):
self.controller.create(str(queue), project=project)
self.controller.create(str(queue), project=project_alt)
interaction = self.controller.list(project=project,
detailed=True)
queues = list(next(interaction))
self.assertEqual(all(map(lambda queue:
'name' in queue and
'metadata' in queue, queues)), True)
self.assertEqual(len(queues), 10)
interaction = self.controller.list(project=project,
marker=next(interaction))
queues = list(next(interaction))
self.assertEqual(all(map(lambda queue:
'name' in queue and
'metadata' not in queue, queues)), True)
self.assertEqual(len(queues), 5)
def test_queue_lifecycle(self):
# Test queue creation
created = self.controller.create('test', project=self.project)
self.assertTrue(created)
# Test queue existence
self.assertTrue(self.controller.exists('test', project=self.project))
# Test queue retrieval
interaction = self.controller.list(project=self.project)
queue = list(next(interaction))[0]
self.assertEqual(queue['name'], 'test')
# Test queue metadata retrieval
metadata = self.controller.get_metadata('test', project=self.project)
self.assertEqual(metadata, {})
# Test queue update
created = self.controller.set_metadata('test', project=self.project,
metadata=dict(meta='test_meta'))
metadata = self.controller.get_metadata('test', project=self.project)
self.assertEqual(metadata['meta'], 'test_meta')
# Touching an existing queue does not affect metadata
created = self.controller.create('test', project=self.project)
self.assertFalse(created)
metadata = self.controller.get_metadata('test', project=self.project)
self.assertEqual(metadata['meta'], 'test_meta')
client_uuid = uuid.uuid4()
# Test queue statistic
_insert_fixtures(self.message_controller, 'test',
project=self.project, client_uuid=client_uuid,
num=6)
# NOTE(kgriffs): We can't get around doing this, because
# we don't know how the storage drive may be calculating
# message timestamps (and may not be monkey-patchable).
time.sleep(1.2)
_insert_fixtures(self.message_controller, 'test',
project=self.project, client_uuid=client_uuid,
num=6)
stats = self.controller.stats('test', project=self.project)
message_stats = stats['messages']
self.assertEqual(message_stats['free'], 12)
self.assertEqual(message_stats['claimed'], 0)
self.assertEqual(message_stats['total'], 12)
oldest = message_stats['oldest']
newest = message_stats['newest']
self.assertNotEqual(oldest, newest)
age = oldest['age']
self.assertThat(age, matchers.GreaterThan(0))
# NOTE(kgriffs): Ensure is different enough
# for the next comparison to work.
soon = timeutils.utcnow() + datetime.timedelta(seconds=60)
for message_stat in (oldest, newest):
created_iso = message_stat['created']
created = timeutils.parse_isotime(created_iso)
self.assertThat(timeutils.normalize_time(created),
matchers.LessThan(soon))
self.assertIn('id', message_stat)
self.assertThat(oldest['created'],
matchers.LessThan(newest['created']))
# Test queue deletion
self.controller.delete('test', project=self.project)
# Test queue existence
self.assertFalse(self.controller.exists('test', project=self.project))
# Test DoesNotExist exception
with testing.expect(storage.errors.DoesNotExist):
self.controller.get_metadata('test', project=self.project)
with testing.expect(storage.errors.DoesNotExist):
self.controller.set_metadata('test', '{}', project=self.project)
def test_stats_for_empty_queue(self):
created = self.controller.create('test', project=self.project)
self.assertTrue(created)
stats = self.controller.stats('test', project=self.project)
message_stats = stats['messages']
self.assertEqual(message_stats['free'], 0)
self.assertEqual(message_stats['claimed'], 0)
self.assertEqual(message_stats['total'], 0)
self.assertNotIn('newest', message_stats)
self.assertNotIn('oldest', message_stats)
class MessageControllerTest(ControllerBaseTest):
"""Message Controller base tests.
NOTE(flaper87): Implementations of this class should
override the tearDown method in order
to clean up storage's state.
"""
queue_name = 'test_queue'
controller_base_class = storage.Message
# Specifies how often expired messages are purged, in sec.
gc_interval = 0
def setUp(self):
super(MessageControllerTest, self).setUp()
# Lets create a queue
self.queue_controller = self.driver.queue_controller
self.claim_controller = self.driver.claim_controller
self.queue_controller.create(self.queue_name, project=self.project)
def tearDown(self):
self.queue_controller.delete(self.queue_name, project=self.project)
super(MessageControllerTest, self).tearDown()
def test_message_lifecycle(self):
queue_name = self.queue_name
message = {
'ttl': 60,
'body': {
'event': 'BackupStarted',
'backupId': 'c378813c-3f0b-11e2-ad92-7823d2b0f3ce'
}
}
# Test Message Creation
created = list(self.controller.post(queue_name, [message],
project=self.project,
client_uuid=uuid.uuid4()))
self.assertEqual(len(created), 1)
message_id = created[0]
# Test Message Get
message_out = self.controller.get(queue_name, message_id,
project=self.project)
self.assertEqual(set(message_out), set(('id', 'body', 'ttl', 'age')))
self.assertEqual(message_out['id'], message_id)
self.assertEqual(message_out['body'], message['body'])
self.assertEqual(message_out['ttl'], message['ttl'])
# Test Message Deletion
self.controller.delete(queue_name, message_id, project=self.project)
# Test does not exist
with testing.expect(storage.errors.DoesNotExist):
self.controller.get(queue_name, message_id, project=self.project)
def test_get_multi(self):
client_uuid = uuid.uuid4()
_insert_fixtures(self.controller, self.queue_name,
project=self.project, client_uuid=client_uuid, num=15)
def load_messages(expected, *args, **kwargs):
interaction = self.controller.list(*args, **kwargs)
msgs = list(next(interaction))
self.assertEqual(len(msgs), expected)
return interaction
# Test all messages, echo False and uuid
load_messages(0, self.queue_name, project=self.project,
client_uuid=client_uuid)
# Test all messages and limit
load_messages(15, self.queue_name, project=self.project, limit=20,
echo=True)
# Test all messages, echo True, and uuid
interaction = load_messages(10, self.queue_name, echo=True,
project=self.project,
client_uuid=client_uuid)
# Test all messages, echo True, uuid and marker
load_messages(5, self.queue_name, echo=True, project=self.project,
marker=next(interaction), client_uuid=client_uuid)
def test_multi_ids(self):
messages_in = [{'ttl': 120, 'body': 0}, {'ttl': 240, 'body': 1}]
ids = self.controller.post(self.queue_name, messages_in,
project=self.project,
client_uuid=uuid.uuid4())
messages_out = self.controller.bulk_get(self.queue_name, ids,
project=self.project)
for idx, message in enumerate(messages_out):
self.assertEqual(set(message), set(('id', 'body', 'ttl', 'age')))
self.assertEqual(message['body'], idx)
self.controller.bulk_delete(self.queue_name, ids,
project=self.project)
with testing.expect(StopIteration):
result = self.controller.bulk_get(self.queue_name, ids,
project=self.project)
next(result)
def test_claim_effects(self):
client_uuid = uuid.uuid4()
_insert_fixtures(self.controller, self.queue_name,
project=self.project, client_uuid=client_uuid, num=12)
def list_messages(include_claimed=None):
kwargs = {
'project': self.project,
'client_uuid': client_uuid,
'echo': True,
}
# Properly test default value
if include_claimed is not None:
kwargs['include_claimed'] = include_claimed
interaction = self.controller.list(self.queue_name, **kwargs)
messages = next(interaction)
return [msg['id'] for msg in messages]
messages_before = list_messages(True)
meta = {'ttl': 70, 'grace': 60}
another_cid, _ = self.claim_controller.create(self.queue_name, meta,
project=self.project)
messages_after = list_messages(True)
self.assertEqual(messages_before, messages_after)
messages_excluding_claimed = list_messages()
self.assertNotEqual(messages_before, messages_excluding_claimed)
self.assertEqual(2, len(messages_excluding_claimed))
cid, msgs = self.claim_controller.create(self.queue_name, meta,
project=self.project)
[msg1, msg2] = msgs
# A wrong claim does not ensure the message deletion
with testing.expect(storage.errors.NotPermitted):
self.controller.delete(self.queue_name, msg1['id'],
project=self.project,
claim=another_cid)
# Make sure a message can be deleted with a claim
self.controller.delete(self.queue_name, msg1['id'],
project=self.project,
claim=cid)
with testing.expect(storage.errors.DoesNotExist):
self.controller.get(self.queue_name, msg1['id'],
project=self.project)
# Make sure such a deletion is idempotent
self.controller.delete(self.queue_name, msg1['id'],
project=self.project,
claim=cid)
# A non-existing claim does not ensure the message deletion
self.claim_controller.delete(self.queue_name, cid,
project=self.project)
with testing.expect(storage.errors.NotPermitted):
self.controller.delete(self.queue_name, msg2['id'],
project=self.project,
claim=cid)
@testing.is_slow(condition=lambda self: self.gc_interval != 0)
def test_expired_messages(self):
messages = [{'body': 3.14, 'ttl': 0}]
client_uuid = uuid.uuid4()
[msgid] = self.controller.post(self.queue_name, messages,
project=self.project,
client_uuid=client_uuid)
time.sleep(self.gc_interval)
with testing.expect(storage.errors.DoesNotExist):
self.controller.get(self.queue_name, msgid,
project=self.project)
stats = self.queue_controller.stats(self.queue_name,
project=self.project)
self.assertEqual(stats['messages']['free'], 0)
def test_bad_id(self):
# NOTE(cpp-cabrera): A malformed ID should result in an empty
# query. Raising an exception for validating IDs makes the
# implementation more verbose instead of taking advantage of
# the Maybe/Optional protocol, particularly when dealing with
# bulk operations.
bad_message_id = 'xyz'
self.controller.delete(self.queue_name,
bad_message_id,
project=self.project)
with testing.expect(errors.MessageDoesNotExist):
self.controller.get(self.queue_name,
bad_message_id,
project=self.project)
def test_bad_claim_id(self):
[msgid] = self.controller.post(self.queue_name,
[{'body': {}, 'ttl': 10}],
project=self.project,
client_uuid=uuid.uuid4())
bad_claim_id = '; DROP TABLE queues'
self.controller.delete(self.queue_name,
msgid,
project=self.project,
claim=bad_claim_id)
def test_bad_marker(self):
bad_marker = 'xyz'
interaction = self.controller.list(self.queue_name,
project=self.project,
client_uuid=uuid.uuid4(),
marker=bad_marker)
messages = list(next(interaction))
self.assertEqual(messages, [])
def test_sort_for_first(self):
client_uuid = uuid.uuid4()
[msgid_first] = self.controller.post(self.queue_name,
[{'body': {}, 'ttl': 120}],
project=self.project,
client_uuid=client_uuid)
_insert_fixtures(self.controller, self.queue_name,
project=self.project, client_uuid=client_uuid, num=10)
[msgid_last] = self.controller.post(self.queue_name,
[{'body': {}, 'ttl': 120}],
project=self.project,
client_uuid=client_uuid)
msg_asc = self.controller.first(self.queue_name,
self.project,
1)
self.assertEqual(msg_asc['id'], msgid_first)
msg_desc = self.controller.first(self.queue_name,
self.project,
-1)
self.assertEqual(msg_desc['id'], msgid_last)
class ClaimControllerTest(ControllerBaseTest):
"""Claim Controller base tests.
NOTE(flaper87): Implementations of this class should
override the tearDown method in order
to clean up storage's state.
"""
queue_name = 'test_queue'
controller_base_class = storage.Claim
def setUp(self):
super(ClaimControllerTest, self).setUp()
# Lets create a queue
self.queue_controller = self.driver.queue_controller
self.message_controller = self.driver.message_controller
self.queue_controller.create(self.queue_name, project=self.project)
def tearDown(self):
self.queue_controller.delete(self.queue_name, project=self.project)
super(ClaimControllerTest, self).tearDown()
def test_claim_lifecycle(self):
_insert_fixtures(self.message_controller, self.queue_name,
project=self.project, client_uuid=uuid.uuid4(),
num=20)
meta = {'ttl': 70, 'grace': 30}
# Make sure create works
claim_id, messages = self.controller.create(self.queue_name, meta,
project=self.project,
limit=15)
messages = list(messages)
self.assertEqual(len(messages), 15)
# Ensure Queue stats
countof = self.queue_controller.stats(self.queue_name,
project=self.project)
self.assertEqual(countof['messages']['claimed'], 15)
self.assertEqual(countof['messages']['free'], 5)
self.assertEqual(countof['messages']['total'], 20)
# Make sure get works
claim, messages2 = self.controller.get(self.queue_name, claim_id,
project=self.project)
messages2 = list(messages2)
self.assertEqual(len(messages2), 15)
self.assertEqual(messages, messages2)
self.assertEqual(claim['ttl'], 70)
self.assertEqual(claim['id'], claim_id)
new_meta = {'ttl': 100, 'grace': 60}
self.controller.update(self.queue_name, claim_id,
new_meta, project=self.project)
# Make sure update works
claim, messages2 = self.controller.get(self.queue_name, claim_id,
project=self.project)
messages2 = list(messages2)
self.assertEqual(len(messages2), 15)
# TODO(zyuan): Add some tests to ensure the ttl is
# extended/not-extended.
for msg1, msg2 in zip(messages, messages2):
self.assertEqual(msg1['body'], msg2['body'])
self.assertEqual(claim['ttl'], 100)
self.assertEqual(claim['id'], claim_id)
# Make sure delete works
self.controller.delete(self.queue_name, claim_id,
project=self.project)
self.assertRaises(storage.errors.ClaimDoesNotExist,
self.controller.get, self.queue_name,
claim_id, project=self.project)
def test_extend_lifetime(self):
_insert_fixtures(self.message_controller, self.queue_name,
project=self.project, client_uuid=uuid.uuid4(),
num=20, ttl=120)
meta = {'ttl': 777, 'grace': 0}
claim_id, messages = self.controller.create(self.queue_name, meta,
project=self.project)
for message in messages:
self.assertEqual(message['ttl'], 777)
def test_extend_lifetime_with_grace_1(self):
_insert_fixtures(self.message_controller, self.queue_name,
project=self.project, client_uuid=uuid.uuid4(),
num=20, ttl=120)
meta = {'ttl': 777, 'grace': 23}
claim_id, messages = self.controller.create(self.queue_name, meta,
project=self.project)
for message in messages:
self.assertEqual(message['ttl'], 800)
def test_extend_lifetime_with_grace_2(self):
_insert_fixtures(self.message_controller, self.queue_name,
project=self.project, client_uuid=uuid.uuid4(),
num=20, ttl=120)
# Although ttl is less than the message's TTL, the grace
# period puts it just over the edge.
meta = {'ttl': 100, 'grace': 22}
claim_id, messages = self.controller.create(self.queue_name, meta,
project=self.project)
for message in messages:
self.assertEqual(message['ttl'], 122)
def test_do_not_extend_lifetime(self):
_insert_fixtures(self.message_controller, self.queue_name,
project=self.project, client_uuid=uuid.uuid4(),
num=20, ttl=120)
# Choose a ttl that is less than the message's current TTL
meta = {'ttl': 60, 'grace': 30}
claim_id, messages = self.controller.create(self.queue_name, meta,
project=self.project)
for message in messages:
self.assertEqual(message['ttl'], 120)
def test_expired_claim(self):
meta = {'ttl': 0, 'grace': 60}
claim_id, messages = self.controller.create(self.queue_name, meta,
project=self.project)
with testing.expect(storage.errors.DoesNotExist):
self.controller.get(self.queue_name, claim_id,
project=self.project)
with testing.expect(storage.errors.DoesNotExist):
self.controller.update(self.queue_name, claim_id,
meta, project=self.project)
def test_illformed_id(self):
# any ill-formed IDs should be regarded as non-existing ones.
self.controller.delete(self.queue_name,
'illformed',
project=self.project)
with testing.expect(errors.DoesNotExist):
self.controller.get(self.queue_name,
'illformed',
project=self.project)
with testing.expect(errors.DoesNotExist):
self.controller.update(self.queue_name,
'illformed',
{'ttl': 40},
project=self.project)
class ShardsControllerTest(ControllerBaseTest):
"""Shards Controller base tests.
NOTE(flaper87): Implementations of this class should
override the tearDown method in order
to clean up storage's state.
"""
controller_base_class = storage.ShardsBase
def setUp(self):
super(ShardsControllerTest, self).setUp()
self.shards_controller = self.driver.shards_controller
# Let's create one shard
self.shard = str(uuid.uuid1())
self.shards_controller.create(self.shard, 100, 'localhost', {})
def tearDown(self):
self.shards_controller.drop_all()
super(ShardsControllerTest, self).tearDown()
def test_create_succeeds(self):
self.shards_controller.create(str(uuid.uuid1()),
100, 'localhost', {})
def test_create_replaces_on_duplicate_insert(self):
name = str(uuid.uuid1())
self.shards_controller.create(name,
100, 'localhost', {})
self.shards_controller.create(name,
111, 'localhost2', {})
entry = self.shards_controller.get(name)
self._shard_expects(entry, xname=name, xweight=111,
xlocation='localhost2')
def _shard_expects(self, shard, xname, xweight, xlocation):
self.assertIn('name', shard)
self.assertEqual(shard['name'], xname)
self.assertIn('weight', shard)
self.assertEqual(shard['weight'], xweight)
self.assertIn('uri', shard)
self.assertEqual(shard['uri'], xlocation)
def test_get_returns_expected_content(self):
res = self.shards_controller.get(self.shard)
self._shard_expects(res, self.shard, 100, 'localhost')
self.assertNotIn('options', res)
def test_detailed_get_returns_expected_content(self):
res = self.shards_controller.get(self.shard, detailed=True)
self.assertIn('options', res)
self.assertEqual(res['options'], {})
def test_get_raises_if_not_found(self):
self.assertRaises(storage.errors.ShardDoesNotExist,
self.shards_controller.get, 'notexists')
def test_exists(self):
self.assertTrue(self.shards_controller.exists(self.shard))
self.assertFalse(self.shards_controller.exists('notexists'))
def test_update_raises_assertion_error_on_bad_fields(self):
self.assertRaises(AssertionError, self.shards_controller.update,
self.shard)
def test_update_works(self):
self.shards_controller.update(self.shard, weight=101,
uri='redis://localhost',
options={'a': 1})
res = self.shards_controller.get(self.shard, detailed=True)
self._shard_expects(res, self.shard, 101, 'redis://localhost')
self.assertEqual(res['options'], {'a': 1})
def test_delete_works(self):
self.shards_controller.delete(self.shard)
self.assertFalse(self.shards_controller.exists(self.shard))
def test_delete_nonexistent_is_silent(self):
self.shards_controller.delete('nonexisting')
def test_drop_all_leads_to_empty_listing(self):
self.shards_controller.drop_all()
cursor = self.shards_controller.list()
self.assertRaises(StopIteration, next, cursor)
def test_listing_simple(self):
# NOTE(cpp-cabrera): base entry interferes with listing results
self.shards_controller.delete(self.shard)
name_gen = lambda i: chr(ord('A') + i)
for i in range(15):
self.shards_controller.create(name_gen(i), i, str(i), {})
res = list(self.shards_controller.list())
self.assertEqual(len(res), 10)
for i, entry in enumerate(res):
self._shard_expects(entry, name_gen(i), i, str(i))
self.assertNotIn('options', entry)
res = list(self.shards_controller.list(limit=5))
self.assertEqual(len(res), 5)
res = next(self.shards_controller.list(marker=name_gen(3)))
self._shard_expects(res, name_gen(4), 4, '4')
res = list(self.shards_controller.list(detailed=True))
self.assertEqual(len(res), 10)
for i, entry in enumerate(res):
self._shard_expects(entry, name_gen(i), i, str(i))
self.assertIn('options', entry)
self.assertEqual(entry['options'], {})
class CatalogueControllerTest(ControllerBaseTest):
controller_base_class = storage.CatalogueBase
def setUp(self):
super(CatalogueControllerTest, self).setUp()
self.controller = self.driver.catalogue_controller
self.queue = six.text_type(uuid.uuid1())
self.project = six.text_type(uuid.uuid1())
def tearDown(self):
self.controller.drop_all()
super(CatalogueControllerTest, self).tearDown()
def _check_structure(self, entry):
self.assertIn('queue', entry)
self.assertIn('project', entry)
self.assertIn('shard', entry)
self.assertIsInstance(entry['queue'], six.text_type)
self.assertIsInstance(entry['project'], six.text_type)
self.assertIsInstance(entry['shard'], six.text_type)
def _check_value(self, entry, xqueue, xproject, xshard):
self.assertEqual(entry['queue'], xqueue)
self.assertEqual(entry['project'], xproject)
self.assertEqual(entry['shard'], xshard)
def test_catalogue_entry_life_cycle(self):
queue = self.queue
project = self.project
# check listing is initially empty
for p in self.controller.list(project):
self.fail('There should be no entries at this time')
# create a listing, check its length
with helpers.shard_entries(self.controller, 10) as expect:
project = expect[0][0]
xs = list(self.controller.list(project))
self.assertEqual(len(xs), 10)
# create, check existence, delete
with helpers.shard_entry(self.controller, project, queue, u'a'):
self.assertTrue(self.controller.exists(project, queue))
# verify it no longer exists
self.assertFalse(self.controller.exists(project, queue))
# verify it isn't listable
self.assertEqual(len(list(self.controller.list(project))), 0)
def test_list(self):
with helpers.shard_entries(self.controller, 10) as expect:
values = zip(self.controller.list(u'_'), expect)
for e, x in values:
p, q, s = x
self._check_structure(e)
self._check_value(e, xqueue=q, xproject=p, xshard=s)
def test_update(self):
with helpers.shard_entry(self.controller, self.project,
self.queue, u'a') as expect:
p, q, s = expect
self.controller.update(p, q, shard=u'b')
entry = self.controller.get(p, q)
self._check_value(entry, xqueue=q, xproject=p, xshard=u'b')
def test_update_raises_when_entry_does_not_exist(self):
self.assertRaises(errors.QueueNotMapped,
self.controller.update,
'not', 'not', 'a')
def test_get(self):
with helpers.shard_entry(self.controller,
self.project,
self.queue, u'a') as expect:
p, q, s = expect
e = self.controller.get(p, q)
self._check_value(e, xqueue=q, xproject=p, xshard=s)
def test_get_raises_if_does_not_exist(self):
with helpers.shard_entry(self.controller,
self.project,
self.queue, u'a') as expect:
p, q, _ = expect
self.assertRaises(errors.QueueNotMapped,
self.controller.get,
p, 'non_existing')
self.assertRaises(errors.QueueNotMapped,
self.controller.get,
'non_existing', q)
self.assertRaises(errors.QueueNotMapped,
self.controller.get,
'non_existing', 'non_existing')
def test_exists(self):
with helpers.shard_entry(self.controller,
self.project,
self.queue, u'a') as expect:
p, q, _ = expect
self.assertTrue(self.controller.exists(p, q))
self.assertFalse(self.controller.exists('nada', 'not_here'))
def _insert_fixtures(controller, queue_name, project=None,
client_uuid=None, num=4, ttl=120):
def messages():
for n in six.moves.xrange(num):
yield {
'ttl': ttl,
'body': {
'event': 'Event number {0}'.format(n)
}}
controller.post(queue_name, messages(),
project=project, client_uuid=client_uuid)
| [
1,
529,
276,
1112,
420,
29958,
392,
3973,
29899,
29894,
424,
29914,
3034,
535,
29875,
13,
29937,
14187,
1266,
313,
29883,
29897,
29871,
29906,
29900,
29896,
29941,
4367,
25966,
29892,
9266,
29889,
13,
29937,
13,
29937,
10413,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
29937,
366,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
29937,
887,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
1678,
1732,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
29937,
13,
29937,
25870,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
29937,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29937,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
13,
29937,
2411,
2957,
29889,
13,
29937,
2823,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
29937,
27028,
1090,
278,
19245,
29889,
13,
13,
5215,
12865,
13,
5215,
931,
13,
5215,
318,
5416,
13,
13,
5215,
270,
6008,
13,
5215,
4832,
13,
3166,
1243,
8504,
1053,
1993,
414,
13,
13,
3166,
1766,
535,
29875,
29889,
3150,
1429,
29889,
9435,
29889,
8173,
1053,
7090,
408,
2897,
417,
29918,
8173,
13,
3166,
1766,
535,
29875,
29889,
3150,
1429,
29889,
9435,
1053,
931,
13239,
13,
3166,
1766,
535,
29875,
29889,
802,
1041,
1053,
8635,
13,
3166,
1766,
535,
29875,
29889,
802,
1041,
29889,
12925,
1053,
4436,
13,
3166,
1766,
535,
29875,
1053,
6987,
408,
6724,
13,
3166,
1766,
535,
29875,
29889,
21150,
1053,
1371,
414,
13,
13,
13,
1990,
15830,
5160,
3057,
29898,
13424,
29889,
3057,
5160,
1125,
13,
1678,
2060,
353,
525,
4836,
29915,
13,
1678,
7156,
29918,
1990,
353,
6213,
13,
1678,
4701,
29918,
1990,
353,
6213,
13,
1678,
4701,
29918,
3188,
29918,
1990,
353,
6213,
13,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
2428,
29898,
2956,
5160,
3057,
29892,
1583,
467,
842,
3373,
580,
13,
13,
4706,
565,
451,
1583,
29889,
9465,
29918,
1990,
29901,
13,
9651,
1583,
29889,
11014,
3057,
877,
3782,
7156,
770,
6790,
1495,
13,
13,
4706,
565,
451,
338,
1491,
1990,
29898,
1311,
29889,
8299,
29918,
1990,
29892,
1583,
29889,
8299,
29918,
3188,
29918,
1990,
1125,
13,
9651,
1583,
29889,
11014,
3057,
877,
29912,
29900,
29913,
338,
451,
385,
2777,
310,
426,
29896,
1836,
525,
13,
462,
3986,
525,
24376,
451,
6969,
4286,
4830,
29898,
13,
462,
795,
1583,
29889,
8299,
29918,
1990,
29892,
13,
462,
795,
1583,
29889,
8299,
29918,
3188,
29918,
1990,
876,
13,
13,
4706,
2897,
417,
29918,
8173,
29889,
9573,
29918,
359,
417,
29918,
2917,
29879,
29898,
1311,
29889,
5527,
29897,
13,
4706,
7090,
353,
2897,
417,
29918,
8173,
29889,
657,
29918,
8173,
29898,
1311,
29889,
5527,
29889,
8173,
29918,
2271,
29897,
13,
13,
4706,
396,
282,
2904,
524,
29901,
11262,
29922,
1333,
29899,
4804,
519,
13,
4706,
1583,
29889,
9465,
353,
1583,
29889,
9465,
29918,
1990,
29898,
1311,
29889,
5527,
29892,
7090,
29897,
13,
4706,
1583,
3032,
19125,
29918,
5527,
580,
13,
13,
4706,
1583,
29889,
1202,
29907,
14044,
786,
29898,
1311,
3032,
15503,
479,
29918,
29503,
2129,
29897,
13,
13,
4706,
396,
282,
2904,
524,
29901,
11262,
29922,
1333,
29899,
4804,
519,
13,
4706,
1583,
29889,
8299,
353,
1583,
29889,
8299,
29918,
1990,
29898,
1311,
29889,
9465,
29897,
13,
13,
1678,
822,
903,
19125,
29918,
5527,
29898,
1311,
1125,
13,
4706,
9995,
29925,
3445,
598,
278,
1970,
1434,
2734,
6987,
13,
13,
4706,
4134,
267,
20831,
292,
445,
1158,
29892,
1818,
671,
13,
4706,
278,
421,
1311,
29889,
5527,
29952,
2777,
322,
10551,
967,
2106,
29889,
13,
4706,
9995,
13,
13,
1678,
822,
903,
15503,
479,
29918,
29503,
2129,
29898,
1311,
1125,
13,
4706,
9995,
4640,
304,
5941,
21218,
1213,
15945,
13,
13,
13,
29992,
1289,
29873,
29889,
1289,
29873,
13,
1990,
5462,
434,
2956,
3057,
29898,
2956,
5160,
3057,
1125,
13,
1678,
9995,
10620,
15830,
2967,
6987,
1213,
15945,
13,
1678,
4701,
29918,
3188,
29918,
1990,
353,
8635,
29889,
10620,
13,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
2428,
29898,
10620,
2956,
3057,
29892,
1583,
467,
842,
3373,
580,
13,
4706,
1583,
29889,
9990,
29918,
8299,
353,
1583,
29889,
9465,
29889,
9990,
29918,
8299,
13,
4706,
1583,
29889,
4906,
29918,
8299,
353,
1583,
29889,
9465,
29889,
4906,
29918,
8299,
13,
4706,
1583,
29889,
29883,
8342,
29918,
8299,
353,
1583,
29889,
9465,
29889,
29883,
8342,
29918,
8299,
13,
13,
1678,
732,
1289,
29873,
29889,
1272,
29898,
8516,
29892,
15830,
5160,
3057,
29889,
4836,
29897,
13,
1678,
822,
1243,
29918,
1761,
29898,
1311,
29892,
2060,
1125,
13,
4706,
396,
6058,
29923,
29898,
29895,
629,
28324,
1125,
22521,
545,
591,
6837,
5534,
322,
16505,
287,
712,
1041,
13,
4706,
396,
297,
1797,
304,
11539,
393,
9521,
6475,
526,
429,
29880,
566,
287,
393,
13,
4706,
396,
526,
451,
472,
278,
1021,
3233,
29889,
13,
4706,
2060,
29918,
1997,
353,
1583,
29889,
4836,
565,
2060,
338,
6213,
1683,
6213,
13,
13,
4706,
954,
353,
29871,
29896,
29945,
13,
4706,
363,
9521,
297,
4832,
29889,
13529,
267,
29889,
29916,
3881,
29898,
1949,
1125,
13,
9651,
1583,
29889,
8299,
29889,
3258,
29898,
710,
29898,
9990,
511,
2060,
29922,
4836,
29897,
13,
9651,
1583,
29889,
8299,
29889,
3258,
29898,
710,
29898,
9990,
511,
2060,
29922,
4836,
29918,
1997,
29897,
13,
13,
4706,
14881,
353,
1583,
29889,
8299,
29889,
1761,
29898,
4836,
29922,
4836,
29892,
13,
462,
462,
965,
13173,
29922,
5574,
29897,
13,
4706,
712,
1041,
353,
1051,
29898,
4622,
29898,
1639,
2467,
876,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
497,
29898,
1958,
29898,
2892,
9521,
29901,
13,
462,
462,
525,
978,
29915,
297,
9521,
322,
13,
462,
462,
525,
19635,
29915,
297,
9521,
29892,
712,
1041,
8243,
5852,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
802,
1041,
511,
29871,
29896,
29900,
29897,
13,
13,
4706,
14881,
353,
1583,
29889,
8299,
29889,
1761,
29898,
4836,
29922,
4836,
29892,
13,
462,
462,
965,
17456,
29922,
4622,
29898,
1639,
2467,
876,
13,
4706,
712,
1041,
353,
1051,
29898,
4622,
29898,
1639,
2467,
876,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
497,
29898,
1958,
29898,
2892,
9521,
29901,
13,
462,
462,
525,
978,
29915,
297,
9521,
322,
13,
462,
462,
525,
19635,
29915,
451,
297,
9521,
29892,
712,
1041,
8243,
5852,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
802,
1041,
511,
29871,
29945,
29897,
13,
13,
1678,
822,
1243,
29918,
9990,
29918,
29880,
22532,
29898,
1311,
1125,
13,
4706,
396,
4321,
9521,
11265,
13,
4706,
2825,
353,
1583,
29889,
8299,
29889,
3258,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
1583,
29889,
9294,
5574,
29898,
11600,
29897,
13,
13,
4706,
396,
4321,
9521,
10379,
13,
4706,
1583,
29889,
9294,
5574,
29898,
1311,
29889,
8299,
29889,
9933,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
876,
13,
13,
4706,
396,
4321,
9521,
5663,
16837,
13,
4706,
14881,
353,
1583,
29889,
8299,
29889,
1761,
29898,
4836,
29922,
1311,
29889,
4836,
29897,
13,
4706,
9521,
353,
1051,
29898,
4622,
29898,
1639,
2467,
876,
29961,
29900,
29962,
13,
4706,
1583,
29889,
9294,
9843,
29898,
9990,
1839,
978,
7464,
525,
1688,
1495,
13,
13,
4706,
396,
4321,
9521,
15562,
5663,
16837,
13,
4706,
15562,
353,
1583,
29889,
8299,
29889,
657,
29918,
19635,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
19635,
29892,
426,
1800,
13,
13,
4706,
396,
4321,
9521,
2767,
13,
4706,
2825,
353,
1583,
29889,
8299,
29889,
842,
29918,
19635,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
1669,
15562,
29922,
8977,
29898,
7299,
2433,
1688,
29918,
7299,
8785,
13,
13,
4706,
15562,
353,
1583,
29889,
8299,
29889,
657,
29918,
19635,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
19635,
1839,
7299,
7464,
525,
1688,
29918,
7299,
1495,
13,
13,
4706,
396,
28675,
292,
385,
5923,
9521,
947,
451,
6602,
15562,
13,
4706,
2825,
353,
1583,
29889,
8299,
29889,
3258,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
1583,
29889,
9294,
8824,
29898,
11600,
29897,
13,
13,
4706,
15562,
353,
1583,
29889,
8299,
29889,
657,
29918,
19635,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
19635,
1839,
7299,
7464,
525,
1688,
29918,
7299,
1495,
13,
13,
4706,
3132,
29918,
25118,
353,
318,
5416,
29889,
25118,
29946,
580,
13,
13,
4706,
396,
4321,
9521,
1002,
4695,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
4906,
29918,
8299,
29892,
525,
1688,
742,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29892,
13,
462,
308,
954,
29922,
29953,
29897,
13,
13,
4706,
396,
6058,
29923,
29898,
29895,
629,
28324,
1125,
1334,
508,
29915,
29873,
679,
2820,
2599,
445,
29892,
1363,
13,
4706,
396,
591,
1016,
29915,
29873,
1073,
920,
278,
8635,
7899,
1122,
367,
25202,
13,
4706,
396,
2643,
5335,
342,
15092,
313,
392,
1122,
451,
367,
1601,
1989,
29899,
5041,
519,
467,
13,
4706,
931,
29889,
17059,
29898,
29896,
29889,
29906,
29897,
13,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
4906,
29918,
8299,
29892,
525,
1688,
742,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29892,
13,
462,
308,
954,
29922,
29953,
29897,
13,
13,
4706,
22663,
353,
1583,
29889,
8299,
29889,
16202,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
2643,
29918,
16202,
353,
22663,
1839,
19158,
2033,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
16202,
1839,
9021,
7464,
29871,
29896,
29906,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
16202,
1839,
29883,
13190,
7464,
29871,
29900,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
16202,
1839,
7827,
7464,
29871,
29896,
29906,
29897,
13,
13,
4706,
23947,
353,
2643,
29918,
16202,
1839,
1025,
342,
2033,
13,
4706,
716,
342,
353,
2643,
29918,
16202,
1839,
1482,
342,
2033,
13,
13,
4706,
1583,
29889,
9294,
3664,
9843,
29898,
1025,
342,
29892,
716,
342,
29897,
13,
13,
4706,
5046,
353,
23947,
1839,
482,
2033,
13,
4706,
1583,
29889,
9294,
7058,
29898,
482,
29892,
1993,
414,
29889,
25120,
1008,
1349,
273,
29898,
29900,
876,
13,
13,
4706,
396,
6058,
29923,
29898,
29895,
629,
28324,
1125,
22521,
545,
338,
1422,
3307,
13,
4706,
396,
363,
278,
2446,
10230,
304,
664,
29889,
13,
4706,
4720,
353,
931,
13239,
29889,
329,
29883,
3707,
580,
718,
12865,
29889,
9346,
287,
2554,
29898,
23128,
29922,
29953,
29900,
29897,
13,
13,
4706,
363,
2643,
29918,
6112,
297,
313,
1025,
342,
29892,
716,
342,
1125,
13,
9651,
2825,
29918,
10718,
353,
2643,
29918,
6112,
1839,
11600,
2033,
13,
9651,
2825,
353,
931,
13239,
29889,
5510,
29918,
275,
327,
603,
29898,
11600,
29918,
10718,
29897,
13,
9651,
1583,
29889,
9294,
7058,
29898,
2230,
13239,
29889,
8945,
675,
29918,
2230,
29898,
11600,
511,
13,
462,
9651,
1993,
414,
29889,
29931,
404,
1349,
273,
29898,
578,
265,
876,
13,
13,
9651,
1583,
29889,
9294,
797,
877,
333,
742,
2643,
29918,
6112,
29897,
13,
13,
4706,
1583,
29889,
9294,
7058,
29898,
1025,
342,
1839,
11600,
7464,
13,
462,
4706,
1993,
414,
29889,
29931,
404,
1349,
273,
29898,
1482,
342,
1839,
11600,
25901,
13,
13,
4706,
396,
4321,
9521,
7374,
291,
13,
4706,
1583,
29889,
8299,
29889,
8143,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
396,
4321,
9521,
10379,
13,
4706,
1583,
29889,
9294,
8824,
29898,
1311,
29889,
8299,
29889,
9933,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
876,
13,
13,
4706,
396,
4321,
5538,
3664,
1252,
391,
3682,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
657,
29918,
19635,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
842,
29918,
19635,
877,
1688,
742,
525,
8875,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
1678,
822,
1243,
29918,
16202,
29918,
1454,
29918,
6310,
29918,
9990,
29898,
1311,
1125,
13,
4706,
2825,
353,
1583,
29889,
8299,
29889,
3258,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
1583,
29889,
9294,
5574,
29898,
11600,
29897,
13,
13,
4706,
22663,
353,
1583,
29889,
8299,
29889,
16202,
877,
1688,
742,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
2643,
29918,
16202,
353,
22663,
1839,
19158,
2033,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
16202,
1839,
9021,
7464,
29871,
29900,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
16202,
1839,
29883,
13190,
7464,
29871,
29900,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
16202,
1839,
7827,
7464,
29871,
29900,
29897,
13,
13,
4706,
1583,
29889,
9294,
3664,
797,
877,
1482,
342,
742,
2643,
29918,
16202,
29897,
13,
4706,
1583,
29889,
9294,
3664,
797,
877,
1025,
342,
742,
2643,
29918,
16202,
29897,
13,
13,
13,
1990,
7777,
2956,
3057,
29898,
2956,
5160,
3057,
1125,
13,
1678,
9995,
3728,
15830,
2967,
6987,
29889,
13,
13,
1678,
6058,
29923,
29898,
29888,
433,
546,
29947,
29955,
1125,
1954,
2037,
800,
310,
445,
770,
881,
13,
1678,
5712,
278,
734,
279,
6767,
1158,
297,
1797,
13,
1678,
304,
5941,
701,
8635,
29915,
29879,
2106,
29889,
13,
1678,
9995,
13,
1678,
9521,
29918,
978,
353,
525,
1688,
29918,
9990,
29915,
13,
1678,
4701,
29918,
3188,
29918,
1990,
353,
8635,
29889,
3728,
13,
13,
1678,
396,
12048,
11057,
920,
4049,
1518,
2859,
7191,
526,
282,
2007,
287,
29892,
297,
5226,
29889,
13,
1678,
330,
29883,
29918,
19207,
353,
29871,
29900,
13,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
2428,
29898,
3728,
2956,
3057,
29892,
1583,
467,
842,
3373,
580,
13,
13,
4706,
396,
365,
1691,
1653,
263,
9521,
13,
4706,
1583,
29889,
9990,
29918,
8299,
353,
1583,
29889,
9465,
29889,
9990,
29918,
8299,
13,
4706,
1583,
29889,
29883,
8342,
29918,
8299,
353,
1583,
29889,
9465,
29889,
29883,
8342,
29918,
8299,
13,
4706,
1583,
29889,
9990,
29918,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
1678,
822,
734,
279,
6767,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9990,
29918,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
2428,
29898,
3728,
2956,
3057,
29892,
1583,
467,
371,
279,
6767,
580,
13,
13,
1678,
822,
1243,
29918,
4906,
29918,
29880,
22532,
29898,
1311,
1125,
13,
4706,
9521,
29918,
978,
353,
1583,
29889,
9990,
29918,
978,
13,
13,
4706,
2643,
353,
426,
13,
9651,
525,
698,
29880,
2396,
29871,
29953,
29900,
29892,
13,
9651,
525,
2587,
2396,
426,
13,
18884,
525,
3696,
2396,
525,
5841,
786,
4763,
287,
742,
13,
18884,
525,
1627,
786,
1204,
2396,
525,
29883,
29941,
29955,
29947,
29947,
29896,
29941,
29883,
29899,
29941,
29888,
29900,
29890,
29899,
29896,
29896,
29872,
29906,
29899,
328,
29929,
29906,
29899,
29955,
29947,
29906,
29941,
29881,
29906,
29890,
29900,
29888,
29941,
346,
29915,
13,
9651,
500,
13,
4706,
500,
13,
13,
4706,
396,
4321,
7777,
6760,
362,
13,
4706,
2825,
353,
1051,
29898,
1311,
29889,
8299,
29889,
2490,
29898,
9990,
29918,
978,
29892,
518,
4906,
1402,
13,
462,
462,
9651,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
9651,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
22130,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
11600,
511,
29871,
29896,
29897,
13,
4706,
2643,
29918,
333,
353,
2825,
29961,
29900,
29962,
13,
13,
4706,
396,
4321,
7777,
3617,
13,
4706,
2643,
29918,
449,
353,
1583,
29889,
8299,
29889,
657,
29898,
9990,
29918,
978,
29892,
2643,
29918,
333,
29892,
13,
462,
462,
3986,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
842,
29898,
4906,
29918,
449,
511,
731,
29898,
877,
333,
742,
525,
2587,
742,
525,
698,
29880,
742,
525,
482,
29915,
4961,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
449,
1839,
333,
7464,
2643,
29918,
333,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
449,
1839,
2587,
7464,
2643,
1839,
2587,
11287,
13,
4706,
1583,
29889,
9294,
9843,
29898,
4906,
29918,
449,
1839,
698,
29880,
7464,
2643,
1839,
698,
29880,
11287,
13,
13,
4706,
396,
4321,
7777,
897,
1026,
291,
13,
4706,
1583,
29889,
8299,
29889,
8143,
29898,
9990,
29918,
978,
29892,
2643,
29918,
333,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
396,
4321,
947,
451,
1863,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
657,
29898,
9990,
29918,
978,
29892,
2643,
29918,
333,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
1678,
822,
1243,
29918,
657,
29918,
9910,
29898,
1311,
1125,
13,
4706,
3132,
29918,
25118,
353,
318,
5416,
29889,
25118,
29946,
580,
13,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
8299,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29892,
954,
29922,
29896,
29945,
29897,
13,
13,
4706,
822,
2254,
29918,
19158,
29898,
9684,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
9651,
14881,
353,
1583,
29889,
8299,
29889,
1761,
10456,
5085,
29892,
3579,
19290,
29897,
13,
9651,
10887,
3174,
353,
1051,
29898,
4622,
29898,
1639,
2467,
876,
13,
9651,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
1516,
3174,
511,
3806,
29897,
13,
9651,
736,
14881,
13,
13,
4706,
396,
4321,
599,
7191,
29892,
2916,
7700,
322,
318,
5416,
13,
4706,
2254,
29918,
19158,
29898,
29900,
29892,
1583,
29889,
9990,
29918,
978,
29892,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
418,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29897,
13,
13,
4706,
396,
4321,
599,
7191,
322,
4046,
13,
4706,
2254,
29918,
19158,
29898,
29896,
29945,
29892,
1583,
29889,
9990,
29918,
978,
29892,
2060,
29922,
1311,
29889,
4836,
29892,
4046,
29922,
29906,
29900,
29892,
13,
462,
418,
2916,
29922,
5574,
29897,
13,
13,
4706,
396,
4321,
599,
7191,
29892,
2916,
5852,
29892,
322,
318,
5416,
13,
4706,
14881,
353,
2254,
29918,
19158,
29898,
29896,
29900,
29892,
1583,
29889,
9990,
29918,
978,
29892,
2916,
29922,
5574,
29892,
13,
462,
462,
1678,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
1678,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29897,
13,
13,
4706,
396,
4321,
599,
7191,
29892,
2916,
5852,
29892,
318,
5416,
322,
17456,
13,
4706,
2254,
29918,
19158,
29898,
29945,
29892,
1583,
29889,
9990,
29918,
978,
29892,
2916,
29922,
5574,
29892,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
418,
17456,
29922,
4622,
29898,
1639,
2467,
511,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29897,
13,
13,
1678,
822,
1243,
29918,
9910,
29918,
4841,
29898,
1311,
1125,
13,
4706,
7191,
29918,
262,
353,
518,
10998,
698,
29880,
2396,
29871,
29896,
29906,
29900,
29892,
525,
2587,
2396,
29871,
29900,
1118,
11117,
698,
29880,
2396,
29871,
29906,
29946,
29900,
29892,
525,
2587,
2396,
29871,
29896,
6525,
13,
4706,
18999,
353,
1583,
29889,
8299,
29889,
2490,
29898,
1311,
29889,
9990,
29918,
978,
29892,
7191,
29918,
262,
29892,
13,
462,
462,
259,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
259,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
3101,
13,
13,
4706,
7191,
29918,
449,
353,
1583,
29889,
8299,
29889,
8645,
29895,
29918,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
18999,
29892,
13,
462,
462,
18884,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
363,
22645,
29892,
2643,
297,
26985,
29898,
19158,
29918,
449,
1125,
13,
9651,
1583,
29889,
9294,
9843,
29898,
842,
29898,
4906,
511,
731,
29898,
877,
333,
742,
525,
2587,
742,
525,
698,
29880,
742,
525,
482,
29915,
4961,
13,
9651,
1583,
29889,
9294,
9843,
29898,
4906,
1839,
2587,
7464,
22645,
29897,
13,
13,
4706,
1583,
29889,
8299,
29889,
8645,
29895,
29918,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
18999,
29892,
13,
462,
462,
1678,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
16329,
13463,
362,
1125,
13,
9651,
1121,
353,
1583,
29889,
8299,
29889,
8645,
29895,
29918,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
18999,
29892,
13,
462,
462,
795,
2060,
29922,
1311,
29889,
4836,
29897,
13,
9651,
2446,
29898,
2914,
29897,
13,
13,
1678,
822,
1243,
29918,
29883,
8342,
29918,
15987,
29879,
29898,
1311,
1125,
13,
4706,
3132,
29918,
25118,
353,
318,
5416,
29889,
25118,
29946,
580,
13,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
8299,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29892,
954,
29922,
29896,
29906,
29897,
13,
13,
4706,
822,
1051,
29918,
19158,
29898,
2856,
29918,
29883,
13190,
29922,
8516,
1125,
13,
9651,
9049,
5085,
353,
426,
13,
18884,
525,
4836,
2396,
1583,
29889,
4836,
29892,
13,
18884,
525,
4645,
29918,
25118,
2396,
3132,
29918,
25118,
29892,
13,
18884,
525,
8057,
2396,
5852,
29892,
13,
9651,
500,
13,
13,
9651,
396,
1019,
546,
368,
1243,
2322,
995,
13,
9651,
565,
3160,
29918,
29883,
13190,
338,
451,
6213,
29901,
13,
18884,
9049,
5085,
1839,
2856,
29918,
29883,
13190,
2033,
353,
3160,
29918,
29883,
13190,
13,
13,
9651,
14881,
353,
1583,
29889,
8299,
29889,
1761,
29898,
1311,
29889,
9990,
29918,
978,
29892,
3579,
19290,
29897,
13,
13,
9651,
7191,
353,
2446,
29898,
1639,
2467,
29897,
13,
9651,
736,
518,
7645,
1839,
333,
2033,
363,
10191,
297,
7191,
29962,
13,
13,
4706,
7191,
29918,
11083,
353,
1051,
29918,
19158,
29898,
5574,
29897,
13,
13,
4706,
12700,
353,
11117,
698,
29880,
2396,
29871,
29955,
29900,
29892,
525,
3874,
346,
2396,
29871,
29953,
29900,
29913,
13,
4706,
1790,
29918,
25232,
29892,
903,
353,
1583,
29889,
29883,
8342,
29918,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
12700,
29892,
13,
462,
462,
462,
418,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
7191,
29918,
7045,
353,
1051,
29918,
19158,
29898,
5574,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
19158,
29918,
11083,
29892,
7191,
29918,
7045,
29897,
13,
13,
4706,
7191,
29918,
735,
22368,
29918,
29883,
13190,
353,
1051,
29918,
19158,
580,
13,
4706,
1583,
29889,
9294,
3664,
9843,
29898,
19158,
29918,
11083,
29892,
7191,
29918,
735,
22368,
29918,
29883,
13190,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29906,
29892,
7431,
29898,
19158,
29918,
735,
22368,
29918,
29883,
13190,
876,
13,
13,
4706,
274,
333,
29892,
10887,
3174,
353,
1583,
29889,
29883,
8342,
29918,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
12700,
29892,
13,
462,
462,
462,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
518,
7645,
29896,
29892,
10191,
29906,
29962,
353,
10887,
3174,
13,
13,
4706,
396,
319,
2743,
5995,
947,
451,
9801,
278,
2643,
7374,
291,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
3664,
15737,
4430,
1125,
13,
9651,
1583,
29889,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
10191,
29896,
1839,
333,
7464,
13,
462,
462,
259,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
259,
5995,
29922,
23327,
29918,
25232,
29897,
13,
13,
4706,
396,
8561,
1854,
263,
2643,
508,
367,
11132,
411,
263,
5995,
13,
4706,
1583,
29889,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
10191,
29896,
1839,
333,
7464,
13,
462,
1669,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
1669,
5995,
29922,
25232,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
10191,
29896,
1839,
333,
7464,
13,
462,
18884,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
396,
8561,
1854,
1316,
263,
7374,
291,
338,
1957,
1526,
327,
296,
13,
4706,
1583,
29889,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
10191,
29896,
1839,
333,
7464,
13,
462,
1669,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
1669,
5995,
29922,
25232,
29897,
13,
13,
4706,
396,
319,
1661,
29899,
735,
15423,
5995,
947,
451,
9801,
278,
2643,
7374,
291,
13,
4706,
1583,
29889,
29883,
8342,
29918,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
274,
333,
29892,
13,
462,
462,
268,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
3664,
15737,
4430,
1125,
13,
9651,
1583,
29889,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
10191,
29906,
1839,
333,
7464,
13,
462,
462,
259,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
259,
5995,
29922,
25232,
29897,
13,
13,
1678,
732,
13424,
29889,
275,
29918,
28544,
29898,
16122,
29922,
2892,
1583,
29901,
1583,
29889,
27354,
29918,
19207,
2804,
29871,
29900,
29897,
13,
1678,
822,
1243,
29918,
4548,
2859,
29918,
19158,
29898,
1311,
1125,
13,
4706,
7191,
353,
518,
10998,
2587,
2396,
29871,
29941,
29889,
29896,
29946,
29892,
525,
698,
29880,
2396,
29871,
29900,
6525,
13,
4706,
3132,
29918,
25118,
353,
318,
5416,
29889,
25118,
29946,
580,
13,
13,
4706,
518,
7645,
333,
29962,
353,
1583,
29889,
8299,
29889,
2490,
29898,
1311,
29889,
9990,
29918,
978,
29892,
7191,
29892,
13,
462,
462,
539,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
539,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29897,
13,
13,
4706,
931,
29889,
17059,
29898,
1311,
29889,
27354,
29918,
19207,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
10191,
333,
29892,
13,
462,
18884,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
22663,
353,
1583,
29889,
9990,
29918,
8299,
29889,
16202,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
9651,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
16202,
1839,
19158,
16215,
9021,
7464,
29871,
29900,
29897,
13,
13,
1678,
822,
1243,
29918,
12313,
29918,
333,
29898,
1311,
1125,
13,
4706,
396,
6058,
29923,
29898,
8223,
29899,
29883,
370,
13941,
1125,
319,
4439,
15628,
3553,
881,
1121,
297,
385,
4069,
13,
4706,
396,
2346,
29889,
390,
1759,
292,
385,
3682,
363,
2854,
1218,
23481,
3732,
278,
13,
4706,
396,
5314,
901,
26952,
2012,
310,
5622,
10631,
310,
13,
4706,
396,
278,
7198,
29914,
27636,
9608,
29892,
10734,
746,
16743,
411,
13,
4706,
396,
21610,
6931,
29889,
13,
4706,
4319,
29918,
4906,
29918,
333,
353,
525,
20230,
29915,
13,
4706,
1583,
29889,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
1669,
4319,
29918,
4906,
29918,
333,
29892,
13,
462,
1669,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12523,
29889,
3728,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
18884,
4319,
29918,
4906,
29918,
333,
29892,
13,
462,
18884,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
1678,
822,
1243,
29918,
12313,
29918,
29883,
8342,
29918,
333,
29898,
1311,
1125,
13,
4706,
518,
7645,
333,
29962,
353,
1583,
29889,
8299,
29889,
2490,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
539,
518,
10998,
2587,
2396,
24335,
525,
698,
29880,
2396,
29871,
29896,
29900,
29913,
1402,
13,
462,
462,
539,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
539,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
3101,
13,
13,
4706,
4319,
29918,
29883,
8342,
29918,
333,
353,
21921,
360,
29366,
10911,
712,
1041,
29915,
13,
4706,
1583,
29889,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
1669,
10191,
333,
29892,
13,
462,
1669,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
1669,
5995,
29922,
12313,
29918,
29883,
8342,
29918,
333,
29897,
13,
13,
1678,
822,
1243,
29918,
12313,
29918,
22976,
29898,
1311,
1125,
13,
4706,
4319,
29918,
22976,
353,
525,
20230,
29915,
13,
4706,
14881,
353,
1583,
29889,
8299,
29889,
1761,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
965,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
965,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
3285,
13,
462,
462,
965,
17456,
29922,
12313,
29918,
22976,
29897,
13,
4706,
7191,
353,
1051,
29898,
4622,
29898,
1639,
2467,
876,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
19158,
29892,
518,
2314,
13,
13,
1678,
822,
1243,
29918,
6605,
29918,
1454,
29918,
4102,
29898,
1311,
1125,
13,
4706,
3132,
29918,
25118,
353,
318,
5416,
29889,
25118,
29946,
580,
13,
13,
4706,
518,
7645,
333,
29918,
4102,
29962,
353,
1583,
29889,
8299,
29889,
2490,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
632,
518,
10998,
2587,
2396,
24335,
525,
698,
29880,
2396,
29871,
29896,
29906,
29900,
29913,
1402,
13,
462,
462,
632,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
632,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29897,
13,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
8299,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29892,
954,
29922,
29896,
29900,
29897,
13,
13,
4706,
518,
7645,
333,
29918,
4230,
29962,
353,
1583,
29889,
8299,
29889,
2490,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
9651,
518,
10998,
2587,
2396,
24335,
525,
698,
29880,
2396,
29871,
29896,
29906,
29900,
29913,
1402,
13,
462,
462,
9651,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
9651,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29897,
13,
13,
4706,
10191,
29918,
6151,
353,
1583,
29889,
8299,
29889,
4102,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
4706,
1583,
29889,
4836,
29892,
13,
462,
462,
308,
29896,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
7645,
29918,
6151,
1839,
333,
7464,
10191,
333,
29918,
4102,
29897,
13,
13,
4706,
10191,
29918,
14273,
353,
1583,
29889,
8299,
29889,
4102,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
308,
1583,
29889,
4836,
29892,
13,
462,
462,
308,
448,
29896,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
7645,
29918,
14273,
1839,
333,
7464,
10191,
333,
29918,
4230,
29897,
13,
13,
13,
1990,
6015,
326,
2956,
3057,
29898,
2956,
5160,
3057,
1125,
13,
1678,
9995,
29907,
8342,
15830,
2967,
6987,
29889,
13,
13,
1678,
6058,
29923,
29898,
29888,
433,
546,
29947,
29955,
1125,
1954,
2037,
800,
310,
445,
770,
881,
13,
1678,
5712,
278,
734,
279,
6767,
1158,
297,
1797,
13,
1678,
304,
5941,
701,
8635,
29915,
29879,
2106,
29889,
13,
1678,
9995,
13,
1678,
9521,
29918,
978,
353,
525,
1688,
29918,
9990,
29915,
13,
1678,
4701,
29918,
3188,
29918,
1990,
353,
8635,
29889,
29907,
8342,
13,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
2428,
29898,
29907,
8342,
2956,
3057,
29892,
1583,
467,
842,
3373,
580,
13,
13,
4706,
396,
365,
1691,
1653,
263,
9521,
13,
4706,
1583,
29889,
9990,
29918,
8299,
353,
1583,
29889,
9465,
29889,
9990,
29918,
8299,
13,
4706,
1583,
29889,
4906,
29918,
8299,
353,
1583,
29889,
9465,
29889,
4906,
29918,
8299,
13,
4706,
1583,
29889,
9990,
29918,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
1678,
822,
734,
279,
6767,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9990,
29918,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
2428,
29898,
29907,
8342,
2956,
3057,
29892,
1583,
467,
371,
279,
6767,
580,
13,
13,
1678,
822,
1243,
29918,
29883,
8342,
29918,
29880,
22532,
29898,
1311,
1125,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
4906,
29918,
8299,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
3285,
13,
462,
308,
954,
29922,
29906,
29900,
29897,
13,
13,
4706,
12700,
353,
11117,
698,
29880,
2396,
29871,
29955,
29900,
29892,
525,
3874,
346,
2396,
29871,
29941,
29900,
29913,
13,
13,
4706,
396,
8561,
1854,
1653,
1736,
13,
4706,
5995,
29918,
333,
29892,
7191,
353,
1583,
29889,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
12700,
29892,
13,
462,
462,
462,
1678,
2060,
29922,
1311,
29889,
4836,
29892,
13,
462,
462,
462,
1678,
4046,
29922,
29896,
29945,
29897,
13,
13,
4706,
7191,
353,
1051,
29898,
19158,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
19158,
511,
29871,
29896,
29945,
29897,
13,
13,
4706,
396,
22521,
545,
5462,
434,
22663,
13,
4706,
2613,
517,
29888,
353,
1583,
29889,
9990,
29918,
8299,
29889,
16202,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
795,
2060,
29922,
1311,
29889,
4836,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29883,
1309,
517,
29888,
1839,
19158,
16215,
29883,
13190,
7464,
29871,
29896,
29945,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29883,
1309,
517,
29888,
1839,
19158,
16215,
9021,
7464,
29871,
29945,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29883,
1309,
517,
29888,
1839,
19158,
16215,
7827,
7464,
29871,
29906,
29900,
29897,
13,
13,
4706,
396,
8561,
1854,
679,
1736,
13,
4706,
5995,
29892,
7191,
29906,
353,
1583,
29889,
8299,
29889,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
5995,
29918,
333,
29892,
13,
462,
462,
1669,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
7191,
29906,
353,
1051,
29898,
19158,
29906,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
19158,
29906,
511,
29871,
29896,
29945,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
19158,
29892,
7191,
29906,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29883,
8342,
1839,
698,
29880,
7464,
29871,
29955,
29900,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29883,
8342,
1839,
333,
7464,
5995,
29918,
333,
29897,
13,
13,
4706,
716,
29918,
7299,
353,
11117,
698,
29880,
2396,
29871,
29896,
29900,
29900,
29892,
525,
3874,
346,
2396,
29871,
29953,
29900,
29913,
13,
4706,
1583,
29889,
8299,
29889,
5504,
29898,
1311,
29889,
9990,
29918,
978,
29892,
5995,
29918,
333,
29892,
13,
462,
1669,
716,
29918,
7299,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
396,
8561,
1854,
2767,
1736,
13,
4706,
5995,
29892,
7191,
29906,
353,
1583,
29889,
8299,
29889,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
5995,
29918,
333,
29892,
13,
462,
462,
1669,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
7191,
29906,
353,
1051,
29898,
19158,
29906,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
19158,
29906,
511,
29871,
29896,
29945,
29897,
13,
13,
4706,
396,
14402,
29898,
1537,
12323,
1125,
3462,
777,
6987,
304,
9801,
278,
260,
15206,
338,
13,
4706,
396,
10410,
29914,
1333,
29899,
1062,
2760,
29889,
13,
4706,
363,
10191,
29896,
29892,
10191,
29906,
297,
14319,
29898,
19158,
29892,
7191,
29906,
1125,
13,
9651,
1583,
29889,
9294,
9843,
29898,
7645,
29896,
1839,
2587,
7464,
10191,
29906,
1839,
2587,
11287,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29883,
8342,
1839,
698,
29880,
7464,
29871,
29896,
29900,
29900,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29883,
8342,
1839,
333,
7464,
5995,
29918,
333,
29897,
13,
13,
4706,
396,
8561,
1854,
5217,
1736,
13,
4706,
1583,
29889,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
5995,
29918,
333,
29892,
13,
462,
1669,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
1583,
29889,
9294,
29934,
1759,
267,
29898,
12925,
29889,
12523,
29889,
29907,
8342,
25125,
3664,
1252,
391,
29892,
13,
462,
3986,
1583,
29889,
8299,
29889,
657,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
3986,
5995,
29918,
333,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
1678,
822,
1243,
29918,
21843,
29918,
29880,
361,
5410,
29898,
1311,
1125,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
4906,
29918,
8299,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
3285,
13,
462,
308,
954,
29922,
29906,
29900,
29892,
260,
15206,
29922,
29896,
29906,
29900,
29897,
13,
13,
4706,
12700,
353,
11117,
698,
29880,
2396,
29871,
29955,
29955,
29955,
29892,
525,
3874,
346,
2396,
29871,
29900,
29913,
13,
13,
4706,
5995,
29918,
333,
29892,
7191,
353,
1583,
29889,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
12700,
29892,
13,
462,
462,
462,
1678,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
363,
2643,
297,
7191,
29901,
13,
9651,
1583,
29889,
9294,
9843,
29898,
4906,
1839,
698,
29880,
7464,
29871,
29955,
29955,
29955,
29897,
13,
13,
1678,
822,
1243,
29918,
21843,
29918,
29880,
361,
5410,
29918,
2541,
29918,
3874,
346,
29918,
29896,
29898,
1311,
1125,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
4906,
29918,
8299,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
3285,
13,
462,
308,
954,
29922,
29906,
29900,
29892,
260,
15206,
29922,
29896,
29906,
29900,
29897,
13,
13,
4706,
12700,
353,
11117,
698,
29880,
2396,
29871,
29955,
29955,
29955,
29892,
525,
3874,
346,
2396,
29871,
29906,
29941,
29913,
13,
13,
4706,
5995,
29918,
333,
29892,
7191,
353,
1583,
29889,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
12700,
29892,
13,
462,
462,
462,
1678,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
363,
2643,
297,
7191,
29901,
13,
9651,
1583,
29889,
9294,
9843,
29898,
4906,
1839,
698,
29880,
7464,
29871,
29947,
29900,
29900,
29897,
13,
13,
1678,
822,
1243,
29918,
21843,
29918,
29880,
361,
5410,
29918,
2541,
29918,
3874,
346,
29918,
29906,
29898,
1311,
1125,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
4906,
29918,
8299,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
3285,
13,
462,
308,
954,
29922,
29906,
29900,
29892,
260,
15206,
29922,
29896,
29906,
29900,
29897,
13,
13,
4706,
396,
8512,
260,
15206,
338,
3109,
1135,
278,
2643,
29915,
29879,
323,
14632,
29892,
278,
17659,
13,
4706,
396,
3785,
15223,
372,
925,
975,
278,
7636,
29889,
13,
4706,
12700,
353,
11117,
698,
29880,
2396,
29871,
29896,
29900,
29900,
29892,
525,
3874,
346,
2396,
29871,
29906,
29906,
29913,
13,
13,
4706,
5995,
29918,
333,
29892,
7191,
353,
1583,
29889,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
12700,
29892,
13,
462,
462,
462,
1678,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
363,
2643,
297,
7191,
29901,
13,
9651,
1583,
29889,
9294,
9843,
29898,
4906,
1839,
698,
29880,
7464,
29871,
29896,
29906,
29906,
29897,
13,
13,
1678,
822,
1243,
29918,
1867,
29918,
1333,
29918,
21843,
29918,
29880,
361,
5410,
29898,
1311,
1125,
13,
4706,
903,
7851,
29918,
7241,
486,
1973,
29898,
1311,
29889,
4906,
29918,
8299,
29892,
1583,
29889,
9990,
29918,
978,
29892,
13,
462,
308,
2060,
29922,
1311,
29889,
4836,
29892,
3132,
29918,
25118,
29922,
25118,
29889,
25118,
29946,
3285,
13,
462,
308,
954,
29922,
29906,
29900,
29892,
260,
15206,
29922,
29896,
29906,
29900,
29897,
13,
13,
4706,
396,
14542,
852,
263,
260,
15206,
393,
338,
3109,
1135,
278,
2643,
29915,
29879,
1857,
323,
14632,
13,
4706,
12700,
353,
11117,
698,
29880,
2396,
29871,
29953,
29900,
29892,
525,
3874,
346,
2396,
29871,
29941,
29900,
29913,
13,
13,
4706,
5995,
29918,
333,
29892,
7191,
353,
1583,
29889,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
12700,
29892,
13,
462,
462,
462,
1678,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
363,
2643,
297,
7191,
29901,
13,
9651,
1583,
29889,
9294,
9843,
29898,
4906,
1839,
698,
29880,
7464,
29871,
29896,
29906,
29900,
29897,
13,
13,
1678,
822,
1243,
29918,
4548,
2859,
29918,
29883,
8342,
29898,
1311,
1125,
13,
4706,
12700,
353,
11117,
698,
29880,
2396,
29871,
29900,
29892,
525,
3874,
346,
2396,
29871,
29953,
29900,
29913,
13,
13,
4706,
5995,
29918,
333,
29892,
7191,
353,
1583,
29889,
8299,
29889,
3258,
29898,
1311,
29889,
9990,
29918,
978,
29892,
12700,
29892,
13,
462,
462,
462,
1678,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
5995,
29918,
333,
29892,
13,
462,
18884,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12925,
29889,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
5504,
29898,
1311,
29889,
9990,
29918,
978,
29892,
5995,
29918,
333,
29892,
13,
462,
462,
259,
12700,
29892,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
1678,
822,
1243,
29918,
453,
15628,
29918,
333,
29898,
1311,
1125,
13,
4706,
396,
738,
4486,
29899,
15628,
23481,
881,
367,
17878,
408,
1661,
29899,
735,
15423,
6743,
29889,
13,
13,
4706,
1583,
29889,
8299,
29889,
8143,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
1669,
525,
453,
15628,
742,
13,
462,
1669,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
657,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
18884,
525,
453,
15628,
742,
13,
462,
18884,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
4706,
411,
6724,
29889,
17854,
29898,
12523,
29889,
25125,
3664,
1252,
391,
1125,
13,
9651,
1583,
29889,
8299,
29889,
5504,
29898,
1311,
29889,
9990,
29918,
978,
29892,
13,
462,
462,
259,
525,
453,
15628,
742,
13,
462,
462,
259,
11117,
698,
29880,
2396,
29871,
29946,
29900,
1118,
13,
462,
462,
259,
2060,
29922,
1311,
29889,
4836,
29897,
13,
13,
13,
1990,
1383,
3163,
2956,
3057,
29898,
2956,
5160,
3057,
1125,
13,
1678,
9995,
2713,
3163,
15830,
2967,
6987,
29889,
13,
13,
1678,
6058,
29923,
29898,
29888,
433,
546,
29947,
29955,
1125,
1954,
2037,
800,
310,
445,
770,
881,
13,
1678,
5712,
278,
734,
279,
6767,
1158,
297,
1797,
13,
1678,
304,
5941,
701,
8635,
29915,
29879,
2106,
29889,
13,
1678,
9995,
13,
1678,
4701,
29918,
3188,
29918,
1990,
353,
8635,
29889,
2713,
3163,
5160,
13,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
2428,
29898,
2713,
3163,
2956,
3057,
29892,
1583,
467,
842,
3373,
580,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
353,
1583,
29889,
9465,
29889,
845,
3163,
29918,
8299,
13,
13,
4706,
396,
2803,
29915,
29879,
1653,
697,
528,
538,
13,
4706,
1583,
29889,
845,
538,
353,
851,
29898,
25118,
29889,
25118,
29896,
3101,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
3258,
29898,
1311,
29889,
845,
538,
29892,
29871,
29896,
29900,
29900,
29892,
525,
7640,
742,
426,
1800,
13,
13,
1678,
822,
734,
279,
6767,
29898,
1311,
1125,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
8865,
29918,
497,
580,
13,
4706,
2428,
29898,
2713,
3163,
2956,
3057,
29892,
1583,
467,
371,
279,
6767,
580,
13,
13,
1678,
822,
1243,
29918,
3258,
29918,
29879,
1682,
3947,
29879,
29898,
1311,
1125,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
3258,
29898,
710,
29898,
25118,
29889,
25118,
29896,
25739,
13,
462,
462,
539,
29896,
29900,
29900,
29892,
525,
7640,
742,
426,
1800,
13,
13,
1678,
822,
1243,
29918,
3258,
29918,
3445,
6048,
29918,
265,
29918,
20908,
5926,
29918,
7851,
29898,
1311,
1125,
13,
4706,
1024,
353,
851,
29898,
25118,
29889,
25118,
29896,
3101,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
3258,
29898,
978,
29892,
13,
462,
462,
539,
29896,
29900,
29900,
29892,
525,
7640,
742,
426,
1800,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
3258,
29898,
978,
29892,
13,
462,
462,
539,
29896,
29896,
29896,
29892,
525,
7640,
29906,
742,
426,
1800,
13,
4706,
6251,
353,
1583,
29889,
845,
3163,
29918,
8299,
29889,
657,
29898,
978,
29897,
13,
4706,
1583,
3032,
845,
538,
29918,
17854,
29879,
29898,
8269,
29892,
921,
978,
29922,
978,
29892,
921,
7915,
29922,
29896,
29896,
29896,
29892,
13,
462,
9651,
921,
5479,
2433,
7640,
29906,
1495,
13,
13,
1678,
822,
903,
845,
538,
29918,
17854,
29879,
29898,
1311,
29892,
528,
538,
29892,
921,
978,
29892,
921,
7915,
29892,
921,
5479,
1125,
13,
4706,
1583,
29889,
9294,
797,
877,
978,
742,
528,
538,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
845,
538,
1839,
978,
7464,
921,
978,
29897,
13,
4706,
1583,
29889,
9294,
797,
877,
7915,
742,
528,
538,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
845,
538,
1839,
7915,
7464,
921,
7915,
29897,
13,
4706,
1583,
29889,
9294,
797,
877,
5338,
742,
528,
538,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
845,
538,
1839,
5338,
7464,
921,
5479,
29897,
13,
13,
1678,
822,
1243,
29918,
657,
29918,
18280,
29918,
9684,
29918,
3051,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
845,
3163,
29918,
8299,
29889,
657,
29898,
1311,
29889,
845,
538,
29897,
13,
4706,
1583,
3032,
845,
538,
29918,
17854,
29879,
29898,
690,
29892,
1583,
29889,
845,
538,
29892,
29871,
29896,
29900,
29900,
29892,
525,
7640,
1495,
13,
4706,
1583,
29889,
9294,
3664,
797,
877,
6768,
742,
620,
29897,
13,
13,
1678,
822,
1243,
29918,
29881,
11881,
29918,
657,
29918,
18280,
29918,
9684,
29918,
3051,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
845,
3163,
29918,
8299,
29889,
657,
29898,
1311,
29889,
845,
538,
29892,
13173,
29922,
5574,
29897,
13,
4706,
1583,
29889,
9294,
797,
877,
6768,
742,
620,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
690,
1839,
6768,
7464,
426,
1800,
13,
13,
1678,
822,
1243,
29918,
657,
29918,
336,
4637,
29918,
361,
29918,
1333,
29918,
11940,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
29934,
1759,
267,
29898,
12925,
29889,
12523,
29889,
2713,
538,
25125,
3664,
1252,
391,
29892,
13,
462,
3986,
1583,
29889,
845,
3163,
29918,
8299,
29889,
657,
29892,
525,
1333,
9933,
1495,
13,
13,
1678,
822,
1243,
29918,
9933,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
5574,
29898,
1311,
29889,
845,
3163,
29918,
8299,
29889,
9933,
29898,
1311,
29889,
845,
538,
876,
13,
4706,
1583,
29889,
9294,
8824,
29898,
1311,
29889,
845,
3163,
29918,
8299,
29889,
9933,
877,
1333,
9933,
8785,
13,
13,
1678,
822,
1243,
29918,
5504,
29918,
336,
4637,
29918,
9294,
291,
29918,
2704,
29918,
265,
29918,
12313,
29918,
9621,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
29934,
1759,
267,
29898,
14697,
291,
2392,
29892,
1583,
29889,
845,
3163,
29918,
8299,
29889,
5504,
29892,
13,
462,
3986,
1583,
29889,
845,
538,
29897,
13,
13,
1678,
822,
1243,
29918,
5504,
29918,
13129,
29898,
1311,
1125,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
5504,
29898,
1311,
29889,
845,
538,
29892,
7688,
29922,
29896,
29900,
29896,
29892,
13,
462,
462,
418,
21333,
2433,
1127,
275,
597,
7640,
742,
13,
462,
462,
418,
3987,
3790,
29915,
29874,
2396,
29871,
29896,
1800,
13,
4706,
620,
353,
1583,
29889,
845,
3163,
29918,
8299,
29889,
657,
29898,
1311,
29889,
845,
538,
29892,
13173,
29922,
5574,
29897,
13,
4706,
1583,
3032,
845,
538,
29918,
17854,
29879,
29898,
690,
29892,
1583,
29889,
845,
538,
29892,
29871,
29896,
29900,
29896,
29892,
525,
1127,
275,
597,
7640,
1495,
13,
4706,
1583,
29889,
9294,
9843,
29898,
690,
1839,
6768,
7464,
11117,
29874,
2396,
29871,
29896,
1800,
13,
13,
1678,
822,
1243,
29918,
8143,
29918,
13129,
29898,
1311,
1125,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
8143,
29898,
1311,
29889,
845,
538,
29897,
13,
4706,
1583,
29889,
9294,
8824,
29898,
1311,
29889,
845,
3163,
29918,
8299,
29889,
9933,
29898,
1311,
29889,
845,
538,
876,
13,
13,
1678,
822,
1243,
29918,
8143,
29918,
9290,
29916,
9696,
29918,
275,
29918,
25590,
296,
29898,
1311,
1125,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
8143,
877,
9290,
29916,
15423,
1495,
13,
13,
1678,
822,
1243,
29918,
8865,
29918,
497,
29918,
280,
7925,
29918,
517,
29918,
6310,
29918,
1761,
292,
29898,
1311,
1125,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
8865,
29918,
497,
580,
13,
4706,
10677,
353,
1583,
29889,
845,
3163,
29918,
8299,
29889,
1761,
580,
13,
4706,
1583,
29889,
9294,
29934,
1759,
267,
29898,
16329,
13463,
362,
29892,
2446,
29892,
10677,
29897,
13,
13,
1678,
822,
1243,
29918,
1761,
292,
29918,
12857,
29898,
1311,
1125,
13,
4706,
396,
6058,
29923,
29898,
8223,
29899,
29883,
370,
13941,
1125,
2967,
6251,
1006,
571,
267,
411,
18028,
2582,
13,
4706,
1583,
29889,
845,
3163,
29918,
8299,
29889,
8143,
29898,
1311,
29889,
845,
538,
29897,
13,
13,
4706,
1024,
29918,
1885,
353,
14013,
474,
29901,
18460,
29898,
536,
877,
29909,
1495,
718,
474,
29897,
13,
4706,
363,
474,
297,
3464,
29898,
29896,
29945,
1125,
13,
9651,
1583,
29889,
845,
3163,
29918,
8299,
29889,
3258,
29898,
978,
29918,
1885,
29898,
29875,
511,
474,
29892,
851,
29898,
29875,
511,
426,
1800,
13,
13,
4706,
620,
353,
1051,
29898,
1311,
29889,
845,
3163,
29918,
8299,
29889,
1761,
3101,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
690,
511,
29871,
29896,
29900,
29897,
13,
4706,
363,
474,
29892,
6251,
297,
26985,
29898,
690,
1125,
13,
9651,
1583,
3032,
845,
538,
29918,
17854,
29879,
29898,
8269,
29892,
1024,
29918,
1885,
29898,
29875,
511,
474,
29892,
851,
29898,
29875,
876,
13,
9651,
1583,
29889,
9294,
3664,
797,
877,
6768,
742,
6251,
29897,
13,
13,
4706,
620,
353,
1051,
29898,
1311,
29889,
845,
3163,
29918,
8299,
29889,
1761,
29898,
13400,
29922,
29945,
876,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
690,
511,
29871,
29945,
29897,
13,
13,
4706,
620,
353,
2446,
29898,
1311,
29889,
845,
3163,
29918,
8299,
29889,
1761,
29898,
22976,
29922,
978,
29918,
1885,
29898,
29941,
4961,
13,
4706,
1583,
3032,
845,
538,
29918,
17854,
29879,
29898,
690,
29892,
1024,
29918,
1885,
29898,
29946,
511,
29871,
29946,
29892,
525,
29946,
1495,
13,
13,
4706,
620,
353,
1051,
29898,
1311,
29889,
845,
3163,
29918,
8299,
29889,
1761,
29898,
29881,
11881,
29922,
5574,
876,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
690,
511,
29871,
29896,
29900,
29897,
13,
4706,
363,
474,
29892,
6251,
297,
26985,
29898,
690,
1125,
13,
9651,
1583,
3032,
845,
538,
29918,
17854,
29879,
29898,
8269,
29892,
1024,
29918,
1885,
29898,
29875,
511,
474,
29892,
851,
29898,
29875,
876,
13,
9651,
1583,
29889,
9294,
797,
877,
6768,
742,
6251,
29897,
13,
9651,
1583,
29889,
9294,
9843,
29898,
8269,
1839,
6768,
7464,
426,
1800,
13,
13,
13,
1990,
6706,
2956,
3057,
29898,
2956,
5160,
3057,
1125,
13,
1678,
4701,
29918,
3188,
29918,
1990,
353,
8635,
29889,
29907,
3968,
434,
5160,
13,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
2428,
29898,
29907,
3968,
434,
2956,
3057,
29892,
1583,
467,
842,
3373,
580,
13,
4706,
1583,
29889,
8299,
353,
1583,
29889,
9465,
29889,
28045,
434,
29918,
8299,
13,
4706,
1583,
29889,
9990,
353,
4832,
29889,
726,
29918,
1853,
29898,
25118,
29889,
25118,
29896,
3101,
13,
4706,
1583,
29889,
4836,
353,
4832,
29889,
726,
29918,
1853,
29898,
25118,
29889,
25118,
29896,
3101,
13,
13,
1678,
822,
734,
279,
6767,
29898,
1311,
1125,
13,
4706,
1583,
29889,
8299,
29889,
8865,
29918,
497,
580,
13,
4706,
2428,
29898,
29907,
3968,
434,
2956,
3057,
29892,
1583,
467,
371,
279,
6767,
580,
13,
13,
1678,
822,
903,
3198,
29918,
23905,
29898,
1311,
29892,
6251,
1125,
13,
4706,
1583,
29889,
9294,
797,
877,
9990,
742,
6251,
29897,
13,
4706,
1583,
29889,
9294,
797,
877,
4836,
742,
6251,
29897,
13,
4706,
1583,
29889,
9294,
797,
877,
845,
538,
742,
6251,
29897,
13,
4706,
1583,
29889,
9294,
3624,
4998,
29898,
8269,
1839,
9990,
7464,
4832,
29889,
726,
29918,
1853,
29897,
13,
4706,
1583,
29889,
9294,
3624,
4998,
29898,
8269,
1839,
4836,
7464,
4832,
29889,
726,
29918,
1853,
29897,
13,
4706,
1583,
29889,
9294,
3624,
4998,
29898,
8269,
1839,
845,
538,
7464,
4832,
29889,
726,
29918,
1853,
29897,
13,
13,
1678,
822,
903,
3198,
29918,
1767,
29898,
1311,
29892,
6251,
29892,
921,
9990,
29892,
921,
4836,
29892,
921,
845,
538,
1125,
13,
4706,
1583,
29889,
9294,
9843,
29898,
8269,
1839,
9990,
7464,
921,
9990,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
8269,
1839,
4836,
7464,
921,
4836,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
8269,
1839,
845,
538,
7464,
921,
845,
538,
29897,
13,
13,
1678,
822,
1243,
29918,
28045,
434,
29918,
8269,
29918,
19264,
29918,
23090,
29898,
1311,
1125,
13,
4706,
9521,
353,
1583,
29889,
9990,
13,
4706,
2060,
353,
1583,
29889,
4836,
13,
13,
4706,
396,
1423,
18028,
338,
12919,
4069,
13,
4706,
363,
282,
297,
1583,
29889,
8299,
29889,
1761,
29898,
4836,
1125,
13,
9651,
1583,
29889,
14057,
877,
8439,
881,
367,
694,
9976,
472,
445,
931,
1495,
13,
13,
4706,
396,
1653,
263,
18028,
29892,
1423,
967,
3309,
13,
4706,
411,
1371,
414,
29889,
845,
538,
29918,
26586,
29898,
1311,
29889,
8299,
29892,
29871,
29896,
29900,
29897,
408,
2149,
29901,
13,
9651,
2060,
353,
2149,
29961,
29900,
3816,
29900,
29962,
13,
9651,
14492,
353,
1051,
29898,
1311,
29889,
8299,
29889,
1761,
29898,
4836,
876,
13,
9651,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
10351,
511,
29871,
29896,
29900,
29897,
13,
13,
4706,
396,
1653,
29892,
1423,
10379,
29892,
5217,
13,
4706,
411,
1371,
414,
29889,
845,
538,
29918,
8269,
29898,
1311,
29889,
8299,
29892,
2060,
29892,
9521,
29892,
318,
29915,
29874,
29374,
13,
9651,
1583,
29889,
9294,
5574,
29898,
1311,
29889,
8299,
29889,
9933,
29898,
4836,
29892,
9521,
876,
13,
13,
4706,
396,
11539,
372,
694,
5520,
4864,
13,
4706,
1583,
29889,
9294,
8824,
29898,
1311,
29889,
8299,
29889,
9933,
29898,
4836,
29892,
9521,
876,
13,
13,
4706,
396,
11539,
372,
3508,
29915,
29873,
1051,
519,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
1761,
29898,
1311,
29889,
8299,
29889,
1761,
29898,
4836,
876,
511,
29871,
29900,
29897,
13,
13,
1678,
822,
1243,
29918,
1761,
29898,
1311,
1125,
13,
4706,
411,
1371,
414,
29889,
845,
538,
29918,
26586,
29898,
1311,
29889,
8299,
29892,
29871,
29896,
29900,
29897,
408,
2149,
29901,
13,
9651,
1819,
353,
14319,
29898,
1311,
29889,
8299,
29889,
1761,
29898,
29884,
15972,
5477,
2149,
29897,
13,
9651,
363,
321,
29892,
921,
297,
1819,
29901,
13,
18884,
282,
29892,
3855,
29892,
269,
353,
921,
13,
18884,
1583,
3032,
3198,
29918,
23905,
29898,
29872,
29897,
13,
18884,
1583,
3032,
3198,
29918,
1767,
29898,
29872,
29892,
921,
9990,
29922,
29939,
29892,
921,
4836,
29922,
29886,
29892,
921,
845,
538,
29922,
29879,
29897,
13,
13,
1678,
822,
1243,
29918,
5504,
29898,
1311,
1125,
13,
4706,
411,
1371,
414,
29889,
845,
538,
29918,
8269,
29898,
1311,
29889,
8299,
29892,
1583,
29889,
4836,
29892,
13,
462,
462,
1583,
29889,
9990,
29892,
318,
29915,
29874,
1495,
408,
2149,
29901,
13,
9651,
282,
29892,
3855,
29892,
269,
353,
2149,
13,
9651,
1583,
29889,
8299,
29889,
5504,
29898,
29886,
29892,
3855,
29892,
528,
538,
29922,
29884,
29915,
29890,
1495,
13,
9651,
6251,
353,
1583,
29889,
8299,
29889,
657,
29898,
29886,
29892,
3855,
29897,
13,
9651,
1583,
3032,
3198,
29918,
1767,
29898,
8269,
29892,
921,
9990,
29922,
29939,
29892,
921,
4836,
29922,
29886,
29892,
921,
845,
538,
29922,
29884,
29915,
29890,
1495,
13,
13,
1678,
822,
1243,
29918,
5504,
29918,
336,
4637,
29918,
8256,
29918,
8269,
29918,
13221,
29918,
1333,
29918,
28997,
29898,
1311,
1125,
13,
4706,
1583,
29889,
9294,
29934,
1759,
267,
29898,
12523,
29889,
10620,
3664,
9689,
287,
29892,
13,
462,
3986,
1583,
29889,
8299,
29889,
5504,
29892,
13,
462,
3986,
525,
1333,
742,
525,
1333,
742,
525,
29874,
1495,
13,
13,
1678,
822,
1243,
29918,
657,
29898,
1311,
1125,
13,
4706,
411,
1371,
414,
29889,
845,
538,
29918,
8269,
29898,
1311,
29889,
8299,
29892,
13,
462,
462,
1583,
29889,
4836,
29892,
13,
462,
462,
1583,
29889,
9990,
29892,
318,
29915,
29874,
1495,
408,
2149,
29901,
13,
9651,
282,
29892,
3855,
29892,
269,
353,
2149,
13,
9651,
321,
353,
1583,
29889,
8299,
29889,
657,
29898,
29886,
29892,
3855,
29897,
13,
9651,
1583,
3032,
3198,
29918,
1767,
29898,
29872,
29892,
921,
9990,
29922,
29939,
29892,
921,
4836,
29922,
29886,
29892,
921,
845,
538,
29922,
29879,
29897,
13,
13,
1678,
822,
1243,
29918,
657,
29918,
336,
4637,
29918,
361,
29918,
13221,
29918,
1333,
29918,
28997,
29898,
1311,
1125,
13,
4706,
411,
1371,
414,
29889,
845,
538,
29918,
8269,
29898,
1311,
29889,
8299,
29892,
13,
462,
462,
1583,
29889,
4836,
29892,
13,
462,
462,
1583,
29889,
9990,
29892,
318,
29915,
29874,
1495,
408,
2149,
29901,
13,
9651,
282,
29892,
3855,
29892,
903,
353,
2149,
13,
9651,
1583,
29889,
9294,
29934,
1759,
267,
29898,
12523,
29889,
10620,
3664,
9689,
287,
29892,
13,
462,
795,
1583,
29889,
8299,
29889,
657,
29892,
13,
462,
795,
282,
29892,
525,
5464,
29918,
735,
15423,
1495,
13,
9651,
1583,
29889,
9294,
29934,
1759,
267,
29898,
12523,
29889,
10620,
3664,
9689,
287,
29892,
13,
462,
795,
1583,
29889,
8299,
29889,
657,
29892,
13,
462,
795,
525,
5464,
29918,
735,
15423,
742,
3855,
29897,
13,
9651,
1583,
29889,
9294,
29934,
1759,
267,
29898,
12523,
29889,
10620,
3664,
9689,
287,
29892,
13,
462,
795,
1583,
29889,
8299,
29889,
657,
29892,
13,
462,
795,
525,
5464,
29918,
735,
15423,
742,
525,
5464,
29918,
735,
15423,
1495,
13,
13,
1678,
822,
1243,
29918,
9933,
29898,
1311,
1125,
13,
4706,
411,
1371,
414,
29889,
845,
538,
29918,
8269,
29898,
1311,
29889,
8299,
29892,
13,
462,
462,
1583,
29889,
4836,
29892,
13,
462,
462,
1583,
29889,
9990,
29892,
318,
29915,
29874,
1495,
408,
2149,
29901,
13,
9651,
282,
29892,
3855,
29892,
903,
353,
2149,
13,
9651,
1583,
29889,
9294,
5574,
29898,
1311,
29889,
8299,
29889,
9933,
29898,
29886,
29892,
3855,
876,
13,
4706,
1583,
29889,
9294,
8824,
29898,
1311,
29889,
8299,
29889,
9933,
877,
29876,
1114,
742,
525,
1333,
29918,
4150,
8785,
13,
13,
13,
1753,
903,
7851,
29918,
7241,
486,
1973,
29898,
8299,
29892,
9521,
29918,
978,
29892,
2060,
29922,
8516,
29892,
13,
462,
268,
3132,
29918,
25118,
29922,
8516,
29892,
954,
29922,
29946,
29892,
260,
15206,
29922,
29896,
29906,
29900,
1125,
13,
13,
1678,
822,
7191,
7295,
13,
4706,
363,
302,
297,
4832,
29889,
13529,
267,
29889,
29916,
3881,
29898,
1949,
1125,
13,
9651,
7709,
426,
13,
18884,
525,
698,
29880,
2396,
260,
15206,
29892,
13,
18884,
525,
2587,
2396,
426,
13,
462,
1678,
525,
3696,
2396,
525,
2624,
1353,
426,
29900,
29913,
4286,
4830,
29898,
29876,
29897,
13,
18884,
9156,
13,
13,
1678,
4701,
29889,
2490,
29898,
9990,
29918,
978,
29892,
7191,
3285,
13,
462,
1678,
2060,
29922,
4836,
29892,
3132,
29918,
25118,
29922,
4645,
29918,
25118,
29897,
13,
2
] |
examples/pervasive/modules/wip/ll_controls.py | EricLina/attn2d | 490 | 87177 | import sys
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
def progressive_max(x):
T = x.size(1)
x = F.pad(x, (T-1, 0), 'constant', -1)
x = F.max_pool1d(x.unsqueeze(1).float(), # shape into B, C, T
T, # kernel size
1, # stride
0, # padding
1, # dilation
False, # ceil_mode
False, # return indices
)
return x.squeeze(1) # B, Tt
def logsumexp(a, b):
m = torch.max(a, b)
return torch.log(torch.exp(a - m) + torch.exp(b - m))
def Linear(in_features, out_features, bias=True):
m = nn.Linear(in_features, out_features, bias)
nn.init.xavier_uniform_(m.weight)
if bias:
nn.init.constant_(m.bias, 0.)
return m
class LLControls(nn.Module):
"""
LL based controller
"""
def __init__(self, args, controller_dim):
nn.Module.__init__(self)
self.gate = nn.Linear(controller_dim, 1, bias=True)
nn.init.normal_(self.gate.weight, 0, 1/controller_dim)
nn.init.constant_(self.gate.bias, 0)
self.penalty = args.oracle_penalty
self.write_right = args.write_right
def get_positions_proba(self, rw_logits):
"""
Inputs:
rw_logits [log(rho), log(1-rho)] : (Tt, B, Ts, 2)
Returns the probabilities of being at position (t,j) (Tt, B, Ts)
"""
Tt, B, Ts, _ = rw_logits.size()
Mr1 = rw_logits[0:1,:,:-1,0].exp()
Mc1 = rw_logits[:,:,0:1,1].exp()
M = rw_logits[1:,:,:-1,0].exp() + rw_logits[:-1,:,1:,1].exp()
M = torch.cat((Mr1, M), dim=0)
M = torch.cat((Mc1, M), dim=-1)
return M
def predict_read_write(self, x):
""" Returns log(rho), log(1-rho) in B, Tt, Ts, 2 """
x = self.gate(x)
s = F.logsigmoid(x)
return torch.cat((s, s-x), dim=-1).float()
def forward(self, observations, scores):
"""
Inputs:
observations : Input for the controller: B, Tt, Ts, C
Scores : log p(y_t | x<j) : B, Tt, Ts
"""
controls = self.predict_read_write(observations) # B,Tt,Ts,2
B, Tt, Ts = scores.size()
with torch.no_grad():
if self.penalty:
# Penalize large contexts:
indices = torch.arange(
Ts,
dtype=scores.dtype,
device=scores.device
) / Ts
scores = scores - self.penalty * indices.unsqueeze(0).unsqueeze(0)
best_context = scores.max(-1)[1] # B, Tt
best_context = progressive_max(best_context).type_as(best_context)
AP = best_context.float().mean(dim=1) / Ts
print('AP:', ' '.join(map(lambda x: '{:.2f}'.format(x), AP.tolist())))
gamma = torch.zeros_like(scores).scatter_(-1, best_context.unsqueeze(-1), 1.0) # B, Tt, Ts
if self.write_right:
gamma = gamma.cumsum(dim=-1)
# Write beyond the ideal context
if self.write_right:
write = gamma[:, 1:] # B, Tt-1, Ts
else:
write = gamma[:, 1:].cumsum(dim=-1) # B, Tt-1, Ts
read = 1 - write
return controls[:, :-1], gamma, read, write
| [
1,
1053,
10876,
13,
5215,
5844,
13,
5215,
12655,
408,
7442,
13,
5215,
4842,
305,
13,
5215,
4842,
305,
29889,
15755,
408,
302,
29876,
13,
5215,
4842,
305,
29889,
15755,
29889,
2220,
284,
408,
383,
13,
3166,
6534,
11762,
1053,
3667,
29879,
13,
13,
13,
1753,
6728,
573,
29918,
3317,
29898,
29916,
1125,
13,
1678,
323,
353,
921,
29889,
2311,
29898,
29896,
29897,
13,
1678,
921,
353,
383,
29889,
8305,
29898,
29916,
29892,
313,
29911,
29899,
29896,
29892,
29871,
29900,
511,
525,
23362,
742,
448,
29896,
29897,
13,
1678,
921,
353,
383,
29889,
3317,
29918,
10109,
29896,
29881,
29898,
29916,
29889,
6948,
802,
29872,
911,
29898,
29896,
467,
7411,
3285,
29871,
396,
8267,
964,
350,
29892,
315,
29892,
323,
13,
462,
1678,
323,
29892,
396,
8466,
2159,
13,
462,
268,
29896,
29892,
396,
380,
2426,
13,
462,
268,
29900,
29892,
396,
7164,
13,
462,
268,
29896,
29892,
396,
270,
8634,
13,
462,
1678,
7700,
29892,
396,
2257,
309,
29918,
8513,
13,
462,
1678,
7700,
29892,
396,
736,
16285,
13,
462,
1678,
1723,
13,
1678,
736,
921,
29889,
29879,
802,
29872,
911,
29898,
29896,
29897,
29871,
396,
350,
29892,
323,
29873,
13,
13,
1753,
1480,
2083,
4548,
29898,
29874,
29892,
289,
1125,
13,
1678,
286,
353,
4842,
305,
29889,
3317,
29898,
29874,
29892,
289,
29897,
13,
1678,
736,
4842,
305,
29889,
1188,
29898,
7345,
305,
29889,
4548,
29898,
29874,
448,
286,
29897,
718,
4842,
305,
29889,
4548,
29898,
29890,
448,
286,
876,
29871,
13,
13,
13,
1753,
22985,
29898,
262,
29918,
22100,
29892,
714,
29918,
22100,
29892,
24003,
29922,
5574,
1125,
13,
1678,
286,
353,
302,
29876,
29889,
12697,
29898,
262,
29918,
22100,
29892,
714,
29918,
22100,
29892,
24003,
29897,
13,
1678,
302,
29876,
29889,
2344,
29889,
29916,
18852,
29918,
29590,
23538,
29885,
29889,
7915,
29897,
13,
1678,
565,
24003,
29901,
13,
4706,
302,
29876,
29889,
2344,
29889,
23362,
23538,
29885,
29889,
29890,
3173,
29892,
29871,
29900,
1846,
13,
1678,
736,
286,
13,
13,
13,
1990,
27624,
17825,
29898,
15755,
29889,
7355,
1125,
13,
1678,
9995,
13,
1678,
27624,
2729,
4701,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
6389,
29892,
4701,
29918,
6229,
1125,
13,
13,
4706,
302,
29876,
29889,
7355,
17255,
2344,
12035,
1311,
29897,
13,
4706,
1583,
29889,
17062,
353,
302,
29876,
29889,
12697,
29898,
8299,
29918,
6229,
29892,
29871,
29896,
29892,
24003,
29922,
5574,
29897,
13,
4706,
302,
29876,
29889,
2344,
29889,
8945,
23538,
1311,
29889,
17062,
29889,
7915,
29892,
29871,
29900,
29892,
29871,
29896,
29914,
8299,
29918,
6229,
29897,
13,
4706,
302,
29876,
29889,
2344,
29889,
23362,
23538,
1311,
29889,
17062,
29889,
29890,
3173,
29892,
29871,
29900,
29897,
13,
4706,
1583,
29889,
2238,
18745,
353,
6389,
29889,
11347,
29918,
2238,
18745,
13,
4706,
1583,
29889,
3539,
29918,
1266,
353,
6389,
29889,
3539,
29918,
1266,
13,
308,
13,
1678,
822,
679,
29918,
1066,
2187,
29918,
771,
2291,
29898,
1311,
29892,
364,
29893,
29918,
1188,
1169,
1125,
13,
4706,
9995,
13,
4706,
10567,
29879,
29901,
13,
9651,
364,
29893,
29918,
1188,
1169,
518,
1188,
29898,
4650,
511,
1480,
29898,
29896,
29899,
4650,
4638,
29871,
584,
313,
29911,
29873,
29892,
350,
29892,
19089,
29892,
29871,
29906,
29897,
13,
4706,
16969,
278,
2070,
11614,
310,
1641,
472,
2602,
313,
29873,
29892,
29926,
29897,
313,
29911,
29873,
29892,
350,
29892,
19089,
29897,
13,
4706,
9995,
13,
4706,
323,
29873,
29892,
350,
29892,
19089,
29892,
903,
353,
364,
29893,
29918,
1188,
1169,
29889,
2311,
580,
13,
4706,
3237,
29896,
353,
364,
29893,
29918,
1188,
1169,
29961,
29900,
29901,
29896,
29892,
29901,
29892,
13018,
29896,
29892,
29900,
1822,
4548,
580,
13,
4706,
4052,
29896,
353,
364,
29893,
29918,
1188,
1169,
7503,
29892,
29901,
29892,
29900,
29901,
29896,
29892,
29896,
1822,
4548,
580,
13,
4706,
341,
353,
364,
29893,
29918,
1188,
1169,
29961,
29896,
29901,
29892,
29901,
29892,
13018,
29896,
29892,
29900,
1822,
4548,
580,
718,
364,
29893,
29918,
1188,
1169,
7503,
29899,
29896,
29892,
29901,
29892,
29896,
29901,
29892,
29896,
1822,
4548,
580,
13,
4706,
341,
353,
4842,
305,
29889,
4117,
3552,
20335,
29896,
29892,
341,
511,
3964,
29922,
29900,
29897,
13,
4706,
341,
353,
4842,
305,
29889,
4117,
3552,
27297,
29896,
29892,
341,
511,
3964,
10457,
29896,
29897,
13,
4706,
736,
341,
13,
268,
13,
1678,
822,
8500,
29918,
949,
29918,
3539,
29898,
1311,
29892,
921,
1125,
13,
4706,
9995,
16969,
1480,
29898,
4650,
511,
1480,
29898,
29896,
29899,
4650,
29897,
297,
350,
29892,
323,
29873,
29892,
19089,
29892,
29871,
29906,
9995,
13,
4706,
921,
353,
1583,
29889,
17062,
29898,
29916,
29897,
13,
4706,
269,
353,
383,
29889,
1188,
18816,
29885,
3398,
29898,
29916,
29897,
13,
4706,
736,
4842,
305,
29889,
4117,
3552,
29879,
29892,
269,
29899,
29916,
511,
3964,
10457,
29896,
467,
7411,
580,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
13917,
29892,
19435,
1125,
13,
4706,
9995,
13,
4706,
10567,
29879,
29901,
29871,
13,
9651,
13917,
584,
10567,
363,
278,
4701,
29901,
350,
29892,
323,
29873,
29892,
19089,
29892,
315,
13,
9651,
2522,
2361,
584,
1480,
282,
29898,
29891,
29918,
29873,
891,
921,
29966,
29926,
29897,
29871,
584,
350,
29892,
323,
29873,
29892,
19089,
13,
4706,
9995,
13,
4706,
11761,
353,
1583,
29889,
27711,
29918,
949,
29918,
3539,
29898,
26739,
800,
29897,
29871,
396,
350,
29892,
29911,
29873,
29892,
29911,
29879,
29892,
29906,
13,
4706,
350,
29892,
323,
29873,
29892,
19089,
353,
19435,
29889,
2311,
580,
13,
4706,
411,
4842,
305,
29889,
1217,
29918,
5105,
7295,
13,
9651,
565,
1583,
29889,
2238,
18745,
29901,
13,
18884,
396,
7363,
284,
675,
2919,
3030,
29879,
29901,
13,
18884,
16285,
353,
4842,
305,
29889,
279,
927,
29898,
13,
462,
1678,
19089,
29892,
13,
462,
1678,
26688,
29922,
1557,
2361,
29889,
29881,
1853,
29892,
13,
462,
1678,
4742,
29922,
1557,
2361,
29889,
10141,
13,
18884,
1723,
847,
19089,
13,
18884,
19435,
353,
19435,
448,
1583,
29889,
2238,
18745,
334,
16285,
29889,
6948,
802,
29872,
911,
29898,
29900,
467,
6948,
802,
29872,
911,
29898,
29900,
29897,
13,
9651,
1900,
29918,
4703,
353,
19435,
29889,
3317,
6278,
29896,
9601,
29896,
29962,
29871,
396,
350,
29892,
323,
29873,
13,
9651,
1900,
29918,
4703,
353,
6728,
573,
29918,
3317,
29898,
13318,
29918,
4703,
467,
1853,
29918,
294,
29898,
13318,
29918,
4703,
29897,
13,
9651,
12279,
353,
1900,
29918,
4703,
29889,
7411,
2141,
12676,
29898,
6229,
29922,
29896,
29897,
847,
19089,
13,
9651,
1596,
877,
3301,
29901,
742,
525,
15300,
7122,
29898,
1958,
29898,
2892,
921,
29901,
22372,
29901,
29889,
29906,
29888,
29913,
4286,
4830,
29898,
29916,
511,
12279,
29889,
25027,
391,
580,
4961,
13,
9651,
330,
2735,
353,
4842,
305,
29889,
3298,
359,
29918,
4561,
29898,
1557,
2361,
467,
1557,
2620,
29918,
6278,
29896,
29892,
1900,
29918,
4703,
29889,
6948,
802,
29872,
911,
6278,
29896,
511,
29871,
29896,
29889,
29900,
29897,
29871,
396,
350,
29892,
323,
29873,
29892,
19089,
13,
9651,
565,
1583,
29889,
3539,
29918,
1266,
29901,
13,
18884,
330,
2735,
353,
330,
2735,
29889,
29883,
398,
2083,
29898,
6229,
10457,
29896,
29897,
13,
13,
4706,
396,
14350,
8724,
278,
10839,
3030,
13,
4706,
565,
1583,
29889,
3539,
29918,
1266,
29901,
13,
9651,
2436,
353,
330,
2735,
7503,
29892,
29871,
29896,
17531,
29871,
396,
350,
29892,
323,
29873,
29899,
29896,
29892,
19089,
13,
4706,
1683,
29901,
13,
9651,
2436,
353,
330,
2735,
7503,
29892,
29871,
29896,
29901,
1822,
29883,
398,
2083,
29898,
6229,
10457,
29896,
29897,
29871,
396,
350,
29892,
323,
29873,
29899,
29896,
29892,
19089,
13,
4706,
1303,
353,
29871,
29896,
448,
2436,
13,
4706,
736,
11761,
7503,
29892,
8956,
29896,
1402,
330,
2735,
29892,
1303,
29892,
2436,
13,
2
] |
gpvdm_data/shape/Gaus/example.py | roderickmackenzie/gpvdm | 12 | 45840 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
from gpvdm_api import gpvdm_api
def run():
a=gpvdm_api(verbose=True)
a.set_save_dir(device_data)
a.edit("light.inp","#light_model","qe")
a.edit("jv0.inp","#Vstop","0.8")
a.run() | [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
29941,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
5215,
2897,
13,
5215,
10876,
13,
13,
3166,
330,
29886,
29894,
18933,
29918,
2754,
1053,
330,
29886,
29894,
18933,
29918,
2754,
13,
13,
1753,
1065,
7295,
13,
12,
29874,
29922,
29887,
29886,
29894,
18933,
29918,
2754,
29898,
369,
15828,
29922,
5574,
29897,
13,
12,
29874,
29889,
842,
29918,
7620,
29918,
3972,
29898,
10141,
29918,
1272,
29897,
13,
12,
29874,
29889,
5628,
703,
4366,
29889,
262,
29886,
3284,
29937,
4366,
29918,
4299,
3284,
29939,
29872,
1159,
13,
12,
29874,
29889,
5628,
703,
29926,
29894,
29900,
29889,
262,
29886,
3284,
29937,
29963,
9847,
3284,
29900,
29889,
29947,
1159,
13,
12,
29874,
29889,
3389,
580,
2
] |
src/orion/algo/robo/__init__.py | lebrice/orion.algo.robo | 0 | 15272 | # -*- coding: utf-8 -*-
"""
Wrapper for RoBO
"""
__descr__ = "TODO"
__license__ = "BSD 3-Clause"
__author__ = u"Epistímio"
__author_short__ = u"Epistímio"
__author_email__ = "<EMAIL>"
__copyright__ = u"2021, Epistímio"
__url__ = "https://github.com/Epistimio/orion.algo.robo"
from ._version import get_versions
__version__ = get_versions()["version"]
del get_versions
| [
1,
396,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
15945,
29908,
13,
15646,
363,
1528,
8456,
13,
15945,
29908,
13,
13,
1649,
2783,
7283,
1649,
353,
376,
4986,
3970,
29908,
13,
1649,
506,
1947,
1649,
353,
376,
29933,
7230,
29871,
29941,
29899,
20216,
1509,
29908,
13,
1649,
8921,
1649,
353,
318,
29908,
29923,
29886,
391,
5487,
601,
29908,
13,
1649,
8921,
29918,
12759,
1649,
353,
318,
29908,
29923,
29886,
391,
5487,
601,
29908,
13,
1649,
8921,
29918,
5269,
1649,
353,
9872,
26862,
6227,
11903,
13,
1649,
8552,
1266,
1649,
353,
318,
29908,
29906,
29900,
29906,
29896,
29892,
14055,
391,
5487,
601,
29908,
13,
1649,
2271,
1649,
353,
376,
991,
597,
3292,
29889,
510,
29914,
29923,
29886,
391,
326,
601,
29914,
272,
291,
29889,
284,
1484,
29889,
307,
833,
29908,
13,
13,
3166,
869,
29918,
3259,
1053,
679,
29918,
26100,
13,
13,
1649,
3259,
1649,
353,
679,
29918,
26100,
580,
3366,
3259,
3108,
13,
6144,
679,
29918,
26100,
13,
2
] |
rgd/geodata/migrations/0004_auto_20210302_2017.py | Erotemic/ResonantGeoData | 0 | 98492 | # Generated by Django 3.2a1 on 2021-03-02 20:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('geodata', '0003_auto_20210301_1639'),
]
operations = [
migrations.RemoveField(
model_name='imageentry',
name='failure_reason',
),
migrations.RemoveField(
model_name='imageentry',
name='metadata',
),
migrations.RemoveField(
model_name='imageentry',
name='status',
),
migrations.DeleteModel(
name='Thumbnail',
),
]
| [
1,
396,
3251,
630,
491,
15337,
29871,
29941,
29889,
29906,
29874,
29896,
373,
29871,
29906,
29900,
29906,
29896,
29899,
29900,
29941,
29899,
29900,
29906,
29871,
29906,
29900,
29901,
29896,
29955,
13,
13,
3166,
9557,
29889,
2585,
1053,
9725,
800,
13,
13,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
13,
13,
1678,
9962,
353,
518,
13,
4706,
6702,
479,
397,
532,
742,
525,
29900,
29900,
29900,
29941,
29918,
6921,
29918,
29906,
29900,
29906,
29896,
29900,
29941,
29900,
29896,
29918,
29896,
29953,
29941,
29929,
5477,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
15941,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
3027,
8269,
742,
13,
9651,
1024,
2433,
14057,
545,
29918,
23147,
742,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
15941,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
3027,
8269,
742,
13,
9651,
1024,
2433,
19635,
742,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
15941,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
3027,
8269,
742,
13,
9651,
1024,
2433,
4882,
742,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
12498,
3195,
29898,
13,
9651,
1024,
2433,
1349,
21145,
742,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
examples/gto/13-symmetry.py | robert-anderson/pyscf | 2 | 120520 | <gh_stars>1-10
#!/usr/bin/env python
#
# Author: <NAME> <<EMAIL>>
#
from pyscf import gto
'''
Specify symmetry.
Mole.symmetry can be True/False to turn on/off the symmetry (default is off),
or a string to specify the symmetry of molecule.
If symmetry is bool type, the atom coordinates might be changed. The molecule
will be rotated to a propper orientation in which the highest rotation axis
is parallel to Z-axis. Also, symmetry_subgroup keyword can be used to
generate a subgroup of the dectected symmetry. symmetry_subgroup keyword has
no effect when symmetry symbol is explicitly given.
NOTE: to assign Mole.symmetry with a given symbol, the molecule must be put
in a proper orientation. The program will check the given symmetry to ensure
that the molecule has the required symmetry. If the detected symmetry does
not match to the assigend symmetry, you will see a warning message on the
screen.
Symmetry adapted basis are stored in Mole object.
'''
mol = gto.M(
atom = 'C 0 .2 0; O 0 0 1.1',
symmetry = True,
)
print('Symmetry %-4s, using subgroup %s. The molecule geometry is changed' %
(mol.topgroup, mol.groupname))
for x in mol._atom:
print(x)
print('--\n')
mol = gto.M(
atom = 'C 0 .2 0; O 0 0 1.1',
symmetry = True,
symmetry_subgroup = 'C2v',
)
print('Symmetry %-4s, using subgroup %s. The molecule geometry is changed' %
(mol.topgroup, mol.groupname))
for x in mol._atom:
print(x)
print('--\n')
try:
mol = gto.M(
atom = 'C 0 .2 0; O 0 0 1.1',
symmetry = 'C2v',
)
except RuntimeWarning as e:
print('Unable to identify the symmetry with the input geometry. Error msg:')
print(e)
print('--\n')
mol = gto.M(
atom = 'C 0 0 0; O 0 0 1.5',
symmetry = 'C2v',
)
print('Symmetry %-4s, using subgroup %s.' % (mol.topgroup, mol.groupname))
print('If "symmetry=string" was specified, the string is taken as the '
'group name and the geometry is kept')
for x in mol._atom:
print(x)
for k, ir in enumerate(mol.irrep_name):
print('Irrep name %s (ID %d), symm-adapted-basis shape %s' %
(ir, mol.irrep_id[k], mol.symm_orb[k].shape))
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
13,
29937,
13,
29937,
13361,
29901,
529,
5813,
29958,
3532,
26862,
6227,
6778,
13,
29937,
13,
13,
3166,
282,
952,
6854,
1053,
330,
517,
13,
13,
12008,
13,
10299,
1598,
18446,
29889,
13,
13,
29924,
1772,
29889,
11967,
2527,
719,
508,
367,
5852,
29914,
8824,
304,
2507,
373,
29914,
2696,
278,
18446,
313,
4381,
338,
1283,
511,
13,
272,
263,
1347,
304,
6084,
278,
18446,
310,
13206,
29883,
1297,
29889,
13,
13,
3644,
18446,
338,
6120,
1134,
29892,
278,
12301,
10350,
1795,
367,
3939,
29889,
29871,
450,
13206,
29883,
1297,
13,
14043,
367,
5731,
630,
304,
263,
410,
2496,
19843,
297,
607,
278,
9939,
13733,
9685,
13,
275,
8943,
304,
796,
29899,
8990,
29889,
29871,
3115,
29892,
18446,
29918,
1491,
2972,
13553,
508,
367,
1304,
304,
13,
17158,
263,
24410,
310,
278,
316,
312,
26458,
18446,
29889,
29871,
18446,
29918,
1491,
2972,
13553,
756,
13,
1217,
2779,
746,
18446,
5829,
338,
9479,
2183,
29889,
13,
13,
12256,
29923,
29901,
304,
3566,
341,
1772,
29889,
11967,
2527,
719,
411,
263,
2183,
5829,
29892,
29871,
278,
13206,
29883,
1297,
1818,
367,
1925,
13,
262,
263,
1571,
19843,
29889,
29871,
450,
1824,
674,
1423,
278,
2183,
18446,
304,
9801,
13,
5747,
278,
13206,
29883,
1297,
756,
278,
3734,
18446,
29889,
29871,
960,
278,
17809,
18446,
947,
13,
1333,
1993,
304,
278,
1223,
335,
355,
18446,
29892,
366,
674,
1074,
263,
9177,
2643,
373,
278,
13,
10525,
29889,
13,
13,
25548,
2527,
719,
23430,
8405,
526,
6087,
297,
341,
1772,
1203,
29889,
13,
12008,
13,
13,
29885,
324,
353,
330,
517,
29889,
29924,
29898,
13,
1678,
12301,
353,
525,
29907,
29871,
29900,
869,
29906,
29871,
29900,
29936,
438,
29871,
29900,
29871,
29900,
29871,
29896,
29889,
29896,
742,
13,
1678,
18446,
353,
5852,
29892,
13,
29897,
13,
2158,
877,
25548,
2527,
719,
1273,
29899,
29946,
29879,
29892,
773,
24410,
1273,
29879,
29889,
29871,
450,
13206,
29883,
1297,
16303,
338,
3939,
29915,
1273,
13,
418,
313,
29885,
324,
29889,
3332,
2972,
29892,
6062,
29889,
2972,
978,
876,
13,
1454,
921,
297,
6062,
3032,
8678,
29901,
13,
1678,
1596,
29898,
29916,
29897,
13,
2158,
877,
489,
29905,
29876,
1495,
13,
13,
29885,
324,
353,
330,
517,
29889,
29924,
29898,
13,
1678,
12301,
353,
525,
29907,
29871,
29900,
869,
29906,
29871,
29900,
29936,
438,
29871,
29900,
29871,
29900,
29871,
29896,
29889,
29896,
742,
13,
1678,
18446,
353,
5852,
29892,
13,
1678,
18446,
29918,
1491,
2972,
353,
525,
29907,
29906,
29894,
742,
13,
29897,
13,
2158,
877,
25548,
2527,
719,
1273,
29899,
29946,
29879,
29892,
773,
24410,
1273,
29879,
29889,
29871,
450,
13206,
29883,
1297,
16303,
338,
3939,
29915,
1273,
13,
418,
313,
29885,
324,
29889,
3332,
2972,
29892,
6062,
29889,
2972,
978,
876,
13,
1454,
921,
297,
6062,
3032,
8678,
29901,
13,
1678,
1596,
29898,
29916,
29897,
13,
2158,
877,
489,
29905,
29876,
1495,
13,
13,
2202,
29901,
13,
1678,
6062,
353,
330,
517,
29889,
29924,
29898,
13,
4706,
12301,
353,
525,
29907,
29871,
29900,
869,
29906,
29871,
29900,
29936,
438,
29871,
29900,
29871,
29900,
29871,
29896,
29889,
29896,
742,
13,
4706,
18446,
353,
525,
29907,
29906,
29894,
742,
13,
1678,
1723,
13,
19499,
24875,
22709,
408,
321,
29901,
13,
1678,
1596,
877,
2525,
519,
304,
12439,
278,
18446,
411,
278,
1881,
16303,
29889,
29871,
4829,
10191,
29901,
1495,
13,
1678,
1596,
29898,
29872,
29897,
13,
2158,
877,
489,
29905,
29876,
1495,
13,
13,
29885,
324,
353,
330,
517,
29889,
29924,
29898,
13,
1678,
12301,
353,
525,
29907,
29871,
29900,
29871,
29900,
29871,
29900,
29936,
438,
29871,
29900,
29871,
29900,
29871,
29896,
29889,
29945,
742,
13,
1678,
18446,
353,
525,
29907,
29906,
29894,
742,
13,
29897,
13,
2158,
877,
25548,
2527,
719,
1273,
29899,
29946,
29879,
29892,
773,
24410,
1273,
29879,
6169,
1273,
313,
29885,
324,
29889,
3332,
2972,
29892,
6062,
29889,
2972,
978,
876,
13,
2158,
877,
3644,
376,
11967,
2527,
719,
29922,
1807,
29908,
471,
6790,
29892,
278,
1347,
338,
4586,
408,
278,
525,
13,
418,
525,
2972,
1024,
322,
278,
16303,
338,
8126,
1495,
13,
1454,
921,
297,
6062,
3032,
8678,
29901,
13,
1678,
1596,
29898,
29916,
29897,
13,
13,
1454,
413,
29892,
3805,
297,
26985,
29898,
29885,
324,
29889,
381,
3445,
29918,
978,
1125,
13,
1678,
1596,
877,
29902,
29878,
3445,
1024,
1273,
29879,
29871,
313,
1367,
1273,
29881,
511,
5016,
29885,
29899,
1114,
415,
287,
29899,
6500,
275,
8267,
1273,
29879,
29915,
1273,
13,
3986,
313,
381,
29892,
6062,
29889,
381,
3445,
29918,
333,
29961,
29895,
1402,
6062,
29889,
11967,
29885,
29918,
11831,
29961,
29895,
1822,
12181,
876,
13,
2
] |
example_project/myshop/urls.py | bluedisk/django-iamport | 6 | 122996 | <reponame>bluedisk/django-iamport
# -*- coding: utf-8 -*-
from django.conf.urls import url
from django.urls import path
from . import views
app_name = "myshop"
urlpatterns = [
path('', views.home, name='home'),
path('retry_order/<int:order_id>', views.retry_order, name='retry_order'),
]
| [
1,
529,
276,
1112,
420,
29958,
2204,
6742,
3873,
29914,
14095,
29899,
2829,
637,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
3166,
9557,
29889,
5527,
29889,
26045,
1053,
3142,
13,
3166,
9557,
29889,
26045,
1053,
2224,
13,
13,
3166,
869,
1053,
8386,
13,
13,
932,
29918,
978,
353,
376,
1357,
19032,
29908,
13,
13,
2271,
11037,
29879,
353,
518,
13,
13,
1678,
2224,
877,
742,
8386,
29889,
5184,
29892,
1024,
2433,
5184,
5477,
13,
1678,
2224,
877,
276,
2202,
29918,
2098,
29914,
29966,
524,
29901,
2098,
29918,
333,
29958,
742,
8386,
29889,
276,
2202,
29918,
2098,
29892,
1024,
2433,
276,
2202,
29918,
2098,
5477,
13,
13,
29962,
13,
2
] |
defs/__init__.py | scionrep/scioncc_new | 2 | 120067 | # Declare as Python package, such that setuptools can include the data files
# (YML, SQL, etc) with the binary egg distribution. | [
1,
396,
3826,
8663,
408,
5132,
3577,
29892,
1316,
393,
731,
21245,
8789,
508,
3160,
278,
848,
2066,
13,
29937,
313,
29979,
1988,
29892,
3758,
29892,
2992,
29897,
411,
278,
7581,
19710,
4978,
29889,
2
] |
maxsmi/utils.py | t-kimber/maxsmi | 1 | 149721 | """
utils.py
Python utils functionalities.
Handles the primary functions
"""
import argparse
from maxsmi.augmentation_strategies import (
no_augmentation,
augmentation_with_duplication,
augmentation_without_duplication,
augmentation_with_reduced_duplication,
augmentation_maximum_estimation,
)
def string_to_bool(string):
"""
Converts a string to a bool.
Parameters
----------
string : str
String.
Returns
-------
bool :
True or False depending on the string.
"""
if isinstance(string, bool):
return string
if string in ("yes", "True", "true", "1"):
return True
elif string in ("no", "False", "false", "0"):
return False
else:
raise argparse.ArgumentTypeError("Choose between 'yes' or 'no'.")
def augmentation_strategy(string):
"""
Converts a string to an augmentation strategy.
Parameters
----------
string : str
String describing the augmentation strategy to be used.
Returns
-------
function :
The augmentation strategy.
"""
if string == "no_augmentation":
return no_augmentation
elif string == "augmentation_with_duplication":
return augmentation_with_duplication
if string == "augmentation_without_duplication":
return augmentation_without_duplication
elif string == "augmentation_with_reduced_duplication":
return augmentation_with_reduced_duplication
elif string == "augmentation_maximum_estimation":
return augmentation_maximum_estimation
else:
raise argparse.ArgumentTypeError(
"Choose between 'no_augmentation',"
"'augmentation_with_duplication', 'augmentation_without_duplication"
"'augmentation_with_reduced_duplication' and 'augmentation_maximum_estimation'."
)
| [
1,
9995,
13,
13239,
29889,
2272,
13,
11980,
3667,
29879,
13303,
1907,
29889,
13,
13,
3481,
793,
278,
7601,
3168,
13,
15945,
29908,
13,
13,
5215,
1852,
5510,
13,
13,
3166,
4236,
29879,
2460,
29889,
2987,
358,
362,
29918,
710,
1845,
583,
1053,
313,
13,
1678,
694,
29918,
2987,
358,
362,
29892,
13,
1678,
18765,
362,
29918,
2541,
29918,
20908,
1414,
29892,
13,
1678,
18765,
362,
29918,
14037,
29918,
20908,
1414,
29892,
13,
1678,
18765,
362,
29918,
2541,
29918,
9313,
1133,
29918,
20908,
1414,
29892,
13,
1678,
18765,
362,
29918,
27525,
398,
29918,
342,
7715,
29892,
13,
29897,
13,
13,
13,
1753,
1347,
29918,
517,
29918,
11227,
29898,
1807,
1125,
13,
1678,
9995,
13,
1678,
1281,
369,
1372,
263,
1347,
304,
263,
6120,
29889,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
1347,
584,
851,
13,
4706,
1714,
29889,
13,
13,
1678,
16969,
13,
1678,
448,
22158,
13,
1678,
6120,
584,
13,
4706,
5852,
470,
7700,
8679,
373,
278,
1347,
29889,
13,
1678,
9995,
13,
1678,
565,
338,
8758,
29898,
1807,
29892,
6120,
1125,
13,
4706,
736,
1347,
13,
1678,
565,
1347,
297,
4852,
3582,
613,
376,
5574,
613,
376,
3009,
613,
376,
29896,
29908,
1125,
13,
4706,
736,
5852,
13,
1678,
25342,
1347,
297,
4852,
1217,
613,
376,
8824,
613,
376,
4541,
613,
376,
29900,
29908,
1125,
13,
4706,
736,
7700,
13,
1678,
1683,
29901,
13,
4706,
12020,
1852,
5510,
29889,
15730,
1542,
2392,
703,
15954,
852,
1546,
525,
3582,
29915,
470,
525,
1217,
4286,
1159,
13,
13,
13,
1753,
18765,
362,
29918,
710,
8963,
29898,
1807,
1125,
13,
1678,
9995,
13,
1678,
1281,
369,
1372,
263,
1347,
304,
385,
18765,
362,
13705,
29889,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
1347,
584,
851,
13,
4706,
1714,
20766,
278,
18765,
362,
13705,
304,
367,
1304,
29889,
13,
13,
1678,
16969,
13,
1678,
448,
22158,
13,
1678,
740,
584,
13,
4706,
450,
18765,
362,
13705,
29889,
13,
1678,
9995,
13,
1678,
565,
1347,
1275,
376,
1217,
29918,
2987,
358,
362,
1115,
13,
4706,
736,
694,
29918,
2987,
358,
362,
13,
1678,
25342,
1347,
1275,
376,
2987,
358,
362,
29918,
2541,
29918,
20908,
1414,
1115,
13,
4706,
736,
18765,
362,
29918,
2541,
29918,
20908,
1414,
13,
1678,
565,
1347,
1275,
376,
2987,
358,
362,
29918,
14037,
29918,
20908,
1414,
1115,
13,
4706,
736,
18765,
362,
29918,
14037,
29918,
20908,
1414,
13,
1678,
25342,
1347,
1275,
376,
2987,
358,
362,
29918,
2541,
29918,
9313,
1133,
29918,
20908,
1414,
1115,
13,
4706,
736,
18765,
362,
29918,
2541,
29918,
9313,
1133,
29918,
20908,
1414,
13,
1678,
25342,
1347,
1275,
376,
2987,
358,
362,
29918,
27525,
398,
29918,
342,
7715,
1115,
13,
4706,
736,
18765,
362,
29918,
27525,
398,
29918,
342,
7715,
13,
1678,
1683,
29901,
13,
4706,
12020,
1852,
5510,
29889,
15730,
1542,
2392,
29898,
13,
9651,
376,
15954,
852,
1546,
525,
1217,
29918,
2987,
358,
362,
742,
29908,
13,
9651,
13577,
2987,
358,
362,
29918,
2541,
29918,
20908,
1414,
742,
525,
2987,
358,
362,
29918,
14037,
29918,
20908,
1414,
29908,
13,
9651,
13577,
2987,
358,
362,
29918,
2541,
29918,
9313,
1133,
29918,
20908,
1414,
29915,
322,
525,
2987,
358,
362,
29918,
27525,
398,
29918,
342,
7715,
29915,
1213,
13,
4706,
1723,
13,
2
] |
tests/mac-logs/examples/tag/tag.py | andrewp-as-is/mac-logs.py | 1 | 39579 | <filename>tests/mac-logs/examples/tag/tag.py
#!/usr/bin/env python
import mac_logs
mac_logs.tag()
| [
1,
529,
9507,
29958,
21150,
29914,
8628,
29899,
20756,
29914,
19057,
29914,
4039,
29914,
4039,
29889,
2272,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
13,
5215,
5825,
29918,
20756,
13,
13,
8628,
29918,
20756,
29889,
4039,
580,
13,
2
] |
Task1E.py | Yichen-Cai-yc539/Lab87-Flood-Warning-System | 0 | 169581 | <filename>Task1E.py
from floodsystem.stationdata import build_station_list
from floodsystem.geo import rivers_by_station_number
def run():
stations = build_station_list()
print(rivers_by_station_number(stations, 10))
run() | [
1,
529,
9507,
29958,
5398,
29896,
29923,
29889,
2272,
13,
3166,
5685,
397,
5205,
29889,
19569,
1272,
1053,
2048,
29918,
19569,
29918,
1761,
13,
3166,
5685,
397,
5205,
29889,
24756,
1053,
27515,
29918,
1609,
29918,
19569,
29918,
4537,
13,
13,
1753,
1065,
7295,
13,
1678,
16355,
353,
2048,
29918,
19569,
29918,
1761,
580,
13,
1678,
1596,
29898,
374,
874,
29918,
1609,
29918,
19569,
29918,
4537,
29898,
303,
800,
29892,
29871,
29896,
29900,
876,
13,
13,
3389,
580,
2
] |
CtCI_custom_classes/linked_list.py | enyquist/Cracking_the_Coding_Interview | 0 | 1613701 | from random import randint
from CtCI_custom_classes.node import Node
class LinkedList:
def __init__(self):
self.head = None
def insert(self, data):
node = Node(data)
node.set_next(self.head)
self.head = node
def size(self):
current = self.head
count = 0
while current:
count += 1
current = current.get_next()
return count
def kth_to_last(self, k):
current = runner = self.head
for _ in range(k):
if runner is None:
return None
runner = runner.get_next()
while runner:
current = current.get_next()
runner = runner.get_next()
return current.get_data()
def search(self, data):
current = self.head
found = False
while current and found is False:
if current.get_data() == data:
found = True
else:
current = current.get_next()
if current is None:
raise ValueError('Data is not in list')
return current
def delete(self, data):
current = self.head
previous = None
found = False
while current and found is False:
if current.get_data() == data:
found = True
else:
previous = current
current = current.get_next()
if current is None:
raise ValueError('Data is not in list')
if previous is None:
self.head = current.get_next()
else:
previous.set_next(current.get_next())
def print_list(self):
temp = self.head
while temp:
print(temp.get_data())
temp = temp.get_next()
def generate(self, length, start, stop):
for _ in range(length):
val = randint(a=start, b=stop)
self.insert(val)
| [
1,
515,
4036,
1053,
20088,
524,
13,
13,
3166,
315,
29873,
8426,
29918,
6341,
29918,
13203,
29889,
3177,
1053,
9071,
13,
13,
13,
1990,
28547,
1293,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
2813,
353,
6213,
13,
13,
1678,
822,
4635,
29898,
1311,
29892,
848,
1125,
13,
4706,
2943,
353,
9071,
29898,
1272,
29897,
13,
4706,
2943,
29889,
842,
29918,
4622,
29898,
1311,
29889,
2813,
29897,
13,
4706,
1583,
29889,
2813,
353,
2943,
13,
13,
1678,
822,
2159,
29898,
1311,
1125,
13,
4706,
1857,
353,
1583,
29889,
2813,
13,
4706,
2302,
353,
29871,
29900,
13,
4706,
1550,
1857,
29901,
13,
9651,
2302,
4619,
29871,
29896,
13,
9651,
1857,
353,
1857,
29889,
657,
29918,
4622,
580,
13,
4706,
736,
2302,
13,
13,
1678,
822,
413,
386,
29918,
517,
29918,
4230,
29898,
1311,
29892,
413,
1125,
13,
4706,
1857,
353,
28877,
353,
1583,
29889,
2813,
13,
4706,
363,
903,
297,
3464,
29898,
29895,
1125,
13,
9651,
565,
28877,
338,
6213,
29901,
13,
18884,
736,
6213,
13,
9651,
28877,
353,
28877,
29889,
657,
29918,
4622,
580,
13,
13,
4706,
1550,
28877,
29901,
13,
9651,
1857,
353,
1857,
29889,
657,
29918,
4622,
580,
13,
9651,
28877,
353,
28877,
29889,
657,
29918,
4622,
580,
13,
13,
4706,
736,
1857,
29889,
657,
29918,
1272,
580,
13,
13,
1678,
822,
2740,
29898,
1311,
29892,
848,
1125,
13,
4706,
1857,
353,
1583,
29889,
2813,
13,
4706,
1476,
353,
7700,
13,
4706,
1550,
1857,
322,
1476,
338,
7700,
29901,
13,
9651,
565,
1857,
29889,
657,
29918,
1272,
580,
1275,
848,
29901,
13,
18884,
1476,
353,
5852,
13,
9651,
1683,
29901,
13,
18884,
1857,
353,
1857,
29889,
657,
29918,
4622,
580,
13,
4706,
565,
1857,
338,
6213,
29901,
13,
9651,
12020,
7865,
2392,
877,
1469,
338,
451,
297,
1051,
1495,
13,
4706,
736,
1857,
13,
13,
1678,
822,
5217,
29898,
1311,
29892,
848,
1125,
13,
4706,
1857,
353,
1583,
29889,
2813,
13,
4706,
3517,
353,
6213,
13,
4706,
1476,
353,
7700,
13,
4706,
1550,
1857,
322,
1476,
338,
7700,
29901,
13,
9651,
565,
1857,
29889,
657,
29918,
1272,
580,
1275,
848,
29901,
13,
18884,
1476,
353,
5852,
13,
9651,
1683,
29901,
13,
18884,
3517,
353,
1857,
13,
18884,
1857,
353,
1857,
29889,
657,
29918,
4622,
580,
13,
4706,
565,
1857,
338,
6213,
29901,
13,
9651,
12020,
7865,
2392,
877,
1469,
338,
451,
297,
1051,
1495,
13,
4706,
565,
3517,
338,
6213,
29901,
13,
9651,
1583,
29889,
2813,
353,
1857,
29889,
657,
29918,
4622,
580,
13,
4706,
1683,
29901,
13,
9651,
3517,
29889,
842,
29918,
4622,
29898,
3784,
29889,
657,
29918,
4622,
3101,
13,
13,
1678,
822,
1596,
29918,
1761,
29898,
1311,
1125,
13,
4706,
5694,
353,
1583,
29889,
2813,
13,
4706,
1550,
5694,
29901,
13,
9651,
1596,
29898,
7382,
29889,
657,
29918,
1272,
3101,
13,
9651,
5694,
353,
5694,
29889,
657,
29918,
4622,
580,
13,
13,
1678,
822,
5706,
29898,
1311,
29892,
3309,
29892,
1369,
29892,
5040,
1125,
13,
4706,
363,
903,
297,
3464,
29898,
2848,
1125,
13,
9651,
659,
353,
20088,
524,
29898,
29874,
29922,
2962,
29892,
289,
29922,
9847,
29897,
13,
9651,
1583,
29889,
7851,
29898,
791,
29897,
13,
2
] |
list_tuple/10.py | mdazharuddin1011999/IoT_Assignment_2 | 0 | 108477 | <filename>list_tuple/10.py
from math import pi, exp
consts = (pi, exp)
print("Area of circle is:", consts[0]*int(input("Enter radius of circle: "))**2) | [
1,
529,
9507,
29958,
1761,
29918,
23583,
29914,
29896,
29900,
29889,
2272,
13,
3166,
5844,
1053,
2930,
29892,
1518,
13,
3075,
29879,
353,
313,
1631,
29892,
1518,
29897,
13,
2158,
703,
13799,
310,
8607,
338,
29901,
613,
1040,
29879,
29961,
29900,
14178,
524,
29898,
2080,
703,
10399,
11855,
310,
8607,
29901,
376,
876,
1068,
29906,
29897,
2
] |
python_reddit_img_download/main.py | brandonyuh/python_reddit_img_download | 1 | 120269 | <filename>python_reddit_img_download/main.py<gh_stars>1-10
import sys
import praw
import re
import pyperclip
import requests
#delete this line
import reddit_variables
# Replace with your own at https://www.reddit.com/prefs/apps
client_id = reddit_variables.client_id
client_secret = reddit_variables.client_secret
user_agent = reddit_variables.user_agent
reddit = praw.Reddit(client_id=client_id, client_secret=client_secret, user_agent=user_agent)
regex_url = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain...
r'localhost|' # localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
def main():
url = pyperclip.paste()
if (not re.match(regex_url, url)):
url = sys.argv[1]
if (not re.match(regex_url, url)):
url = input("URL?")
if (not re.match(regex_url, url)):
print("URL invalid quitting")
sys.exit(1)
submission = reddit.submission(url=url)
author = str(submission.author)
image_url = submission.url
id = str(submission.id)
local_image = author + "_" + id + ".png"
with open(author + "_" + id + ".txt", "w") as file:
file.write(url)
img_data = requests.get(image_url).content
with open(local_image, 'wb') as handler:
handler.write(img_data)
if __name__ == "__main__":
main() | [
1,
529,
9507,
29958,
4691,
29918,
1127,
27423,
29918,
2492,
29918,
10382,
29914,
3396,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
10876,
13,
5215,
20467,
13,
5215,
337,
13,
5215,
11451,
546,
24049,
13,
5215,
7274,
13,
13,
29937,
8143,
445,
1196,
13,
5215,
337,
1289,
277,
29918,
20897,
13,
13,
29937,
22108,
411,
596,
1914,
472,
2045,
597,
1636,
29889,
1127,
27423,
29889,
510,
29914,
29886,
24539,
29914,
13371,
13,
4645,
29918,
333,
353,
337,
1289,
277,
29918,
20897,
29889,
4645,
29918,
333,
13,
4645,
29918,
19024,
353,
337,
1289,
277,
29918,
20897,
29889,
4645,
29918,
19024,
13,
1792,
29918,
14748,
353,
337,
1289,
277,
29918,
20897,
29889,
1792,
29918,
14748,
13,
13,
1127,
27423,
353,
20467,
29889,
9039,
27423,
29898,
4645,
29918,
333,
29922,
4645,
29918,
333,
29892,
3132,
29918,
19024,
29922,
4645,
29918,
19024,
29892,
1404,
29918,
14748,
29922,
1792,
29918,
14748,
29897,
13,
13,
13087,
29918,
2271,
353,
337,
29889,
12198,
29898,
13,
1678,
364,
29915,
29985,
10780,
29901,
1124,
29989,
23102,
29897,
29879,
29973,
597,
29915,
29871,
396,
1732,
597,
470,
2045,
597,
13,
1678,
364,
29915,
10780,
5919,
29973,
10834,
29909,
29899,
29999,
29900,
29899,
29929,
850,
29973,
10834,
29909,
29899,
29999,
29900,
29899,
29929,
29899,
3199,
29900,
29892,
29953,
29896,
4400,
29909,
29899,
29999,
29900,
29899,
29929,
2314,
29973,
29905,
1846,
29974,
10780,
10834,
29909,
29899,
29999,
3199,
29906,
29892,
29953,
1012,
29889,
29973,
29989,
29961,
29909,
29899,
29999,
29900,
29899,
29929,
29899,
3199,
29906,
29892,
1012,
29889,
7897,
29989,
29915,
29871,
396,
5354,
856,
13,
1678,
364,
29915,
7640,
29989,
29915,
29871,
396,
15683,
856,
13,
1678,
364,
12764,
29881,
29912,
29896,
29892,
29941,
1012,
7790,
29881,
29912,
29896,
29892,
29941,
1012,
7790,
29881,
29912,
29896,
29892,
29941,
1012,
7790,
29881,
29912,
29896,
29892,
29941,
1800,
29915,
29871,
396,
2023,
272,
10377,
13,
1678,
364,
29915,
10780,
1057,
29905,
29881,
29974,
6877,
29915,
29871,
396,
13136,
2011,
13,
1678,
364,
29915,
10780,
8419,
29973,
29989,
29961,
13401,
10725,
29903,
29974,
1262,
742,
337,
29889,
6259,
6632,
1525,
23487,
29897,
13,
13,
1753,
1667,
7295,
13,
1678,
3142,
353,
11451,
546,
24049,
29889,
16179,
580,
13,
1678,
565,
313,
1333,
337,
29889,
4352,
29898,
13087,
29918,
2271,
29892,
3142,
22164,
13,
4706,
3142,
353,
10876,
29889,
19218,
29961,
29896,
29962,
13,
4706,
565,
313,
1333,
337,
29889,
4352,
29898,
13087,
29918,
2271,
29892,
3142,
22164,
13,
9651,
3142,
353,
1881,
703,
4219,
29973,
1159,
13,
9651,
565,
313,
1333,
337,
29889,
4352,
29898,
13087,
29918,
2271,
29892,
3142,
22164,
13,
18884,
1596,
703,
4219,
8340,
439,
5367,
1159,
13,
18884,
10876,
29889,
13322,
29898,
29896,
29897,
13,
13,
1678,
29240,
353,
337,
1289,
277,
29889,
1491,
6737,
29898,
2271,
29922,
2271,
29897,
13,
1678,
4148,
353,
851,
29898,
1491,
6737,
29889,
8921,
29897,
13,
1678,
1967,
29918,
2271,
353,
29240,
29889,
2271,
13,
1678,
1178,
353,
851,
29898,
1491,
6737,
29889,
333,
29897,
13,
13,
1678,
1887,
29918,
3027,
353,
4148,
718,
11119,
29908,
718,
1178,
718,
11393,
2732,
29908,
13,
1678,
411,
1722,
29898,
8921,
718,
11119,
29908,
718,
1178,
718,
11393,
3945,
613,
376,
29893,
1159,
408,
934,
29901,
13,
4706,
934,
29889,
3539,
29898,
2271,
29897,
13,
1678,
10153,
29918,
1272,
353,
7274,
29889,
657,
29898,
3027,
29918,
2271,
467,
3051,
13,
1678,
411,
1722,
29898,
2997,
29918,
3027,
29892,
525,
29893,
29890,
1495,
408,
7834,
29901,
13,
4706,
7834,
29889,
3539,
29898,
2492,
29918,
1272,
29897,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
1667,
580,
2
] |
api/core/threads_core.py | michael-pryor/GeoTweetSearch | 1 | 86725 | <reponame>michael-pryor/GeoTweetSearch<filename>api/core/threads_core.py
import logging
import os
from threading import Thread
import traceback
import time
from api.config import Configuration
from api.core.utility import EventTimer
logger = logging.getLogger(__name__)
class BaseThread(Thread):
def __init__(self, threadName, onTerminateFunc=None, criticalThread=None, maxFailures=None, failureBackoffMaximumMs=None):
if criticalThread is None:
criticalThread = True
if criticalThread:
critString = '(critical)'
else:
critString = '(non critical)'
name = '%s %s' % (threadName, critString)
super(BaseThread,self).__init__(name=name)
if failureBackoffMaximumMs is None:
failureBackoffMaximumMs = Configuration.THREAD_FAILURE_DEFAULT_MAXIMUM_BACKOFF_MS
if maxFailures is None:
maxFailures = Configuration.THREAD_FAILURE_DEFAULT_MAXIMUM_COUNT
self.stopped = False
self.on_terminate_func = onTerminateFunc
self.is_critical_thread = criticalThread
self.failure_event_timer = EventTimer(maxFailures, failureBackoffMaximumMs * 2)
self.on_failure_wait_before_restart_seconds = float(1)
self.on_failure_wait_before_restart_seconds_maximum = float(failureBackoffMaximumMs) / 1000
def _run(self):
raise NotImplementedError
def _onRestart(self, e):
""" Called when thread fails and attempts to restart,
run method will be called afterwards.
@param e exception which triggered restart.
@return True if """
traceback.print_exc()
def _onFailure(self, e):
""" Called when restarts failed and thread is terminating. """
traceback.print_exc()
def run(self):
needRestart = None
while True:
logger.info('Starting thread: %s' % self.getName())
try:
if needRestart:
self._onRestart(needRestart)
needRestart = None
self._run()
if not self.stopped:
raise Exception('Thread illegally exited')
logger.warn('Thread legally exited and will be allowed to terminate: %s' % self.getName()) # looking at this, keep as warn for now.
break # if we reach this point thread is terminating normally.
except Exception as e:
logger.error('Exception in thread: %s - %s (%s)' % (self.getName(), e.message, type(e)))
if not self.failure_event_timer.onEvent():
if self.on_failure_wait_before_restart_seconds > 0:
if self.failure_event_timer.triggered_reset:
logger.error('Reset failure back off time to 1 second of thread: %s' % self.getName())
self.on_failure_wait_before_restart_seconds = float(1)
logger.error('Waiting %.2f seconds before restarting thread: %s' % (self.on_failure_wait_before_restart_seconds, self.getName()))
time.sleep(self.on_failure_wait_before_restart_seconds)
# Exponential increase in wait time (up to maximum).
if self.on_failure_wait_before_restart_seconds < self.on_failure_wait_before_restart_seconds_maximum:
self.on_failure_wait_before_restart_seconds *= 2
if self.on_failure_wait_before_restart_seconds > self.on_failure_wait_before_restart_seconds_maximum:
self.on_failure_wait_before_restart_seconds = self.on_failure_wait_before_restart_seconds_maximum
logger.error('Attempting to restart thread: %s' % self.getName())
needRestart = e
continue
else:
try:
self._onFailure(e)
except Exception as e:
logger.error('Exception while terminating thread: %s, details: %s' % (self.getName(), e.message))
if self.is_critical_thread:
logger.error('Critical thread failed, terminating application - thread responsible: %s' % self.getName())
os._exit(0)
else:
logger.error('Thread failed without terminating application: %s' % self.getName())
break
logger.warn('Thread terminating: %s' % self.getName()) # looking at this, keep as warn for now.
if self.on_terminate_func:
self.on_terminate_func()
def stop(self):
self.stopped = True | [
1,
529,
276,
1112,
420,
29958,
29885,
436,
4271,
29899,
558,
29891,
272,
29914,
7999,
29877,
29911,
16668,
7974,
29966,
9507,
29958,
2754,
29914,
3221,
29914,
28993,
29918,
3221,
29889,
2272,
13,
5215,
12183,
13,
5215,
2897,
13,
3166,
3244,
292,
1053,
10480,
13,
5215,
9637,
1627,
13,
5215,
931,
13,
3166,
7882,
29889,
2917,
1053,
20999,
13,
3166,
7882,
29889,
3221,
29889,
329,
1793,
1053,
6864,
14745,
13,
13,
21707,
353,
12183,
29889,
657,
16363,
22168,
978,
1649,
29897,
13,
13,
1990,
7399,
4899,
29898,
4899,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3244,
1170,
29892,
373,
14343,
16976,
14400,
29922,
8516,
29892,
12187,
4899,
29922,
8516,
29892,
4236,
16243,
1973,
29922,
8516,
29892,
10672,
5841,
2696,
7976,
12539,
29924,
29879,
29922,
8516,
1125,
13,
4706,
565,
12187,
4899,
338,
6213,
29901,
13,
9651,
12187,
4899,
353,
5852,
13,
13,
4706,
565,
29871,
12187,
4899,
29901,
13,
9651,
3994,
1231,
353,
525,
29898,
9695,
936,
16029,
13,
4706,
1683,
29901,
13,
9651,
3994,
1231,
353,
525,
29898,
5464,
12187,
16029,
13,
13,
4706,
1024,
353,
14210,
29879,
1273,
29879,
29915,
1273,
313,
7097,
1170,
29892,
3994,
1231,
29897,
13,
13,
4706,
2428,
29898,
5160,
4899,
29892,
1311,
467,
1649,
2344,
12035,
978,
29922,
978,
29897,
13,
13,
4706,
565,
10672,
5841,
2696,
7976,
12539,
29924,
29879,
338,
6213,
29901,
13,
9651,
10672,
5841,
2696,
7976,
12539,
29924,
29879,
353,
20999,
29889,
4690,
16310,
29918,
4519,
6227,
11499,
29918,
23397,
29918,
12648,
7833,
5005,
29918,
29933,
11375,
27681,
29918,
4345,
13,
13,
4706,
565,
4236,
16243,
1973,
338,
6213,
29901,
13,
9651,
4236,
16243,
1973,
353,
20999,
29889,
4690,
16310,
29918,
4519,
6227,
11499,
29918,
23397,
29918,
12648,
7833,
5005,
29918,
18736,
13,
13,
13,
4706,
1583,
29889,
7864,
2986,
353,
7700,
13,
4706,
1583,
29889,
265,
29918,
18821,
403,
29918,
9891,
353,
373,
14343,
16976,
14400,
13,
13,
4706,
1583,
29889,
275,
29918,
9695,
936,
29918,
7097,
353,
12187,
4899,
13,
4706,
1583,
29889,
14057,
545,
29918,
3696,
29918,
20404,
353,
6864,
14745,
29898,
3317,
16243,
1973,
29892,
10672,
5841,
2696,
7976,
12539,
29924,
29879,
334,
29871,
29906,
29897,
13,
4706,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
353,
5785,
29898,
29896,
29897,
13,
4706,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
29918,
27525,
398,
353,
5785,
29898,
14057,
545,
5841,
2696,
7976,
12539,
29924,
29879,
29897,
847,
29871,
29896,
29900,
29900,
29900,
13,
13,
1678,
822,
903,
3389,
29898,
1311,
1125,
13,
4706,
12020,
2216,
1888,
2037,
287,
2392,
13,
13,
1678,
822,
903,
265,
15078,
442,
29898,
1311,
29892,
321,
1125,
13,
4706,
9995,
3037,
839,
746,
3244,
8465,
322,
14734,
304,
10715,
29892,
13,
9651,
1065,
1158,
674,
367,
2000,
12335,
29889,
13,
9651,
732,
3207,
321,
3682,
607,
19799,
10715,
29889,
13,
9651,
732,
2457,
5852,
565,
9995,
13,
4706,
9637,
1627,
29889,
2158,
29918,
735,
29883,
580,
13,
13,
1678,
822,
903,
265,
24155,
29898,
1311,
29892,
321,
1125,
13,
4706,
9995,
3037,
839,
746,
1791,
5708,
5229,
322,
3244,
338,
6624,
1218,
29889,
9995,
13,
4706,
9637,
1627,
29889,
2158,
29918,
735,
29883,
580,
13,
13,
1678,
822,
1065,
29898,
1311,
1125,
13,
4706,
817,
15078,
442,
353,
6213,
13,
4706,
1550,
5852,
29901,
13,
9651,
17927,
29889,
3888,
877,
4763,
292,
3244,
29901,
1273,
29879,
29915,
1273,
1583,
29889,
19629,
3101,
13,
9651,
1018,
29901,
13,
18884,
565,
817,
15078,
442,
29901,
13,
462,
1678,
1583,
3032,
265,
15078,
442,
29898,
26180,
15078,
442,
29897,
13,
462,
1678,
817,
15078,
442,
353,
6213,
13,
13,
18884,
1583,
3032,
3389,
580,
13,
13,
18884,
565,
451,
1583,
29889,
7864,
2986,
29901,
13,
462,
1678,
12020,
8960,
877,
4899,
980,
1397,
635,
429,
1573,
1495,
13,
13,
18884,
17927,
29889,
25442,
877,
4899,
2814,
635,
429,
1573,
322,
674,
367,
6068,
304,
29504,
29901,
1273,
29879,
29915,
1273,
1583,
29889,
19629,
3101,
396,
3063,
472,
445,
29892,
3013,
408,
29383,
363,
1286,
29889,
13,
18884,
2867,
396,
565,
591,
6159,
445,
1298,
3244,
338,
6624,
1218,
12891,
29889,
13,
9651,
5174,
8960,
408,
321,
29901,
13,
18884,
17927,
29889,
2704,
877,
2451,
297,
3244,
29901,
1273,
29879,
448,
1273,
29879,
313,
29995,
29879,
16029,
1273,
313,
1311,
29889,
19629,
3285,
321,
29889,
4906,
29892,
1134,
29898,
29872,
4961,
13,
13,
18884,
565,
451,
1583,
29889,
14057,
545,
29918,
3696,
29918,
20404,
29889,
265,
2624,
7295,
13,
462,
1678,
565,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
1405,
29871,
29900,
29901,
13,
462,
4706,
565,
1583,
29889,
14057,
545,
29918,
3696,
29918,
20404,
29889,
21001,
287,
29918,
12071,
29901,
13,
462,
9651,
17927,
29889,
2704,
877,
27175,
10672,
1250,
1283,
931,
304,
29871,
29896,
1473,
310,
3244,
29901,
1273,
29879,
29915,
1273,
1583,
29889,
19629,
3101,
13,
462,
9651,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
353,
5785,
29898,
29896,
29897,
13,
13,
462,
4706,
17927,
29889,
2704,
877,
15716,
292,
18695,
29906,
29888,
6923,
1434,
10715,
292,
3244,
29901,
1273,
29879,
29915,
1273,
313,
1311,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
29892,
1583,
29889,
19629,
22130,
13,
462,
4706,
931,
29889,
17059,
29898,
1311,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
29897,
13,
13,
462,
4706,
396,
1222,
1112,
2556,
7910,
297,
4480,
931,
313,
786,
304,
7472,
467,
13,
462,
4706,
565,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
529,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
29918,
27525,
398,
29901,
13,
462,
9651,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
334,
29922,
29871,
29906,
13,
13,
462,
9651,
565,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
1405,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
29918,
27525,
398,
29901,
13,
462,
18884,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
353,
1583,
29889,
265,
29918,
14057,
545,
29918,
10685,
29918,
11083,
29918,
5060,
442,
29918,
23128,
29918,
27525,
398,
13,
13,
462,
1678,
17927,
29889,
2704,
877,
4165,
3456,
292,
304,
10715,
3244,
29901,
1273,
29879,
29915,
1273,
1583,
29889,
19629,
3101,
13,
462,
1678,
817,
15078,
442,
353,
321,
13,
462,
1678,
6773,
13,
18884,
1683,
29901,
13,
462,
1678,
1018,
29901,
13,
462,
4706,
1583,
3032,
265,
24155,
29898,
29872,
29897,
13,
462,
1678,
5174,
8960,
408,
321,
29901,
13,
462,
4706,
17927,
29889,
2704,
877,
2451,
1550,
6624,
1218,
3244,
29901,
1273,
29879,
29892,
4902,
29901,
1273,
29879,
29915,
1273,
313,
1311,
29889,
19629,
3285,
321,
29889,
4906,
876,
13,
13,
462,
1678,
565,
1583,
29889,
275,
29918,
9695,
936,
29918,
7097,
29901,
13,
462,
4706,
17927,
29889,
2704,
877,
29907,
768,
936,
3244,
5229,
29892,
6624,
1218,
2280,
448,
3244,
14040,
29901,
1273,
29879,
29915,
1273,
1583,
29889,
19629,
3101,
13,
462,
4706,
2897,
3032,
13322,
29898,
29900,
29897,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
17927,
29889,
2704,
877,
4899,
5229,
1728,
6624,
1218,
2280,
29901,
1273,
29879,
29915,
1273,
1583,
29889,
19629,
3101,
13,
13,
462,
1678,
2867,
13,
13,
4706,
17927,
29889,
25442,
877,
4899,
6624,
1218,
29901,
1273,
29879,
29915,
1273,
1583,
29889,
19629,
3101,
396,
3063,
472,
445,
29892,
3013,
408,
29383,
363,
1286,
29889,
13,
4706,
565,
1583,
29889,
265,
29918,
18821,
403,
29918,
9891,
29901,
13,
9651,
1583,
29889,
265,
29918,
18821,
403,
29918,
9891,
580,
13,
13,
1678,
822,
5040,
29898,
1311,
1125,
13,
4706,
1583,
29889,
7864,
2986,
353,
5852,
2
] |
main/PublicEmotionDatasets/Adobe/process/train_glove.py | cvlab-stonybrook/Emotion-Prediction | 10 | 31650 | <filename>main/PublicEmotionDatasets/Adobe/process/train_glove.py
"""
Copyright (c) 2019 <NAME>
Licensed under the MIT License
Author: <NAME>
Email: <EMAIL>
Last modified: 18/12/2019
Usage:
Run this script to train GloVe model on Adobe tags.
"""
import os
import gluonnlp as nlp
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sb
from glove import Corpus, Glove
import glob
import pickle
from gensim.models import Word2Vec
from gensim.models import KeyedVectors
model_folder = "/nfs/bigfovea/add_disk0/eugenia/Emotion/wordembedding_models/"
#Creating a corpus object
corpus = Corpus()
#Training the corpus to generate the co occurence matrix which is used in GloVe
corpus.fit(lines, window=10)
# train the model
glove = Glove(no_components=5, learning_rate=0.05)
glove.fit(corpus.matrix, epochs=30, no_threads=4, verbose=True)
glove.add_dictionary(corpus.dictionary)
# save the model
glove.save(os.path.join(model_folder, 'glove_adobe.model')) | [
1,
529,
9507,
29958,
3396,
29914,
19858,
6026,
8194,
16390,
294,
1691,
29914,
3253,
16945,
29914,
5014,
29914,
14968,
29918,
29887,
417,
345,
29889,
2272,
13,
15945,
29908,
13,
11882,
1266,
313,
29883,
29897,
29871,
29906,
29900,
29896,
29929,
529,
5813,
29958,
13,
29931,
293,
21144,
1090,
278,
341,
1806,
19245,
13,
13720,
29901,
529,
5813,
29958,
13,
9823,
29901,
529,
26862,
6227,
29958,
13,
8897,
9120,
29901,
29871,
29896,
29947,
29914,
29896,
29906,
29914,
29906,
29900,
29896,
29929,
13,
13,
27573,
29901,
13,
6558,
445,
2471,
304,
7945,
21806,
29963,
29872,
1904,
373,
2087,
16945,
8282,
29889,
13,
15945,
29908,
13,
13,
5215,
2897,
13,
5215,
3144,
29884,
3409,
22833,
408,
302,
22833,
13,
5215,
12655,
408,
7442,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
409,
370,
1398,
408,
17444,
13,
3166,
15482,
345,
1053,
2994,
13364,
29892,
21806,
345,
13,
5215,
13149,
13,
5215,
5839,
280,
13,
3166,
26943,
326,
29889,
9794,
1053,
10803,
29906,
25987,
13,
3166,
26943,
326,
29889,
9794,
1053,
7670,
287,
29963,
11142,
13,
13,
13,
4299,
29918,
12083,
353,
5591,
29876,
5847,
29914,
3752,
29888,
994,
29874,
29914,
1202,
29918,
20960,
29900,
29914,
29872,
10214,
423,
29914,
6026,
8194,
29914,
13762,
2310,
2580,
8497,
29918,
9794,
12975,
13,
13,
29937,
9832,
1218,
263,
1034,
13364,
1203,
13,
2616,
13364,
353,
2994,
13364,
580,
13,
29937,
5323,
2827,
278,
1034,
13364,
304,
5706,
278,
1302,
6403,
663,
4636,
607,
338,
1304,
297,
21806,
29963,
29872,
13,
2616,
13364,
29889,
9202,
29898,
9012,
29892,
3474,
29922,
29896,
29900,
29897,
13,
13,
29937,
7945,
278,
1904,
13,
29887,
417,
345,
353,
21806,
345,
29898,
1217,
29918,
14036,
29922,
29945,
29892,
6509,
29918,
10492,
29922,
29900,
29889,
29900,
29945,
29897,
13,
29887,
417,
345,
29889,
9202,
29898,
2616,
13364,
29889,
5344,
29892,
21502,
12168,
29922,
29941,
29900,
29892,
694,
29918,
28993,
29922,
29946,
29892,
26952,
29922,
5574,
29897,
13,
29887,
417,
345,
29889,
1202,
29918,
27126,
29898,
2616,
13364,
29889,
27126,
29897,
13,
13,
29937,
4078,
278,
1904,
13,
29887,
417,
345,
29889,
7620,
29898,
359,
29889,
2084,
29889,
7122,
29898,
4299,
29918,
12083,
29892,
525,
29887,
417,
345,
29918,
328,
16945,
29889,
4299,
8785,
2
] |
tests/contrib/test_discord.py | eblume/flask-dance | 0 | 130882 | <filename>tests/contrib/test_discord.py<gh_stars>0
from __future__ import unicode_literals
import pytest
import responses
from urlobject import URLObject
from flask import Flask
from flask_dance.contrib.discord import make_discord_blueprint, discord
from flask_dance.consumer import OAuth2ConsumerBlueprint
from flask_dance.consumer.storage import MemoryStorage
@pytest.fixture
def make_app():
def _make_app(*args, **kwargs):
app = Flask(__name__)
app.secret_key = "whatever"
blueprint = make_discord_blueprint(*args, **kwargs)
app.register_blueprint(blueprint)
return app
return _make_app
def test_blueprint_factory():
discord_bp = make_discord_blueprint(
client_id="foo",
client_secret="bar",
scope=["identify", "email"],
redirect_to="index",
)
assert isinstance(discord_bp, OAuth2ConsumerBlueprint)
assert discord_bp.session.scope == ["identify", "email"]
assert discord_bp.session.base_url == "https://discordapp.com/"
assert discord_bp.session.client_id == "foo"
assert discord_bp.client_secret == "bar"
assert discord_bp.authorization_url == "https://discordapp.com/api/oauth2/authorize"
assert discord_bp.token_url == "https://discordapp.com/api/oauth2/token"
def test_load_from_config(make_app):
app = make_app(redirect_to="index")
app.config["DISCORD_OAUTH_CLIENT_ID"] = "foo"
app.config["DISCORD_OAUTH_CLIENT_SECRET"] = "bar"
resp = app.test_client().get("/discord")
url = resp.headers["Location"]
client_id = URLObject(url).query.dict.get("client_id")
assert client_id == "foo"
@responses.activate
def test_context_local(make_app):
responses.add(responses.GET, "https://google.com")
# set up two apps with two different set of auth tokens
app1 = make_app(
"foo1",
"bar1",
redirect_to="url1",
storage=MemoryStorage({"access_token": "<PASSWORD>"}),
)
app2 = make_app(
"foo2",
"bar2",
redirect_to="url2",
storage=MemoryStorage({"access_token": "<PASSWORD>"}),
)
# outside of a request context, referencing functions on the `discord` object
# will raise an exception
with pytest.raises(RuntimeError):
discord.get("https://google.com")
# inside of a request context, `discord` should be a proxy to the correct
# blueprint session
with app1.test_request_context("/"):
app1.preprocess_request()
discord.get("https://google.com")
request = responses.calls[0].request
assert request.headers["Authorization"] == "Bearer app1"
with app2.test_request_context("/"):
app2.preprocess_request()
discord.get("https://google.com")
request = responses.calls[1].request
assert request.headers["Authorization"] == "Bearer app2"
| [
1,
529,
9507,
29958,
21150,
29914,
21570,
29914,
1688,
29918,
2218,
16090,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
5215,
11451,
1688,
13,
5215,
20890,
13,
3166,
5065,
417,
1675,
1053,
3988,
2061,
13,
3166,
29784,
1053,
2379,
1278,
13,
3166,
29784,
29918,
29881,
749,
29889,
21570,
29889,
2218,
16090,
1053,
1207,
29918,
2218,
16090,
29918,
9539,
2158,
29892,
2313,
536,
13,
3166,
29784,
29918,
29881,
749,
29889,
25978,
261,
1053,
438,
6444,
29906,
13696,
4680,
21319,
2158,
13,
3166,
29784,
29918,
29881,
749,
29889,
25978,
261,
29889,
12925,
1053,
18914,
10486,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
1207,
29918,
932,
7295,
13,
1678,
822,
903,
5675,
29918,
932,
10456,
5085,
29892,
3579,
19290,
1125,
13,
4706,
623,
353,
2379,
1278,
22168,
978,
1649,
29897,
13,
4706,
623,
29889,
19024,
29918,
1989,
353,
376,
1332,
5564,
29908,
13,
4706,
7254,
2158,
353,
1207,
29918,
2218,
16090,
29918,
9539,
2158,
10456,
5085,
29892,
3579,
19290,
29897,
13,
4706,
623,
29889,
9573,
29918,
9539,
2158,
29898,
9539,
2158,
29897,
13,
4706,
736,
623,
13,
13,
1678,
736,
903,
5675,
29918,
932,
13,
13,
13,
1753,
1243,
29918,
9539,
2158,
29918,
14399,
7295,
13,
1678,
2313,
536,
29918,
25288,
353,
1207,
29918,
2218,
16090,
29918,
9539,
2158,
29898,
13,
4706,
3132,
29918,
333,
543,
5431,
613,
13,
4706,
3132,
29918,
19024,
543,
1646,
613,
13,
4706,
6874,
29922,
3366,
1693,
1598,
613,
376,
5269,
12436,
13,
4706,
6684,
29918,
517,
543,
2248,
613,
13,
1678,
1723,
13,
1678,
4974,
338,
8758,
29898,
2218,
16090,
29918,
25288,
29892,
438,
6444,
29906,
13696,
4680,
21319,
2158,
29897,
13,
1678,
4974,
2313,
536,
29918,
25288,
29889,
7924,
29889,
6078,
1275,
6796,
1693,
1598,
613,
376,
5269,
3108,
13,
1678,
4974,
2313,
536,
29918,
25288,
29889,
7924,
29889,
3188,
29918,
2271,
1275,
376,
991,
597,
2218,
16090,
932,
29889,
510,
12975,
13,
1678,
4974,
2313,
536,
29918,
25288,
29889,
7924,
29889,
4645,
29918,
333,
1275,
376,
5431,
29908,
13,
1678,
4974,
2313,
536,
29918,
25288,
29889,
4645,
29918,
19024,
1275,
376,
1646,
29908,
13,
1678,
4974,
2313,
536,
29918,
25288,
29889,
8921,
2133,
29918,
2271,
1275,
376,
991,
597,
2218,
16090,
932,
29889,
510,
29914,
2754,
29914,
23106,
29906,
29914,
8921,
675,
29908,
13,
1678,
4974,
2313,
536,
29918,
25288,
29889,
6979,
29918,
2271,
1275,
376,
991,
597,
2218,
16090,
932,
29889,
510,
29914,
2754,
29914,
23106,
29906,
29914,
6979,
29908,
13,
13,
13,
1753,
1243,
29918,
1359,
29918,
3166,
29918,
2917,
29898,
5675,
29918,
932,
1125,
13,
1678,
623,
353,
1207,
29918,
932,
29898,
17886,
29918,
517,
543,
2248,
1159,
13,
1678,
623,
29889,
2917,
3366,
23711,
29907,
25593,
29918,
29949,
20656,
29950,
29918,
27205,
3919,
29918,
1367,
3108,
353,
376,
5431,
29908,
13,
1678,
623,
29889,
2917,
3366,
23711,
29907,
25593,
29918,
29949,
20656,
29950,
29918,
27205,
3919,
29918,
1660,
22245,
29911,
3108,
353,
376,
1646,
29908,
13,
13,
1678,
4613,
353,
623,
29889,
1688,
29918,
4645,
2141,
657,
11974,
2218,
16090,
1159,
13,
1678,
3142,
353,
4613,
29889,
13662,
3366,
6508,
3108,
13,
1678,
3132,
29918,
333,
353,
3988,
2061,
29898,
2271,
467,
1972,
29889,
8977,
29889,
657,
703,
4645,
29918,
333,
1159,
13,
1678,
4974,
3132,
29918,
333,
1275,
376,
5431,
29908,
13,
13,
13,
29992,
26679,
267,
29889,
11236,
403,
13,
1753,
1243,
29918,
4703,
29918,
2997,
29898,
5675,
29918,
932,
1125,
13,
1678,
20890,
29889,
1202,
29898,
26679,
267,
29889,
7194,
29892,
376,
991,
597,
3608,
29889,
510,
1159,
13,
13,
1678,
396,
731,
701,
1023,
11446,
411,
1023,
1422,
731,
310,
4817,
18897,
13,
1678,
623,
29896,
353,
1207,
29918,
932,
29898,
13,
4706,
376,
5431,
29896,
613,
13,
4706,
376,
1646,
29896,
613,
13,
4706,
6684,
29918,
517,
543,
2271,
29896,
613,
13,
4706,
8635,
29922,
16015,
10486,
3319,
29908,
5943,
29918,
6979,
1115,
9872,
25711,
17013,
29958,
9092,
511,
13,
1678,
1723,
13,
1678,
623,
29906,
353,
1207,
29918,
932,
29898,
13,
4706,
376,
5431,
29906,
613,
13,
4706,
376,
1646,
29906,
613,
13,
4706,
6684,
29918,
517,
543,
2271,
29906,
613,
13,
4706,
8635,
29922,
16015,
10486,
3319,
29908,
5943,
29918,
6979,
1115,
9872,
25711,
17013,
29958,
9092,
511,
13,
1678,
1723,
13,
13,
1678,
396,
5377,
310,
263,
2009,
3030,
29892,
29371,
3168,
373,
278,
421,
2218,
16090,
29952,
1203,
13,
1678,
396,
674,
12020,
385,
3682,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
7944,
2392,
1125,
13,
4706,
2313,
536,
29889,
657,
703,
991,
597,
3608,
29889,
510,
1159,
13,
13,
1678,
396,
2768,
310,
263,
2009,
3030,
29892,
421,
2218,
16090,
29952,
881,
367,
263,
10166,
304,
278,
1959,
13,
1678,
396,
7254,
2158,
4867,
13,
1678,
411,
623,
29896,
29889,
1688,
29918,
3827,
29918,
4703,
11974,
29908,
1125,
13,
4706,
623,
29896,
29889,
1457,
5014,
29918,
3827,
580,
13,
4706,
2313,
536,
29889,
657,
703,
991,
597,
3608,
29889,
510,
1159,
13,
4706,
2009,
353,
20890,
29889,
29883,
4293,
29961,
29900,
1822,
3827,
13,
4706,
4974,
2009,
29889,
13662,
3366,
25471,
3108,
1275,
376,
29933,
799,
261,
623,
29896,
29908,
13,
13,
1678,
411,
623,
29906,
29889,
1688,
29918,
3827,
29918,
4703,
11974,
29908,
1125,
13,
4706,
623,
29906,
29889,
1457,
5014,
29918,
3827,
580,
13,
4706,
2313,
536,
29889,
657,
703,
991,
597,
3608,
29889,
510,
1159,
13,
4706,
2009,
353,
20890,
29889,
29883,
4293,
29961,
29896,
1822,
3827,
13,
4706,
4974,
2009,
29889,
13662,
3366,
25471,
3108,
1275,
376,
29933,
799,
261,
623,
29906,
29908,
13,
2
] |
examples/python/macOS/hack_or_die.py | kitazaki/NORA_Badge | 0 | 20383 | from __future__ import print_function
import time
import uuid
import Adafruit_BluefruitLE
CHARACTERISTIC_SERVICE_UUID = uuid.UUID('0000fee0-0000-1000-8000-00805f9b34fb')
CHARACTERISTIC_DATA_UUID = uuid.UUID('0000fee1-0000-1000-8000-00805f9b34fb')
provider = Adafruit_BluefruitLE.get_provider()
def main():
provider.clear_cached_data()
adapter = provider.get_default_adapter()
if not adapter.is_powered:
adapter.power_on()
print('Searching for device...')
try:
adapter.start_scan()
device = provider.find_device(service_uuids=[CHARACTERISTIC_SERVICE_UUID])
if device is None:
raise RuntimeError('Failed to find device!')
else:
print(device)
print('device: {0}'.format(device.name))
print('id: {0}'.format(device.id))
finally:
adapter.stop_scan()
print('Connecting to device...')
device.connect()
try:
print('Discovering services...')
device.discover([CHARACTERISTIC_SERVICE_UUID], [CHARACTERISTIC_DATA_UUID])
service = device.find_service(CHARACTERISTIC_SERVICE_UUID)
print('service uuid: {0}'.format(service.uuid))
data = service.find_characteristic(CHARACTERISTIC_DATA_UUID)
print('characteristic uuid: {0}'.format(data.uuid))
print('Writing Data..')
bs = bytes(range(16))
bs = b'\x77\x61\x6E\x67\x00\x00\x00\x00\x30\x00\x00\x00\x00\x00\x00\x00'
data.write_value(bs)
time.sleep(0.1)
bs = b'\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
data.write_value(bs)
time.sleep(0.1)
bs = b'\x00\x00\x00\x00\x00\x00\xE1\x0C\x06\x17\x2D\x23\x00\x00\x00\x00'
data.write_value(bs)
time.sleep(0.1)
bs = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
data.write_value(bs)
time.sleep(0.1)
bs = b'\x00\x00\xc6\xc6\xc6\xfe\xc6\xc6\xc6\xc6\x00\x00\x00\xfe\xc6\xc6'
data.write_value(bs)
time.sleep(0.1)
bs = b'\xfe\xc6\xc6\xc6\xc6\x00\x00\x00\xfe\xc6\xc0\xc0\xc6\xc6\xc6\xfe'
data.write_value(bs)
time.sleep(0.1)
bs = b'\x00\x00\x00\xc6\xcc\xd8\xf0\xd8\xcc\xc6\xc6\x00\x00\x00\x00\x00'
data.write_value(bs)
time.sleep(0.1)
bs = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7c\x6c\x6c'
data.write_value(bs)
time.sleep(0.1)
bs = b'\x7c\x00\x00\x00\x00\x00\x00\x00\x6c\x78\x70\x60\x00\x00\x00\x00'
data.write_value(bs)
time.sleep(0.1)
bs = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\xce\xc6\xc6\xc6\xc6'
data.write_value(bs)
time.sleep(0.1)
bs = b'\xce\xf8\x00\x00\x00\x30\x30\x30\x30\x30\x30\x30\x30\x00\x00\x00'
data.write_value(bs)
time.sleep(0.1)
bs = b'\xfe\xc0\xc0\xfe\xc0\xc0\xc0\xfe\x00\x00\x00\x00\x00\x00\x00\x00'
data.write_value(bs)
time.sleep(3)
print('Writing done.')
finally:
device.disconnect()
provider.initialize()
provider.run_mainloop_with(main)
| [
1,
515,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
13,
5215,
931,
13,
5215,
318,
5416,
13,
13,
5215,
23255,
29888,
9216,
29918,
21319,
29888,
9216,
1307,
13,
13,
11282,
17923,
1001,
9047,
2965,
29918,
6304,
19059,
29918,
29965,
11150,
353,
318,
5416,
29889,
29965,
11150,
877,
29900,
29900,
29900,
29900,
1725,
29872,
29900,
29899,
29900,
29900,
29900,
29900,
29899,
29896,
29900,
29900,
29900,
29899,
29947,
29900,
29900,
29900,
29899,
29900,
29900,
29947,
29900,
29945,
29888,
29929,
29890,
29941,
29946,
14943,
1495,
13,
11282,
17923,
1001,
9047,
2965,
29918,
14573,
29918,
29965,
11150,
353,
318,
5416,
29889,
29965,
11150,
877,
29900,
29900,
29900,
29900,
1725,
29872,
29896,
29899,
29900,
29900,
29900,
29900,
29899,
29896,
29900,
29900,
29900,
29899,
29947,
29900,
29900,
29900,
29899,
29900,
29900,
29947,
29900,
29945,
29888,
29929,
29890,
29941,
29946,
14943,
1495,
13,
13,
18121,
353,
23255,
29888,
9216,
29918,
21319,
29888,
9216,
1307,
29889,
657,
29918,
18121,
580,
13,
13,
1753,
1667,
7295,
13,
1678,
13113,
29889,
8551,
29918,
29883,
3791,
29918,
1272,
580,
13,
1678,
13304,
353,
13113,
29889,
657,
29918,
4381,
29918,
21412,
580,
13,
1678,
565,
451,
13304,
29889,
275,
29918,
13519,
287,
29901,
13,
4706,
13304,
29889,
13519,
29918,
265,
580,
13,
1678,
1596,
877,
7974,
292,
363,
4742,
856,
1495,
13,
1678,
1018,
29901,
13,
4706,
13304,
29889,
2962,
29918,
16192,
580,
13,
4706,
4742,
353,
13113,
29889,
2886,
29918,
10141,
29898,
5509,
29918,
29884,
29884,
4841,
11759,
11282,
17923,
1001,
9047,
2965,
29918,
6304,
19059,
29918,
29965,
11150,
2314,
13,
4706,
565,
4742,
338,
6213,
29901,
13,
9651,
12020,
24875,
2392,
877,
17776,
304,
1284,
4742,
29991,
1495,
13,
4706,
1683,
29901,
13,
9651,
1596,
29898,
10141,
29897,
13,
9651,
1596,
877,
10141,
29901,
426,
29900,
29913,
4286,
4830,
29898,
10141,
29889,
978,
876,
13,
9651,
1596,
877,
333,
29901,
426,
29900,
29913,
4286,
4830,
29898,
10141,
29889,
333,
876,
13,
1678,
7146,
29901,
13,
4706,
13304,
29889,
9847,
29918,
16192,
580,
13,
1678,
1596,
877,
17918,
292,
304,
4742,
856,
1495,
13,
1678,
4742,
29889,
6915,
580,
13,
1678,
1018,
29901,
13,
4706,
1596,
877,
4205,
11911,
292,
5786,
856,
1495,
13,
4706,
4742,
29889,
2218,
11911,
4197,
11282,
17923,
1001,
9047,
2965,
29918,
6304,
19059,
29918,
29965,
11150,
1402,
518,
11282,
17923,
1001,
9047,
2965,
29918,
14573,
29918,
29965,
11150,
2314,
13,
4706,
2669,
353,
4742,
29889,
2886,
29918,
5509,
29898,
11282,
17923,
1001,
9047,
2965,
29918,
6304,
19059,
29918,
29965,
11150,
29897,
13,
4706,
1596,
877,
5509,
318,
5416,
29901,
426,
29900,
29913,
4286,
4830,
29898,
5509,
29889,
25118,
876,
13,
4706,
848,
353,
2669,
29889,
2886,
29918,
18609,
4695,
29898,
11282,
17923,
1001,
9047,
2965,
29918,
14573,
29918,
29965,
11150,
29897,
13,
4706,
1596,
877,
18609,
4695,
318,
5416,
29901,
426,
29900,
29913,
4286,
4830,
29898,
1272,
29889,
25118,
876,
13,
4706,
1596,
877,
29956,
768,
292,
3630,
636,
1495,
13,
4706,
24512,
353,
6262,
29898,
3881,
29898,
29896,
29953,
876,
13,
4706,
24512,
353,
289,
12764,
29916,
29955,
29955,
29905,
29916,
29953,
29896,
29905,
29916,
29953,
29923,
29905,
29916,
29953,
29955,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
29900,
29900,
29905,
29916,
29900,
29890,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29923,
29896,
29905,
29916,
29900,
29907,
29905,
29916,
29900,
29953,
29905,
29916,
29896,
29955,
29905,
29916,
29906,
29928,
29905,
29916,
29906,
29941,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
29916,
1725,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
1725,
29905,
21791,
29953,
29905,
21791,
29953,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
1725,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
1725,
29905,
21791,
29953,
29905,
21791,
29900,
29905,
21791,
29900,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
29916,
1725,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
21791,
29953,
29905,
29916,
617,
29905,
29916,
29881,
29947,
29905,
24660,
29900,
29905,
29916,
29881,
29947,
29905,
29916,
617,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29955,
29883,
29905,
29916,
29953,
29883,
29905,
29916,
29953,
29883,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
29955,
29883,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29953,
29883,
29905,
29916,
29955,
29947,
29905,
29916,
29955,
29900,
29905,
29916,
29953,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
24660,
29947,
29905,
29916,
346,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
21791,
29953,
29905,
21791,
29953,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
346,
29905,
24660,
29947,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29941,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
24512,
353,
289,
12764,
29916,
1725,
29905,
21791,
29900,
29905,
21791,
29900,
29905,
29916,
1725,
29905,
21791,
29900,
29905,
21791,
29900,
29905,
21791,
29900,
29905,
29916,
1725,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29915,
13,
4706,
848,
29889,
3539,
29918,
1767,
29898,
5824,
29897,
13,
4706,
931,
29889,
17059,
29898,
29941,
29897,
13,
4706,
1596,
877,
29956,
768,
292,
2309,
29889,
1495,
13,
1678,
7146,
29901,
13,
4706,
4742,
29889,
2218,
6915,
580,
13,
13,
18121,
29889,
24926,
580,
13,
18121,
29889,
3389,
29918,
3396,
7888,
29918,
2541,
29898,
3396,
29897,
13,
13,
2
] |
isimip_qc/exceptions.py | rouxter/isimip-qc | 4 | 124618 | class FileWarning(Exception):
def __init__(self, file, message, *args, **kwargs):
file.warn(message, *args, **kwargs)
super().__init__(message % args)
class FileError(Exception):
def __init__(self, file, message, *args, **kwargs):
file.error(message, *args, **kwargs)
super().__init__(message % args)
class FileCritical(Exception):
def __init__(self, file, message, *args, **kwargs):
file.critical(message, *args, **kwargs)
super().__init__(message % args)
| [
1,
770,
3497,
22709,
29898,
2451,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
934,
29892,
2643,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
934,
29889,
25442,
29898,
4906,
29892,
334,
5085,
29892,
3579,
19290,
29897,
13,
4706,
2428,
2141,
1649,
2344,
12035,
4906,
1273,
6389,
29897,
13,
13,
13,
1990,
3497,
2392,
29898,
2451,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
934,
29892,
2643,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
934,
29889,
2704,
29898,
4906,
29892,
334,
5085,
29892,
3579,
19290,
29897,
13,
4706,
2428,
2141,
1649,
2344,
12035,
4906,
1273,
6389,
29897,
13,
13,
13,
1990,
3497,
29907,
768,
936,
29898,
2451,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
934,
29892,
2643,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
934,
29889,
9695,
936,
29898,
4906,
29892,
334,
5085,
29892,
3579,
19290,
29897,
13,
4706,
2428,
2141,
1649,
2344,
12035,
4906,
1273,
6389,
29897,
13,
2
] |
src/Step5-extract-votes-for-categories-having-them-all.py | YossiCohen/Cross-Domain-Transfer-Learning-RecSys | 3 | 127866 | import csv
import time
import os
import pandas as pd
DATA_ROOT = "C:\\RS\\Amazon\\All\\"
MINIMUM_X_CATEGORIES_FILENAME = 'minimum_2_Categories.csv'
# MINIMUM_X_CATEGORIES_FILENAME = 'minimum_2_196k.csv'
SOURCE_RATING_FILES_TO_USE = ['ratings_Movies_and_TV.csv','ratings_CDs_and_Vinyl.csv']
TARGET_RATING_FILE = 'ratings_Toys_and_Games.csv'
##Items that untouched by users with both catogories will be ignored in both categories
timestamp = time.strftime('%y%m%d%H%M%S')
for category_filename in SOURCE_RATING_FILES_TO_USE:
big_table = pd.read_csv(os.path.join(DATA_ROOT, MINIMUM_X_CATEGORIES_FILENAME), index_col=['user_id'], usecols=['user_id', category_filename, TARGET_RATING_FILE])
out_filename = os.path.join(DATA_ROOT, timestamp + category_filename + '_FILTERED_BY_' + TARGET_RATING_FILE)
with open(out_filename, 'w', newline='', encoding='utf8') as filtered_ratings:
writer = csv.writer(filtered_ratings, delimiter=',', lineterminator='\n')
cat_file = open(os.path.join(DATA_ROOT, category_filename), 'rt')
try:
cat_file_reader = csv.reader(cat_file)
for row in cat_file_reader:
if row[0] in big_table.index:
if big_table.get_value(row[0],TARGET_RATING_FILE) != 0 and big_table.get_value(row[0],category_filename) !=0:
# print(row, big_table.get_value(row[0],TARGET_RATING_FILE), big_table.get_value(row[0],category_filename)) #TBD - Many more
writer.writerow(row)
filtered_ratings.flush()
finally:
cat_file.close()
out_filename2 = os.path.join(DATA_ROOT, timestamp + TARGET_RATING_FILE+ '_FILTERED_BY_' + category_filename )
with open(out_filename2, 'w', newline='', encoding='utf8') as filtered_ratings:
writer = csv.writer(filtered_ratings, delimiter=',', lineterminator='\n')
cat_file = open(os.path.join(DATA_ROOT, TARGET_RATING_FILE), 'rt')
try:
cat_file_reader = csv.reader(cat_file)
for row in cat_file_reader:
if row[0] in big_table.index:
if big_table.get_value(row[0],TARGET_RATING_FILE) != 0 and big_table.get_value(row[0],category_filename) !=0:
# print(row, big_table.get_value(row[0],TARGET_RATING_FILE), big_table.get_value(row[0],category_filename)) #TBD - Many more
writer.writerow(row)
filtered_ratings.flush()
finally:
cat_file.close()
| [
1,
1053,
11799,
13,
5215,
931,
13,
5215,
2897,
13,
13,
5215,
11701,
408,
10518,
13,
13,
14573,
29918,
21289,
353,
376,
29907,
22298,
12445,
1966,
29909,
655,
6626,
1966,
3596,
1966,
29908,
13,
16173,
7833,
5005,
29918,
29990,
29918,
29907,
3040,
29954,
1955,
29059,
29918,
7724,
5813,
353,
525,
1195,
12539,
29918,
29906,
29918,
29907,
14404,
29889,
7638,
29915,
13,
29937,
341,
1177,
7833,
5005,
29918,
29990,
29918,
29907,
3040,
29954,
1955,
29059,
29918,
7724,
5813,
353,
525,
1195,
12539,
29918,
29906,
29918,
29896,
29929,
29953,
29895,
29889,
7638,
29915,
13,
27839,
4741,
29918,
29934,
1299,
4214,
29918,
24483,
29918,
4986,
29918,
17171,
353,
6024,
3605,
886,
29918,
29924,
586,
583,
29918,
392,
29918,
8050,
29889,
7638,
3788,
3605,
886,
29918,
6530,
29879,
29918,
392,
29918,
29963,
262,
2904,
29889,
7638,
2033,
13,
29911,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
353,
525,
3605,
886,
29918,
1762,
952,
29918,
392,
29918,
29954,
1280,
29889,
7638,
29915,
13,
13,
13,
2277,
6913,
393,
443,
16747,
287,
491,
4160,
411,
1716,
6635,
468,
3842,
674,
367,
17262,
297,
1716,
13997,
13,
16394,
353,
931,
29889,
710,
615,
603,
877,
29995,
29891,
29995,
29885,
29995,
29881,
29995,
29950,
29995,
29924,
29995,
29903,
1495,
13,
13,
13,
1454,
7663,
29918,
9507,
297,
7791,
4574,
4741,
29918,
29934,
1299,
4214,
29918,
24483,
29918,
4986,
29918,
17171,
29901,
13,
1678,
4802,
29918,
2371,
353,
10518,
29889,
949,
29918,
7638,
29898,
359,
29889,
2084,
29889,
7122,
29898,
14573,
29918,
21289,
29892,
341,
1177,
7833,
5005,
29918,
29990,
29918,
29907,
3040,
29954,
1955,
29059,
29918,
7724,
5813,
511,
2380,
29918,
1054,
29922,
1839,
1792,
29918,
333,
7464,
671,
22724,
29922,
1839,
1792,
29918,
333,
742,
7663,
29918,
9507,
29892,
323,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
2314,
13,
13,
1678,
714,
29918,
9507,
353,
2897,
29889,
2084,
29889,
7122,
29898,
14573,
29918,
21289,
29892,
14334,
718,
7663,
29918,
9507,
718,
22868,
3738,
29931,
4945,
3352,
29918,
22716,
29918,
29915,
718,
323,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
29897,
13,
1678,
411,
1722,
29898,
449,
29918,
9507,
29892,
525,
29893,
742,
25899,
2433,
742,
8025,
2433,
9420,
29947,
1495,
408,
22289,
29918,
3605,
886,
29901,
13,
4706,
9227,
353,
11799,
29889,
13236,
29898,
4572,
287,
29918,
3605,
886,
29892,
28552,
29922,
742,
742,
6276,
300,
837,
262,
1061,
2433,
29905,
29876,
1495,
13,
4706,
6635,
29918,
1445,
353,
1722,
29898,
359,
29889,
2084,
29889,
7122,
29898,
14573,
29918,
21289,
29892,
7663,
29918,
9507,
511,
525,
2273,
1495,
13,
4706,
1018,
29901,
13,
9651,
6635,
29918,
1445,
29918,
16950,
353,
11799,
29889,
16950,
29898,
4117,
29918,
1445,
29897,
13,
9651,
363,
1948,
297,
6635,
29918,
1445,
29918,
16950,
29901,
13,
18884,
565,
1948,
29961,
29900,
29962,
297,
4802,
29918,
2371,
29889,
2248,
29901,
13,
462,
1678,
565,
4802,
29918,
2371,
29889,
657,
29918,
1767,
29898,
798,
29961,
29900,
1402,
29911,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
29897,
2804,
29871,
29900,
322,
4802,
29918,
2371,
29889,
657,
29918,
1767,
29898,
798,
29961,
29900,
1402,
7320,
29918,
9507,
29897,
2804,
29900,
29901,
13,
462,
4706,
396,
1596,
29898,
798,
29892,
4802,
29918,
2371,
29889,
657,
29918,
1767,
29898,
798,
29961,
29900,
1402,
29911,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
511,
4802,
29918,
2371,
29889,
657,
29918,
1767,
29898,
798,
29961,
29900,
1402,
7320,
29918,
9507,
876,
396,
24895,
29928,
448,
9267,
901,
13,
462,
4706,
9227,
29889,
13236,
340,
29898,
798,
29897,
13,
9651,
22289,
29918,
3605,
886,
29889,
23126,
580,
13,
4706,
7146,
29901,
13,
9651,
6635,
29918,
1445,
29889,
5358,
580,
13,
13,
1678,
714,
29918,
9507,
29906,
353,
2897,
29889,
2084,
29889,
7122,
29898,
14573,
29918,
21289,
29892,
14334,
718,
323,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
29974,
22868,
3738,
29931,
4945,
3352,
29918,
22716,
29918,
29915,
718,
7663,
29918,
9507,
1723,
13,
1678,
411,
1722,
29898,
449,
29918,
9507,
29906,
29892,
525,
29893,
742,
25899,
2433,
742,
8025,
2433,
9420,
29947,
1495,
408,
22289,
29918,
3605,
886,
29901,
13,
4706,
9227,
353,
11799,
29889,
13236,
29898,
4572,
287,
29918,
3605,
886,
29892,
28552,
29922,
742,
742,
6276,
300,
837,
262,
1061,
2433,
29905,
29876,
1495,
13,
4706,
6635,
29918,
1445,
353,
1722,
29898,
359,
29889,
2084,
29889,
7122,
29898,
14573,
29918,
21289,
29892,
323,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
511,
525,
2273,
1495,
13,
4706,
1018,
29901,
13,
9651,
6635,
29918,
1445,
29918,
16950,
353,
11799,
29889,
16950,
29898,
4117,
29918,
1445,
29897,
13,
9651,
363,
1948,
297,
6635,
29918,
1445,
29918,
16950,
29901,
13,
18884,
565,
1948,
29961,
29900,
29962,
297,
4802,
29918,
2371,
29889,
2248,
29901,
13,
462,
1678,
565,
4802,
29918,
2371,
29889,
657,
29918,
1767,
29898,
798,
29961,
29900,
1402,
29911,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
29897,
2804,
29871,
29900,
322,
4802,
29918,
2371,
29889,
657,
29918,
1767,
29898,
798,
29961,
29900,
1402,
7320,
29918,
9507,
29897,
2804,
29900,
29901,
13,
462,
4706,
396,
1596,
29898,
798,
29892,
4802,
29918,
2371,
29889,
657,
29918,
1767,
29898,
798,
29961,
29900,
1402,
29911,
1718,
7194,
29918,
29934,
1299,
4214,
29918,
7724,
511,
4802,
29918,
2371,
29889,
657,
29918,
1767,
29898,
798,
29961,
29900,
1402,
7320,
29918,
9507,
876,
396,
24895,
29928,
448,
9267,
901,
13,
462,
4706,
9227,
29889,
13236,
340,
29898,
798,
29897,
13,
9651,
22289,
29918,
3605,
886,
29889,
23126,
580,
13,
4706,
7146,
29901,
13,
9651,
6635,
29918,
1445,
29889,
5358,
580,
13,
2
] |
src/pengbot/adapters/facebook/adapter.py | mariocesar/pengbot | 1 | 27520 | <reponame>mariocesar/pengbot<filename>src/pengbot/adapters/facebook/adapter.py
import json
from pengbot.utils import isbound
from .api import Facebook
from ..web import WebAdapter
class Adapter(WebAdapter):
_fbapi = None
@property
def fbapi(self):
if not self._fbapi:
self._fbapi = Facebook(self)
return self._fbapi
@WebAdapter.route('GET', r'/')
def handle_verify_token(self, start_response, request):
verify_token = request.GET.get('hub.verify_token', None)
challenge = request.GET.get('hub.challenge', None)
if verify_token == self.context.verify_token:
start_response('200 OK', [('Content-Type', 'text/plain')])
return challenge
else:
start_response('401 OK', [('Content-Type', 'text/plain')])
return "Invalid Token"
@WebAdapter.route('POST', r'/')
def handle_payload(self, start_response, request):
payload = json.loads(request.body.decode())
assert 'object' in payload, 'Missing object type in payload: %r' % payload
assert payload['object'] == 'page', 'Unknown object type: %r' % payload['object']
assert 'entry' in payload, 'Missing entry'
for entry in payload['entry']:
try:
assert 'id' in entry, 'Missing id in entry: %r' % entry
assert 'time' in entry, 'Missing timestamp in entry: %r' % entry
self.handle_message(entry)
except Exception as err:
start_response('500 OK', [('Content-Type', 'text/plain')])
return '%r' % err
else:
start_response('200 OK', [('Content-Type', 'text/plain')])
return ''
def say(self, recipient, text):
response = self.fbapi.send_message({
'recipient': {'id': recipient},
'message': {'text': text}}
)
self.logger.debug(response.content)
| [
1,
529,
276,
1112,
420,
29958,
29885,
1306,
542,
26892,
29914,
29886,
996,
7451,
29966,
9507,
29958,
4351,
29914,
29886,
996,
7451,
29914,
328,
481,
2153,
29914,
15445,
29914,
21412,
29889,
2272,
13,
5215,
4390,
13,
13,
3166,
282,
996,
7451,
29889,
13239,
1053,
338,
9917,
13,
13,
3166,
869,
2754,
1053,
13327,
13,
3166,
6317,
2676,
1053,
2563,
6168,
13,
13,
13,
1990,
2087,
3314,
29898,
3609,
6168,
1125,
13,
1678,
903,
14943,
2754,
353,
6213,
13,
13,
1678,
732,
6799,
13,
1678,
822,
285,
29890,
2754,
29898,
1311,
1125,
13,
4706,
565,
451,
1583,
3032,
14943,
2754,
29901,
13,
9651,
1583,
3032,
14943,
2754,
353,
13327,
29898,
1311,
29897,
13,
4706,
736,
1583,
3032,
14943,
2754,
13,
13,
1678,
732,
3609,
6168,
29889,
13134,
877,
7194,
742,
364,
29915,
29914,
1495,
13,
1678,
822,
4386,
29918,
27902,
29918,
6979,
29898,
1311,
29892,
1369,
29918,
5327,
29892,
2009,
1125,
13,
13,
4706,
11539,
29918,
6979,
353,
2009,
29889,
7194,
29889,
657,
877,
29882,
431,
29889,
27902,
29918,
6979,
742,
6213,
29897,
13,
4706,
18766,
353,
2009,
29889,
7194,
29889,
657,
877,
29882,
431,
29889,
305,
11768,
742,
6213,
29897,
13,
13,
4706,
565,
11539,
29918,
6979,
1275,
1583,
29889,
4703,
29889,
27902,
29918,
6979,
29901,
13,
9651,
1369,
29918,
5327,
877,
29906,
29900,
29900,
9280,
742,
518,
877,
3916,
29899,
1542,
742,
525,
726,
29914,
24595,
1495,
2314,
13,
9651,
736,
18766,
13,
4706,
1683,
29901,
13,
9651,
1369,
29918,
5327,
877,
29946,
29900,
29896,
9280,
742,
518,
877,
3916,
29899,
1542,
742,
525,
726,
29914,
24595,
1495,
2314,
13,
9651,
736,
376,
13919,
25159,
29908,
13,
13,
1678,
732,
3609,
6168,
29889,
13134,
877,
5438,
742,
364,
29915,
29914,
1495,
13,
1678,
822,
4386,
29918,
23813,
29898,
1311,
29892,
1369,
29918,
5327,
29892,
2009,
1125,
13,
4706,
20092,
353,
4390,
29889,
18132,
29898,
3827,
29889,
2587,
29889,
13808,
3101,
13,
13,
4706,
4974,
525,
3318,
29915,
297,
20092,
29892,
525,
18552,
292,
1203,
1134,
297,
20092,
29901,
1273,
29878,
29915,
1273,
20092,
13,
4706,
4974,
20092,
1839,
3318,
2033,
1275,
525,
3488,
742,
525,
14148,
1203,
1134,
29901,
1273,
29878,
29915,
1273,
20092,
1839,
3318,
2033,
13,
4706,
4974,
525,
8269,
29915,
297,
20092,
29892,
525,
18552,
292,
6251,
29915,
13,
13,
4706,
363,
6251,
297,
20092,
1839,
8269,
2033,
29901,
13,
9651,
1018,
29901,
13,
18884,
4974,
525,
333,
29915,
297,
6251,
29892,
525,
18552,
292,
1178,
297,
6251,
29901,
1273,
29878,
29915,
1273,
6251,
13,
18884,
4974,
525,
2230,
29915,
297,
6251,
29892,
525,
18552,
292,
14334,
297,
6251,
29901,
1273,
29878,
29915,
1273,
6251,
13,
13,
18884,
1583,
29889,
8411,
29918,
4906,
29898,
8269,
29897,
13,
9651,
5174,
8960,
408,
4589,
29901,
13,
18884,
1369,
29918,
5327,
877,
29945,
29900,
29900,
9280,
742,
518,
877,
3916,
29899,
1542,
742,
525,
726,
29914,
24595,
1495,
2314,
13,
18884,
736,
14210,
29878,
29915,
1273,
4589,
13,
9651,
1683,
29901,
13,
18884,
1369,
29918,
5327,
877,
29906,
29900,
29900,
9280,
742,
518,
877,
3916,
29899,
1542,
742,
525,
726,
29914,
24595,
1495,
2314,
13,
18884,
736,
6629,
13,
13,
1678,
822,
1827,
29898,
1311,
29892,
23957,
993,
29892,
1426,
1125,
13,
4706,
2933,
353,
1583,
29889,
14943,
2754,
29889,
6717,
29918,
4906,
3319,
13,
9651,
525,
4361,
29886,
993,
2396,
11117,
333,
2396,
23957,
993,
1118,
13,
9651,
525,
4906,
2396,
11117,
726,
2396,
1426,
930,
13,
4706,
1723,
13,
13,
4706,
1583,
29889,
21707,
29889,
8382,
29898,
5327,
29889,
3051,
29897,
13,
2
] |
index.py | PrinceRaiN/Rain-player | 0 | 171572 |
import sys
import os
from os.path import expanduser
from PyQt5.QtWidgets import *
from PyQt5.QtMultimedia import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
import time
scriptDir = os.path.dirname(os.path.realpath(__file__))
SCREEN,_ = loadUiType(os.path.join(os.path.dirname(__file__),"first.ui"))
PLAYER,_ = loadUiType(os.path.join(os.path.dirname(__file__),"player.ui"))
class Threading(QThread):
mysignal = pyqtSignal(int)
def __init__(self, parent=None):
QThread.__init__(self, parent)
def run(self):
time.sleep(4)
self.mysignal.emit(1)
class ThreadAnimation(QThread):
myAnimation = pyqtSignal(int)
def __init__(self, parent=None):
QThread.__init__(self, parent)
self.runs = True
def run(self):
while self.runs:
time.sleep(2)
self.myAnimation.emit(1)
def stop(self):
self.runs = False
class Screen(QMainWindow, SCREEN):
def __init__(self, parent=None):
super(Screen, self).__init__(parent)
QMainWindow.__init__(self)
self.setWindowIcon(QIcon(scriptDir + os.path.sep + 'icons/rain.png'))
self.setupUi(self)
pitmap = QPixmap("icons/rain.png")
self.image.setPixmap(pitmap)
thread = Threading(self)
thread.mysignal.connect(self.onTimeEnd)
thread.start()
@pyqtSlot(int)
def onTimeEnd(self, value):
self.hide()
window = Player(self)
window.show()
class Player(QMainWindow, PLAYER):
def __init__(self, parent=None):
super(Player, self).__init__(parent)
self.setupUi(self)
self.setWindowIcon(QIcon(scriptDir + os.path.sep + 'icons/rain.png'))
self.play_icon = QIcon("icons/play.png")
self.next_icon = QIcon("icons/next.png")
self.back_icon = QIcon("icons/back.png")
self.pause_icon = QIcon("icons/pause.png")
self.stop_icon = QIcon("icons/stop.png")
self.volume_icon = QIcon("icons/volume.png")
self.mute_icon = QIcon("icons/mute.png")
self.default_image = QPixmap("icons/rain.png")
self.currentPlaylist = QMediaPlaylist()
self.icon_button()
self.setAcceptDrops(True)
self.sound = True
self.music = {}
self.player = QMediaPlayer(self)
self.player.mediaStatusChanged.connect(self.mediaStatusChange)
self.player.positionChanged.connect(self.positionChanged)
self.player.durationChanged.connect(self.durationChanged)
self.musicList.itemClicked.connect(self.on_item_clicked)
self._buffer = QBuffer()
self.musicProgress.setValue(0)
self.musicProgress.setRange(0, 0)
self.musicProgress.sliderMoved.connect(self.onSliderMoved)
self.musicVolume.valueChanged.connect(self.onVolumeChange)
self.player.setPlaylist(self.currentPlaylist)
self.volumeProgress.clicked.connect(self.onSoundClicked)
self.stopButton.clicked.connect(self.onStopClicked)
self.nextButton.clicked.connect(self.onNextClicked)
self.backButton.clicked.connect(self.onBackClicked)
self.playButton.clicked.connect(self.onPlayClicked)
self.pauseButton.clicked.connect(self.onPauseClicked)
self.musicVolume.setValue(50)
self.index = 0
self.item = ""
self.animation = ThreadAnimation(self)
self.animation.myAnimation.connect(self.startAni)
self.animation.start()
self.aniType = "left"
self.actionExit_3.triggered.connect(self.exit_gui)
def onVolumeChange(self, value):
self.player.setVolume(value)
def onNextClicked(self):
self.player.playlist().next()
index = self.player.playlist().currentIndex()
try:
self.musicList.item(index).setSelected(True)
except:
self.player.playlist().setCurrentIndex(0)
self.musicList.item(0).setSelected(True)
self.player.play()
def onBackClicked(self):
self.player.playlist().previous()
index = self.player.playlist().currentIndex()
try:
self.musicList.item(index).setSelected(True)
except:
self.player.playlist().setCurrentIndex(0)
self.musicList.item(0).setSelected(True)
self.player.play()
def onPlayClicked(self):
if self.currentPlaylist.mediaCount() == 0:
self.openFile()
return
if self.player.state() == QMediaPlayer.PausedState:
self.player.play()
elif self.player.state() == QMediaPlayer.StoppedState:
self.player.play()
elif self.player.state() == QMediaPlayer.PlayingState:
return
else:
self.player.play()
def openFile(self):
fileChoosen = QFileDialog.getOpenFileUrl(self, 'Open Music File', expanduser('~'),'Audio (*.mp3 *.ogg *.wav)','*.mp3 *.ogg *.wav')
if fileChoosen != None:
self.musicList.addItem(fileChoosen[0].fileName())
self.currentPlaylist.addMedia(QMediaContent(fileChoosen[0]))
def onPauseClicked(self):
if self.player.state() == QMediaPlayer.PausedState:
self.player.play()
elif self.player.state() == QMediaPlayer.StoppedState:
self.player.play()
else:
self.player.pause()
def onStopClicked(self):
if self.player.state() == QMediaPlayer.PlayingState:
self.player.stop()
elif self.player.state() == QMediaPlayer.PausedState:
self.player.stop()
def onSoundClicked(self):
if self.sound:
self.volumeProgress.setIcon(self.mute_icon)
self.player.setVolume(0)
self.sound = False
else:
self.sound = True
self.player.setVolume(self.musicVolume.value())
self.volumeProgress.setIcon(self.volume_icon)
def durationChanged(self, duration):
self.musicProgress.setRange(0, duration)
def onSliderMoved(self, position):
sender = self.sender()
if isinstance(sender, QSlider):
if self.player.isSeekable():
self.player.setPosition(position)
def on_item_clicked(self, item):
data = self.musicList.selectedIndexes()[0]
index = data.row()
self.playMusic(index=index)
def playMusic(self, index=0):
self.player.setPlaylist(self.currentPlaylist)
self.player.playlist().setCurrentIndex(index)
self.player.play()
self.player.setVolume(self.musicVolume.value())
def onVolumeChange(self, value):
if value > 50:
self.player.setVolume(value+1)
else:
self.player.setVolume(value)
def positionChanged(self, position):
tm = '%d:%02d'%(int(position/60000),int((position/1000)%60))
self.startTime.setText(tm)
self.musicProgress.setValue(position)
def mediaStatusChange(self):
durationT = self.player.duration()
tm = "%d:%02d"%(int(durationT/60000),int((durationT/1000)%60))
self.musicTime.setText(tm)
index = self.player.playlist().currentIndex()
try:
self.musicList.item(index).setSelected(True)
except:
pass
def icon_button(self):
self.playButton.setIcon(self.play_icon)
self.pauseButton.setIcon(self.pause_icon)
self.nextButton.setIcon(self.next_icon)
self.backButton.setIcon(self.back_icon)
self.stopButton.setIcon(self.stop_icon)
self.image.setPixmap(self.default_image)
self.image.setAlignment(Qt.AlignCenter)
self.volumeProgress.setIcon(self.volume_icon)
def dropEvent(self, e):
for x in e.mimeData().urls():
mp3 = x.toString()
name = x.fileName()
path = x.toLocalFile()
self.musicList.addItem(name)
self.currentPlaylist.addMedia(QMediaContent(QUrl.fromLocalFile(path)))
def dragEnterEvent(self, e):
for x in e.mimeData().urls():
mp3 = x.toString()
if mp3.endswith(".mp3") or mp3.endswith(".MP3"):
e.accept()
else:
e.ignore()
def closeEvent(self, event):
reply = QMessageBox.question(self,'Exit?','Are you sure you want to close?',QMessageBox.Yes|QMessageBox.No,QMessageBox.Yes)
if reply == QMessageBox.Yes :
qApp.quit()
else :
try:
event.ignore()
except AttributeError:
pass
@pyqtSlot(int)
def startAni(self, i):
anim = QPropertyAnimation(self.image, b"geometry")
anim.setDuration(30)
if self.aniType == "left":
anim.setStartValue(QRect(180, 100, 411, 271))
anim.setEndValue(QRect(190, 110, 420, 280))
self.aniType = "right"
elif self.aniType == "right":
anim.setStartValue(QRect(190, 110, 420, 280))
anim.setEndValue(QRect(180, 100, 411, 271))
self.aniType = "dort"
elif self.aniType == "dort":
anim.setStartValue(QRect(180, 100, 411, 271))
anim.setEndValue(QRect(122, 302, 395, 261))
self.aniType = "left"
anim.start()
def exit_gui(self):
app.exit()
if __name__ == "__main__":
app=QApplication(sys.argv)
window = Screen()
window.show()
app.exec_()
| [
1,
6756,
13,
5215,
10876,
30004,
13,
5215,
2897,
30004,
13,
3166,
2897,
29889,
2084,
1053,
7985,
1792,
30004,
13,
3166,
10772,
17303,
29945,
29889,
17303,
8801,
29879,
1053,
334,
30004,
13,
3166,
10772,
17303,
29945,
29889,
17303,
11930,
1053,
334,
30004,
13,
3166,
10772,
17303,
29945,
29889,
17303,
9203,
1053,
334,
30004,
13,
3166,
10772,
17303,
29945,
29889,
17303,
28707,
1053,
334,
30004,
13,
3166,
10772,
17303,
29945,
29889,
29884,
293,
1053,
2254,
29965,
29875,
1542,
30004,
13,
5215,
931,
30004,
13,
30004,
13,
2154,
9170,
353,
2897,
29889,
2084,
29889,
25721,
29898,
359,
29889,
2084,
29889,
6370,
2084,
22168,
1445,
1649,
876,
30004,
13,
7187,
1525,
1430,
29892,
29918,
353,
2254,
29965,
29875,
1542,
29898,
359,
29889,
2084,
29889,
7122,
29898,
359,
29889,
2084,
29889,
25721,
22168,
1445,
1649,
511,
29908,
4102,
29889,
1481,
5783,
30004,
13,
29925,
18799,
1001,
29892,
29918,
353,
2254,
29965,
29875,
1542,
29898,
359,
29889,
2084,
29889,
7122,
29898,
359,
29889,
2084,
29889,
25721,
22168,
1445,
1649,
511,
29908,
9106,
29889,
1481,
5783,
30004,
13,
30004,
13,
1990,
10480,
292,
29898,
29984,
4899,
1125,
30004,
13,
1678,
590,
25436,
353,
11451,
17915,
10140,
284,
29898,
524,
8443,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3847,
29922,
8516,
1125,
30004,
13,
4706,
660,
4899,
17255,
2344,
12035,
1311,
29892,
3847,
8443,
13,
30004,
13,
1678,
822,
1065,
29898,
1311,
1125,
30004,
13,
4706,
931,
29889,
17059,
29898,
29946,
8443,
13,
4706,
1583,
29889,
5781,
647,
284,
29889,
21976,
29898,
29896,
8443,
13,
30004,
13,
1990,
10480,
13579,
29898,
29984,
4899,
1125,
30004,
13,
1678,
590,
13579,
353,
11451,
17915,
10140,
284,
29898,
524,
8443,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3847,
29922,
8516,
1125,
30004,
13,
4706,
660,
4899,
17255,
2344,
12035,
1311,
29892,
3847,
8443,
13,
4706,
1583,
29889,
3389,
29879,
353,
5852,
30004,
13,
1678,
822,
1065,
29898,
1311,
1125,
30004,
13,
4706,
1550,
1583,
29889,
3389,
29879,
29901,
30004,
13,
9651,
931,
29889,
17059,
29898,
29906,
8443,
13,
9651,
1583,
29889,
1357,
13579,
29889,
21976,
29898,
29896,
8443,
13,
1678,
822,
5040,
29898,
1311,
1125,
30004,
13,
4706,
1583,
29889,
3389,
29879,
353,
7700,
30004,
13,
4706,
6756,
13,
1990,
22666,
29898,
29984,
6330,
5907,
29892,
12314,
1525,
1430,
1125,
30004,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3847,
29922,
8516,
1125,
30004,
13,
4706,
2428,
29898,
11357,
29892,
1583,
467,
1649,
2344,
12035,
3560,
8443,
13,
4706,
660,
6330,
5907,
17255,
2344,
12035,
1311,
8443,
13,
4706,
1583,
29889,
842,
5907,
12492,
29898,
29984,
12492,
29898,
2154,
9170,
718,
2897,
29889,
2084,
29889,
19570,
718,
525,
27078,
29914,
6038,
29889,
2732,
8785,
30004,
13,
4706,
1583,
29889,
14669,
29965,
29875,
29898,
1311,
8443,
13,
4706,
282,
10137,
353,
660,
29925,
861,
1958,
703,
27078,
29914,
6038,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
3027,
29889,
842,
29925,
861,
1958,
29898,
29886,
10137,
8443,
13,
4706,
3244,
353,
10480,
292,
29898,
1311,
8443,
13,
4706,
3244,
29889,
5781,
647,
284,
29889,
6915,
29898,
1311,
29889,
265,
2481,
5044,
8443,
13,
4706,
3244,
29889,
2962,
26471,
13,
4706,
6756,
13,
1678,
732,
2272,
17915,
29903,
8276,
29898,
524,
8443,
13,
1678,
822,
373,
2481,
5044,
29898,
1311,
29892,
995,
1125,
30004,
13,
4706,
1583,
29889,
11458,
26471,
13,
4706,
3474,
353,
14574,
29898,
1311,
8443,
13,
4706,
3474,
29889,
4294,
26471,
13,
30004,
13,
4706,
6756,
13,
1990,
14574,
29898,
29984,
6330,
5907,
29892,
349,
18799,
1001,
1125,
30004,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3847,
29922,
8516,
1125,
30004,
13,
4706,
2428,
29898,
9075,
29892,
1583,
467,
1649,
2344,
12035,
3560,
8443,
13,
4706,
1583,
29889,
14669,
29965,
29875,
29898,
1311,
8443,
13,
4706,
1583,
29889,
842,
5907,
12492,
29898,
29984,
12492,
29898,
2154,
9170,
718,
2897,
29889,
2084,
29889,
19570,
718,
525,
27078,
29914,
6038,
29889,
2732,
8785,
30004,
13,
4706,
1583,
29889,
1456,
29918,
4144,
353,
660,
12492,
703,
27078,
29914,
1456,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
4622,
29918,
4144,
353,
660,
12492,
703,
27078,
29914,
4622,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
1627,
29918,
4144,
353,
660,
12492,
703,
27078,
29914,
1627,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
29886,
1071,
29918,
4144,
353,
660,
12492,
703,
27078,
29914,
29886,
1071,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
9847,
29918,
4144,
353,
660,
12492,
703,
27078,
29914,
9847,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
24623,
29918,
4144,
353,
660,
12492,
703,
27078,
29914,
24623,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
29885,
1082,
29918,
4144,
353,
660,
12492,
703,
27078,
29914,
29885,
1082,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
4381,
29918,
3027,
353,
660,
29925,
861,
1958,
703,
27078,
29914,
6038,
29889,
2732,
1159,
30004,
13,
4706,
1583,
29889,
3784,
13454,
1761,
353,
660,
10572,
13454,
1761,
26471,
13,
4706,
1583,
29889,
4144,
29918,
3092,
26471,
13,
4706,
1583,
29889,
842,
23965,
29928,
307,
567,
29898,
5574,
8443,
13,
4706,
1583,
29889,
29802,
353,
5852,
30004,
13,
4706,
1583,
29889,
23596,
353,
6571,
30004,
13,
30004,
13,
4706,
1583,
29889,
9106,
353,
660,
10572,
9075,
29898,
1311,
8443,
13,
4706,
1583,
29889,
9106,
29889,
9799,
5709,
7590,
29889,
6915,
29898,
1311,
29889,
9799,
5709,
7277,
8443,
13,
4706,
1583,
29889,
9106,
29889,
3283,
7590,
29889,
6915,
29898,
1311,
29889,
3283,
7590,
8443,
13,
4706,
1583,
29889,
9106,
29889,
19708,
7590,
29889,
6915,
29898,
1311,
29889,
19708,
7590,
8443,
13,
4706,
1583,
29889,
23596,
1293,
29889,
667,
4164,
287,
29889,
6915,
29898,
1311,
29889,
265,
29918,
667,
29918,
3808,
287,
8443,
13,
4706,
1583,
3032,
9040,
353,
660,
7701,
26471,
13,
4706,
1583,
29889,
23596,
14470,
29889,
842,
1917,
29898,
29900,
8443,
13,
4706,
1583,
29889,
23596,
14470,
29889,
842,
6069,
29898,
29900,
29892,
29871,
29900,
8443,
13,
4706,
1583,
29889,
23596,
14470,
29889,
23165,
29924,
8238,
29889,
6915,
29898,
1311,
29889,
265,
16973,
1241,
29924,
8238,
8443,
13,
4706,
1583,
29889,
23596,
24679,
29889,
1767,
7590,
29889,
6915,
29898,
1311,
29889,
265,
24679,
7277,
8443,
13,
4706,
1583,
29889,
9106,
29889,
842,
13454,
1761,
29898,
1311,
29889,
3784,
13454,
1761,
8443,
13,
4706,
1583,
29889,
24623,
14470,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
265,
29456,
4164,
287,
8443,
13,
4706,
1583,
29889,
9847,
3125,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
265,
16329,
4164,
287,
8443,
13,
4706,
1583,
29889,
4622,
3125,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
265,
9190,
4164,
287,
8443,
13,
4706,
1583,
29889,
1627,
3125,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
265,
5841,
4164,
287,
8443,
13,
4706,
1583,
29889,
1456,
3125,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
265,
13454,
4164,
287,
8443,
13,
4706,
1583,
29889,
29886,
1071,
3125,
29889,
3808,
287,
29889,
6915,
29898,
1311,
29889,
265,
29925,
1071,
4164,
287,
8443,
13,
4706,
1583,
29889,
23596,
24679,
29889,
842,
1917,
29898,
29945,
29900,
8443,
13,
4706,
1583,
29889,
2248,
353,
29871,
29900,
30004,
13,
4706,
1583,
29889,
667,
353,
5124,
30004,
13,
4706,
1583,
29889,
18962,
353,
10480,
13579,
29898,
1311,
8443,
13,
4706,
1583,
29889,
18962,
29889,
1357,
13579,
29889,
6915,
29898,
1311,
29889,
2962,
29909,
1240,
8443,
13,
4706,
1583,
29889,
18962,
29889,
2962,
26471,
13,
4706,
1583,
29889,
3270,
1542,
353,
376,
1563,
19451,
13,
4706,
1583,
29889,
2467,
24365,
29918,
29941,
29889,
21001,
287,
29889,
6915,
29898,
1311,
29889,
13322,
29918,
23569,
8443,
13,
30004,
13,
30004,
13,
30004,
13,
30004,
13,
30004,
13,
1678,
822,
373,
24679,
7277,
29898,
1311,
29892,
995,
1125,
30004,
13,
4706,
1583,
29889,
9106,
29889,
842,
24679,
29898,
1767,
8443,
13,
1678,
822,
373,
9190,
4164,
287,
29898,
1311,
1125,
30004,
13,
4706,
1583,
29889,
9106,
29889,
1456,
1761,
2141,
4622,
26471,
13,
4706,
2380,
353,
1583,
29889,
9106,
29889,
1456,
1761,
2141,
3784,
3220,
26471,
13,
4706,
1018,
29901,
30004,
13,
9651,
1583,
29889,
23596,
1293,
29889,
667,
29898,
2248,
467,
842,
8592,
29898,
5574,
8443,
13,
4706,
5174,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
1456,
1761,
2141,
842,
7583,
3220,
29898,
29900,
8443,
13,
9651,
1583,
29889,
23596,
1293,
29889,
667,
29898,
29900,
467,
842,
8592,
29898,
5574,
8443,
13,
9651,
1583,
29889,
9106,
29889,
1456,
26471,
13,
1678,
822,
373,
5841,
4164,
287,
29898,
1311,
1125,
30004,
13,
4706,
1583,
29889,
9106,
29889,
1456,
1761,
2141,
24957,
26471,
13,
4706,
2380,
353,
1583,
29889,
9106,
29889,
1456,
1761,
2141,
3784,
3220,
26471,
13,
4706,
1018,
29901,
30004,
13,
9651,
1583,
29889,
23596,
1293,
29889,
667,
29898,
2248,
467,
842,
8592,
29898,
5574,
8443,
13,
4706,
5174,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
1456,
1761,
2141,
842,
7583,
3220,
29898,
29900,
8443,
13,
9651,
1583,
29889,
23596,
1293,
29889,
667,
29898,
29900,
467,
842,
8592,
29898,
5574,
8443,
13,
9651,
1583,
29889,
9106,
29889,
1456,
26471,
13,
30004,
13,
1678,
822,
373,
13454,
4164,
287,
29898,
1311,
1125,
30004,
13,
4706,
565,
1583,
29889,
3784,
13454,
1761,
29889,
9799,
3981,
580,
1275,
29871,
29900,
29901,
30004,
13,
9651,
1583,
29889,
3150,
2283,
26471,
13,
9651,
736,
30004,
13,
4706,
565,
1583,
29889,
9106,
29889,
3859,
580,
1275,
660,
10572,
9075,
29889,
29925,
15244,
2792,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
1456,
26471,
13,
4706,
25342,
1583,
29889,
9106,
29889,
3859,
580,
1275,
660,
10572,
9075,
29889,
20754,
2986,
2792,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
1456,
26471,
13,
4706,
25342,
1583,
29889,
9106,
29889,
3859,
580,
1275,
660,
10572,
9075,
29889,
13454,
292,
2792,
29901,
30004,
13,
9651,
736,
30004,
13,
4706,
1683,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
1456,
26471,
13,
9651,
6756,
13,
1678,
822,
1722,
2283,
29898,
1311,
1125,
30004,
13,
4706,
934,
15954,
7749,
353,
660,
2283,
7647,
29889,
657,
6585,
2283,
5983,
29898,
1311,
29892,
525,
6585,
6125,
3497,
742,
7985,
1792,
877,
30022,
5477,
29915,
17111,
3070,
29889,
1526,
29941,
20611,
468,
29887,
20611,
29893,
485,
29897,
3788,
10521,
1526,
29941,
20611,
468,
29887,
20611,
29893,
485,
1495,
30004,
13,
4706,
565,
934,
15954,
7749,
2804,
6213,
29901,
30004,
13,
9651,
1583,
29889,
23596,
1293,
29889,
1202,
2001,
29898,
1445,
15954,
7749,
29961,
29900,
1822,
28926,
3101,
30004,
13,
9651,
1583,
29889,
3784,
13454,
1761,
29889,
1202,
10572,
29898,
29984,
10572,
3916,
29898,
1445,
15954,
7749,
29961,
29900,
12622,
30004,
13,
9651,
6756,
13,
1678,
822,
373,
29925,
1071,
4164,
287,
29898,
1311,
1125,
30004,
13,
4706,
565,
1583,
29889,
9106,
29889,
3859,
580,
1275,
660,
10572,
9075,
29889,
29925,
15244,
2792,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
1456,
26471,
13,
4706,
25342,
1583,
29889,
9106,
29889,
3859,
580,
1275,
660,
10572,
9075,
29889,
20754,
2986,
2792,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
1456,
26471,
13,
4706,
1683,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
29886,
1071,
26471,
13,
1678,
6756,
13,
1678,
822,
373,
16329,
4164,
287,
29898,
1311,
1125,
30004,
13,
4706,
565,
1583,
29889,
9106,
29889,
3859,
580,
1275,
660,
10572,
9075,
29889,
13454,
292,
2792,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
9847,
26471,
13,
4706,
25342,
1583,
29889,
9106,
29889,
3859,
580,
1275,
660,
10572,
9075,
29889,
29925,
15244,
2792,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
9847,
26471,
13,
4706,
6756,
13,
1678,
822,
373,
29456,
4164,
287,
29898,
1311,
1125,
30004,
13,
4706,
565,
1583,
29889,
29802,
29901,
30004,
13,
9651,
1583,
29889,
24623,
14470,
29889,
842,
12492,
29898,
1311,
29889,
29885,
1082,
29918,
4144,
8443,
13,
9651,
1583,
29889,
9106,
29889,
842,
24679,
29898,
29900,
8443,
13,
9651,
1583,
29889,
29802,
353,
7700,
30004,
13,
4706,
1683,
29901,
30004,
13,
9651,
1583,
29889,
29802,
353,
5852,
30004,
13,
9651,
1583,
29889,
9106,
29889,
842,
24679,
29898,
1311,
29889,
23596,
24679,
29889,
1767,
3101,
30004,
13,
9651,
1583,
29889,
24623,
14470,
29889,
842,
12492,
29898,
1311,
29889,
24623,
29918,
4144,
8443,
13,
4706,
6756,
13,
1678,
822,
14385,
7590,
29898,
1311,
29892,
14385,
1125,
30004,
13,
4706,
1583,
29889,
23596,
14470,
29889,
842,
6069,
29898,
29900,
29892,
14385,
8443,
13,
4706,
6756,
13,
1678,
822,
373,
16973,
1241,
29924,
8238,
29898,
1311,
29892,
2602,
1125,
30004,
13,
4706,
10004,
353,
1583,
29889,
15452,
26471,
13,
4706,
565,
338,
8758,
29898,
15452,
29892,
660,
16973,
1241,
1125,
30004,
13,
9651,
565,
1583,
29889,
9106,
29889,
275,
2008,
1416,
519,
7295,
30004,
13,
18884,
1583,
29889,
9106,
29889,
842,
8003,
29898,
3283,
8443,
13,
18884,
6756,
13,
1678,
822,
373,
29918,
667,
29918,
3808,
287,
29898,
1311,
29892,
2944,
1125,
30004,
13,
4706,
848,
353,
1583,
29889,
23596,
1293,
29889,
8391,
3220,
267,
580,
29961,
29900,
29962,
30004,
13,
4706,
2380,
353,
848,
29889,
798,
26471,
13,
4706,
1583,
29889,
1456,
21238,
29898,
2248,
29922,
2248,
8443,
13,
4706,
6756,
13,
1678,
822,
1708,
21238,
29898,
1311,
29892,
2380,
29922,
29900,
1125,
30004,
13,
4706,
1583,
29889,
9106,
29889,
842,
13454,
1761,
29898,
1311,
29889,
3784,
13454,
1761,
8443,
13,
4706,
1583,
29889,
9106,
29889,
1456,
1761,
2141,
842,
7583,
3220,
29898,
2248,
8443,
13,
4706,
1583,
29889,
9106,
29889,
1456,
26471,
13,
4706,
1583,
29889,
9106,
29889,
842,
24679,
29898,
1311,
29889,
23596,
24679,
29889,
1767,
3101,
30004,
13,
4706,
6756,
13,
1678,
6756,
13,
1678,
822,
373,
24679,
7277,
29898,
1311,
29892,
995,
1125,
30004,
13,
4706,
565,
995,
1405,
29871,
29945,
29900,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
842,
24679,
29898,
1767,
29974,
29896,
8443,
13,
4706,
1683,
29901,
30004,
13,
9651,
1583,
29889,
9106,
29889,
842,
24679,
29898,
1767,
8443,
13,
4706,
6756,
13,
1678,
822,
2602,
7590,
29898,
1311,
29892,
2602,
1125,
30004,
13,
4706,
27702,
353,
14210,
29881,
16664,
29900,
29906,
29881,
29915,
29995,
29898,
524,
29898,
3283,
29914,
29953,
29900,
29900,
29900,
29900,
511,
524,
3552,
3283,
29914,
29896,
29900,
29900,
29900,
29897,
29995,
29953,
29900,
876,
30004,
13,
4706,
1583,
29889,
2962,
2481,
29889,
12038,
29898,
18276,
8443,
13,
4706,
1583,
29889,
23596,
14470,
29889,
842,
1917,
29898,
3283,
8443,
13,
18884,
6756,
13,
1678,
822,
5745,
5709,
7277,
29898,
1311,
1125,
30004,
13,
4706,
14385,
29911,
353,
1583,
29889,
9106,
29889,
19708,
26471,
13,
4706,
27702,
353,
11860,
29881,
16664,
29900,
29906,
29881,
29908,
29995,
29898,
524,
29898,
19708,
29911,
29914,
29953,
29900,
29900,
29900,
29900,
511,
524,
3552,
19708,
29911,
29914,
29896,
29900,
29900,
29900,
29897,
29995,
29953,
29900,
876,
30004,
13,
4706,
1583,
29889,
23596,
2481,
29889,
12038,
29898,
18276,
8443,
13,
4706,
2380,
353,
1583,
29889,
9106,
29889,
1456,
1761,
2141,
3784,
3220,
26471,
13,
4706,
1018,
29901,
30004,
13,
9651,
1583,
29889,
23596,
1293,
29889,
667,
29898,
2248,
467,
842,
8592,
29898,
5574,
8443,
13,
4706,
5174,
29901,
30004,
13,
9651,
1209,
30004,
13,
4706,
6756,
13,
1678,
822,
9849,
29918,
3092,
29898,
1311,
1125,
30004,
13,
4706,
1583,
29889,
1456,
3125,
29889,
842,
12492,
29898,
1311,
29889,
1456,
29918,
4144,
8443,
13,
4706,
1583,
29889,
29886,
1071,
3125,
29889,
842,
12492,
29898,
1311,
29889,
29886,
1071,
29918,
4144,
8443,
13,
4706,
1583,
29889,
4622,
3125,
29889,
842,
12492,
29898,
1311,
29889,
4622,
29918,
4144,
8443,
13,
4706,
1583,
29889,
1627,
3125,
29889,
842,
12492,
29898,
1311,
29889,
1627,
29918,
4144,
8443,
13,
4706,
1583,
29889,
9847,
3125,
29889,
842,
12492,
29898,
1311,
29889,
9847,
29918,
4144,
8443,
13,
4706,
1583,
29889,
3027,
29889,
842,
29925,
861,
1958,
29898,
1311,
29889,
4381,
29918,
3027,
8443,
13,
4706,
1583,
29889,
3027,
29889,
842,
14658,
29898,
17303,
29889,
2499,
647,
13409,
8443,
13,
4706,
1583,
29889,
24623,
14470,
29889,
842,
12492,
29898,
1311,
29889,
24623,
29918,
4144,
8443,
13,
30004,
13,
30004,
13,
1678,
822,
5768,
2624,
29898,
1311,
29892,
321,
1125,
30004,
13,
4706,
363,
921,
297,
321,
29889,
29885,
603,
1469,
2141,
26045,
7295,
30004,
13,
9651,
22326,
29941,
353,
921,
29889,
7711,
26471,
13,
9651,
1024,
353,
921,
29889,
28926,
26471,
13,
9651,
2224,
353,
921,
29889,
517,
7717,
2283,
26471,
13,
9651,
1583,
29889,
23596,
1293,
29889,
1202,
2001,
29898,
978,
8443,
13,
9651,
1583,
29889,
3784,
13454,
1761,
29889,
1202,
10572,
29898,
29984,
10572,
3916,
29898,
29984,
5983,
29889,
3166,
7717,
2283,
29898,
2084,
4961,
30004,
13,
9651,
6756,
13,
1678,
822,
8338,
10399,
2624,
29898,
1311,
29892,
321,
1125,
30004,
13,
4706,
363,
921,
297,
321,
29889,
29885,
603,
1469,
2141,
26045,
7295,
30004,
13,
9651,
22326,
29941,
353,
921,
29889,
7711,
26471,
13,
9651,
565,
22326,
29941,
29889,
1975,
2541,
17350,
1526,
29941,
1159,
470,
22326,
29941,
29889,
1975,
2541,
17350,
3580,
29941,
29908,
1125,
30004,
13,
18884,
321,
29889,
16044,
26471,
13,
9651,
1683,
29901,
30004,
13,
18884,
321,
29889,
17281,
26471,
13,
18884,
6756,
13,
1678,
822,
3802,
2624,
29898,
1311,
29892,
1741,
1125,
30004,
13,
4706,
8908,
353,
660,
3728,
3313,
29889,
12470,
29898,
1311,
5501,
24365,
29973,
3788,
17506,
366,
1854,
366,
864,
304,
3802,
29973,
742,
29984,
3728,
3313,
29889,
8241,
29989,
29984,
3728,
3313,
29889,
3782,
29892,
29984,
3728,
3313,
29889,
8241,
8443,
13,
4706,
565,
8908,
1275,
660,
3728,
3313,
29889,
8241,
584,
30004,
13,
9651,
3855,
2052,
29889,
28358,
26471,
13,
4706,
1683,
584,
30004,
13,
9651,
1018,
29901,
30004,
13,
18884,
1741,
29889,
17281,
26471,
13,
9651,
5174,
23833,
2392,
29901,
30004,
13,
18884,
1209,
30004,
13,
9651,
6756,
13,
1678,
732,
2272,
17915,
29903,
8276,
29898,
524,
8443,
13,
1678,
822,
1369,
29909,
1240,
29898,
1311,
29892,
474,
1125,
30004,
13,
4706,
3778,
353,
660,
4854,
13579,
29898,
1311,
29889,
3027,
29892,
289,
29908,
19156,
1159,
30004,
13,
4706,
3778,
29889,
842,
18984,
29898,
29941,
29900,
8443,
13,
4706,
565,
1583,
29889,
3270,
1542,
1275,
376,
1563,
1115,
30004,
13,
9651,
3778,
29889,
842,
4763,
1917,
29898,
29984,
7364,
29898,
29896,
29947,
29900,
29892,
29871,
29896,
29900,
29900,
29892,
29871,
29946,
29896,
29896,
29892,
29871,
29906,
29955,
29896,
876,
30004,
13,
9651,
3778,
29889,
842,
5044,
1917,
29898,
29984,
7364,
29898,
29896,
29929,
29900,
29892,
29871,
29896,
29896,
29900,
29892,
29871,
29946,
29906,
29900,
29892,
29871,
29906,
29947,
29900,
876,
30004,
13,
9651,
1583,
29889,
3270,
1542,
353,
376,
1266,
19451,
13,
4706,
25342,
1583,
29889,
3270,
1542,
1275,
376,
1266,
1115,
30004,
13,
9651,
3778,
29889,
842,
4763,
1917,
29898,
29984,
7364,
29898,
29896,
29929,
29900,
29892,
29871,
29896,
29896,
29900,
29892,
29871,
29946,
29906,
29900,
29892,
29871,
29906,
29947,
29900,
876,
30004,
13,
9651,
3778,
29889,
842,
5044,
1917,
29898,
29984,
7364,
29898,
29896,
29947,
29900,
29892,
29871,
29896,
29900,
29900,
29892,
29871,
29946,
29896,
29896,
29892,
29871,
29906,
29955,
29896,
876,
30004,
13,
9651,
1583,
29889,
3270,
1542,
353,
376,
29881,
441,
19451,
13,
4706,
25342,
1583,
29889,
3270,
1542,
1275,
376,
29881,
441,
1115,
30004,
13,
9651,
3778,
29889,
842,
4763,
1917,
29898,
29984,
7364,
29898,
29896,
29947,
29900,
29892,
29871,
29896,
29900,
29900,
29892,
29871,
29946,
29896,
29896,
29892,
29871,
29906,
29955,
29896,
876,
30004,
13,
9651,
3778,
29889,
842,
5044,
1917,
29898,
29984,
7364,
29898,
29896,
29906,
29906,
29892,
29871,
29941,
29900,
29906,
29892,
29871,
29941,
29929,
29945,
29892,
29871,
29906,
29953,
29896,
876,
30004,
13,
9651,
1583,
29889,
3270,
1542,
353,
376,
1563,
19451,
13,
4706,
3778,
29889,
2962,
26471,
13,
30004,
13,
30004,
13,
30004,
13,
1678,
822,
6876,
29918,
23569,
29898,
1311,
1125,
30004,
13,
4706,
623,
29889,
13322,
26471,
13,
30004,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
30004,
13,
1678,
623,
29922,
29984,
4873,
29898,
9675,
29889,
19218,
8443,
13,
1678,
3474,
353,
22666,
26471,
13,
1678,
3474,
29889,
4294,
26471,
13,
1678,
623,
29889,
4258,
29918,
26471,
13,
2
] |
editor/scheduler/__init__.py | iamsayem/smart-editor | 0 | 30851 | """
Created by Sayem on 14 March, 2021
All rights reserved. Copyright © 2020.
"""
from .celery import app as celery_app
__author__ = "Sayem"
__all__ = ["celery_app"]
| [
1,
9995,
13,
1678,
6760,
630,
491,
14891,
331,
373,
29871,
29896,
29946,
4779,
29892,
29871,
29906,
29900,
29906,
29896,
13,
1678,
2178,
10462,
21676,
29889,
14187,
1266,
29871,
30211,
29871,
29906,
29900,
29906,
29900,
29889,
13,
15945,
29908,
13,
3166,
869,
2242,
708,
1053,
623,
408,
6432,
708,
29918,
932,
13,
1649,
8921,
1649,
353,
376,
29903,
388,
331,
29908,
13,
13,
1649,
497,
1649,
353,
6796,
2242,
708,
29918,
932,
3108,
13,
2
] |
main/migrations/0028_auto_20170103_1634.py | jsmnbom/htxaarhuslan | 1 | 14708 | <gh_stars>1-10
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2017-01-03 15:34
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('main', '0027_auto_20170103_1130'),
]
operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255, verbose_name='navn')),
('url', models.URLField(blank=True, help_text='Valgfri. Link som kan klikkes på kalenderen.', max_length=255, null=True, verbose_name='link')),
('start', models.DateTimeField(null=True, verbose_name='Start')),
('end', models.DateTimeField(blank=True, null=True, verbose_name='Slut')),
('lan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.Lan', verbose_name='lan')),
],
options={
'verbose_name_plural': 'begivenheder',
'verbose_name': 'begivenhed',
},
),
migrations.AlterField(
model_name='tournament',
name='end',
field=models.DateTimeField(blank=True, null=True, verbose_name='Slut'),
),
]
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
29937,
3251,
630,
491,
15337,
29871,
29896,
29889,
29896,
29900,
29889,
29906,
373,
29871,
29906,
29900,
29896,
29955,
29899,
29900,
29896,
29899,
29900,
29941,
29871,
29896,
29945,
29901,
29941,
29946,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
3166,
9557,
29889,
2585,
1053,
9725,
800,
29892,
4733,
13,
5215,
9557,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
13,
13,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
13,
13,
1678,
9962,
353,
518,
13,
4706,
6702,
3396,
742,
525,
29900,
29900,
29906,
29955,
29918,
6921,
29918,
29906,
29900,
29896,
29955,
29900,
29896,
29900,
29941,
29918,
29896,
29896,
29941,
29900,
5477,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
2624,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
29892,
26952,
29918,
978,
2433,
6654,
29876,
1495,
511,
13,
18884,
6702,
2271,
742,
4733,
29889,
4219,
3073,
29898,
19465,
29922,
5574,
29892,
1371,
29918,
726,
2433,
1440,
29887,
7932,
29889,
6645,
1047,
6841,
413,
5081,
10794,
3548,
25364,
1581,
264,
29889,
742,
4236,
29918,
2848,
29922,
29906,
29945,
29945,
29892,
1870,
29922,
5574,
29892,
26952,
29918,
978,
2433,
2324,
1495,
511,
13,
18884,
6702,
2962,
742,
4733,
29889,
11384,
3073,
29898,
4304,
29922,
5574,
29892,
26952,
29918,
978,
2433,
4763,
1495,
511,
13,
18884,
6702,
355,
742,
4733,
29889,
11384,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
29892,
26952,
29918,
978,
2433,
16973,
329,
1495,
511,
13,
18884,
6702,
6468,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
3396,
29889,
29931,
273,
742,
26952,
29918,
978,
2433,
6468,
1495,
511,
13,
9651,
21251,
13,
9651,
3987,
3790,
13,
18884,
525,
369,
15828,
29918,
978,
29918,
572,
3631,
2396,
525,
28060,
5428,
29882,
2447,
742,
13,
18884,
525,
369,
15828,
29918,
978,
2396,
525,
28060,
5428,
17143,
742,
13,
9651,
2981,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2499,
357,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
29873,
2905,
1166,
742,
13,
9651,
1024,
2433,
355,
742,
13,
9651,
1746,
29922,
9794,
29889,
11384,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
29892,
26952,
29918,
978,
2433,
16973,
329,
5477,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
main/migration_types.py | sotheara-leang/xFlask | 2 | 159130 | from xflask.sqlalchemy import StringEnum, IntegerEnum
from xflask.type import *
from main.type.edu_level import *
| [
1,
515,
921,
1579,
1278,
29889,
2850,
284,
305,
6764,
1053,
1714,
16854,
29892,
8102,
16854,
13,
3166,
921,
1579,
1278,
29889,
1853,
1053,
334,
13,
3166,
1667,
29889,
1853,
29889,
6085,
29918,
5563,
1053,
334,
13,
2
] |
src/tests/models/test_model.py | ChristianHinge/geometric | 3 | 150443 | import pytest
import torch
from torch_geometric.data import Batch
from src.models.model import GCN
@pytest.fixture
def model():
return GCN(2, 2)
class TestGCN:
def test_model_structure(self, model):
assert model.conv_layers[0].in_channels == 2
assert model.conv_layers[0].out_channels == 64
assert model.conv_layers[1].in_channels == 64
assert model.conv_layers[1].out_channels == 64
assert model.conv_layers[2].in_channels == 64
assert model.conv_layers[2].out_channels == 64
assert model.linear.in_features == 64
assert model.linear.out_features == 2
def test_forward_correct(self, model):
x = torch.zeros([1, 2])
edge_index = torch.zeros([2, 2], dtype=torch.long)
batch = torch.zeros([1, 1], dtype=torch.int64)
data = Batch(x=x, edge_index=edge_index, batch=batch)
output = model.forward(data.x, data.edge_index, data.batch)
assert output.shape == torch.Size([1, 2])
def test_forward_empty(self, model):
data = Batch()
with pytest.raises(TypeError):
model.forward(data.x, data.edge_index, data.batch)
def test_forward_wrong_shape(self, model):
x = torch.zeros([1, 2, 3])
edge_index = torch.zeros([2], dtype=torch.long)
batch = torch.zeros([1, 1, 1, 1], dtype=torch.int64)
data = Batch(x=x, edge_index=edge_index, batch=batch)
with pytest.raises(IndexError):
model.forward(data.x, data.edge_index, data.batch)
| [
1,
1053,
11451,
1688,
13,
5215,
4842,
305,
13,
3166,
4842,
305,
29918,
479,
14066,
29889,
1272,
1053,
350,
905,
13,
13,
3166,
4765,
29889,
9794,
29889,
4299,
1053,
402,
13778,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
1904,
7295,
13,
1678,
736,
402,
13778,
29898,
29906,
29892,
29871,
29906,
29897,
13,
13,
13,
1990,
4321,
8766,
29940,
29901,
13,
1678,
822,
1243,
29918,
4299,
29918,
23905,
29898,
1311,
29892,
1904,
1125,
13,
4706,
4974,
1904,
29889,
20580,
29918,
29277,
29961,
29900,
1822,
262,
29918,
305,
12629,
1275,
29871,
29906,
13,
4706,
4974,
1904,
29889,
20580,
29918,
29277,
29961,
29900,
1822,
449,
29918,
305,
12629,
1275,
29871,
29953,
29946,
13,
4706,
4974,
1904,
29889,
20580,
29918,
29277,
29961,
29896,
1822,
262,
29918,
305,
12629,
1275,
29871,
29953,
29946,
13,
4706,
4974,
1904,
29889,
20580,
29918,
29277,
29961,
29896,
1822,
449,
29918,
305,
12629,
1275,
29871,
29953,
29946,
13,
4706,
4974,
1904,
29889,
20580,
29918,
29277,
29961,
29906,
1822,
262,
29918,
305,
12629,
1275,
29871,
29953,
29946,
13,
4706,
4974,
1904,
29889,
20580,
29918,
29277,
29961,
29906,
1822,
449,
29918,
305,
12629,
1275,
29871,
29953,
29946,
13,
4706,
4974,
1904,
29889,
10660,
29889,
262,
29918,
22100,
1275,
29871,
29953,
29946,
13,
4706,
4974,
1904,
29889,
10660,
29889,
449,
29918,
22100,
1275,
29871,
29906,
13,
13,
1678,
822,
1243,
29918,
11333,
29918,
15728,
29898,
1311,
29892,
1904,
1125,
13,
4706,
921,
353,
4842,
305,
29889,
3298,
359,
4197,
29896,
29892,
29871,
29906,
2314,
13,
4706,
7636,
29918,
2248,
353,
4842,
305,
29889,
3298,
359,
4197,
29906,
29892,
29871,
29906,
1402,
26688,
29922,
7345,
305,
29889,
5426,
29897,
13,
4706,
9853,
353,
4842,
305,
29889,
3298,
359,
4197,
29896,
29892,
29871,
29896,
1402,
26688,
29922,
7345,
305,
29889,
524,
29953,
29946,
29897,
13,
4706,
848,
353,
350,
905,
29898,
29916,
29922,
29916,
29892,
7636,
29918,
2248,
29922,
12864,
29918,
2248,
29892,
9853,
29922,
16175,
29897,
13,
13,
4706,
1962,
353,
1904,
29889,
11333,
29898,
1272,
29889,
29916,
29892,
848,
29889,
12864,
29918,
2248,
29892,
848,
29889,
16175,
29897,
13,
13,
4706,
4974,
1962,
29889,
12181,
1275,
4842,
305,
29889,
3505,
4197,
29896,
29892,
29871,
29906,
2314,
13,
13,
1678,
822,
1243,
29918,
11333,
29918,
6310,
29898,
1311,
29892,
1904,
1125,
13,
4706,
848,
353,
350,
905,
580,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1542,
2392,
1125,
13,
9651,
1904,
29889,
11333,
29898,
1272,
29889,
29916,
29892,
848,
29889,
12864,
29918,
2248,
29892,
848,
29889,
16175,
29897,
13,
13,
1678,
822,
1243,
29918,
11333,
29918,
15866,
549,
29918,
12181,
29898,
1311,
29892,
1904,
1125,
13,
4706,
921,
353,
4842,
305,
29889,
3298,
359,
4197,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
2314,
13,
4706,
7636,
29918,
2248,
353,
4842,
305,
29889,
3298,
359,
4197,
29906,
1402,
26688,
29922,
7345,
305,
29889,
5426,
29897,
13,
4706,
9853,
353,
4842,
305,
29889,
3298,
359,
4197,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
1402,
26688,
29922,
7345,
305,
29889,
524,
29953,
29946,
29897,
13,
4706,
848,
353,
350,
905,
29898,
29916,
29922,
29916,
29892,
7636,
29918,
2248,
29922,
12864,
29918,
2248,
29892,
9853,
29922,
16175,
29897,
13,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
3220,
2392,
1125,
13,
9651,
1904,
29889,
11333,
29898,
1272,
29889,
29916,
29892,
848,
29889,
12864,
29918,
2248,
29892,
848,
29889,
16175,
29897,
13,
2
] |
rotkehlchen/tests/exchanges/test_independentreserve.py | rotkehlchenio/rotkehlchen | 137 | 41963 | <reponame>rotkehlchenio/rotkehlchen<gh_stars>100-1000
import warnings as test_warnings
from unittest.mock import patch
import pytest
from rotkehlchen.accounting.structures.balance import Balance
from rotkehlchen.constants.assets import A_AUD, A_ETC, A_ETH
from rotkehlchen.errors.asset import UnknownAsset
from rotkehlchen.exchanges.data_structures import Location, Trade, TradeType
from rotkehlchen.exchanges.independentreserve import (
IR_TO_WORLD,
Independentreserve,
independentreserve_asset,
)
from rotkehlchen.fval import FVal
from rotkehlchen.tests.utils.mock import MockResponse
def test_location():
exchange = Independentreserve('independentreserve1', 'a', b'a', object(), object())
assert exchange.location == Location.INDEPENDENTRESERVE
assert exchange.name == 'independentreserve1'
def test_assets_are_known():
exchange = Independentreserve('independentreserve1', 'a', b'a', object(), object())
response = exchange._api_query('get', 'Public', 'GetValidPrimaryCurrencyCodes')
for currency in response:
try:
independentreserve_asset(currency)
except UnknownAsset:
test_warnings.warn(UserWarning(
f'Found unknown primary asset {currency} in IndependentReserve. '
f'Support for it has to be added',
))
response = exchange._api_query('get', 'Public', 'GetValidSecondaryCurrencyCodes')
for currency in response:
try:
independentreserve_asset(currency)
except UnknownAsset:
test_warnings.warn(UserWarning(
f'Found unknown secondary asset {currency} in IndependentReserve. '
f'Support for it has to be added',
))
@pytest.mark.parametrize('should_mock_current_price_queries', [True])
def test_query_balances(
function_scope_independentreserve,
inquirer, # pylint: disable=unused-argument
):
"""Test all balances returned by IndependentReserve are proccessed properly"""
exchange = function_scope_independentreserve
def mock_api_return(method, url, **kwargs): # pylint: disable=unused-argument
assert method == 'post'
response = """[{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Aud", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Usd", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Nzd", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Sgd", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Xbt", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Eth", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Xrp", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Ada", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Dot", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Uni", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Link", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Usdt", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Usdc", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Bch", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Ltc", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Mkr", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Dai", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Comp", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Snx", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Grt", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Eos", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Xlm", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Etc", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Bat", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Pmgt", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Yfi", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Aave", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Zrx", "TotalBalance": 150.55},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 150.55, "CurrencyCode": "Omg", "TotalBalance": 150.55}]""" # noqa: E501
return MockResponse(200, response)
with patch.object(exchange.session, 'request', side_effect=mock_api_return):
balances, msg = exchange.query_balances()
assert msg == ''
assets_seen = {0}
for asset, balance in balances.items():
assert asset in IR_TO_WORLD.values()
assert asset not in assets_seen
assets_seen.add(asset)
assert balance.amount == FVal('150.55')
@pytest.mark.parametrize('should_mock_current_price_queries', [True])
def test_query_some_balances(
function_scope_independentreserve,
inquirer, # pylint: disable=unused-argument
):
"""Just like test_query_balances but make sure 0 balances are skipped"""
exchange = function_scope_independentreserve
def mock_api_return(method, url, **kwargs): # pylint: disable=unused-argument
assert method == 'post'
response = """[{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 1.2, "CurrencyCode": "Aud", "TotalBalance": 2.5},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Usd", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Nzd", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Sgd", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Xbt", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Eth", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Xrp", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Ada", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Dot", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Uni", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Link", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Usdt", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Usdc", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Bch", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Ltc", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Mkr", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Dai", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Comp", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Snx", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Grt", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Eos", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Xlm", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Etc", "TotalBalance": 100.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Bat", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Pmgt", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Yfi", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Aave", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Zrx", "TotalBalance": 0.0},
{"AccountGuid": "foo", "AccountStatus": "Active", "AvailableBalance": 0.0, "CurrencyCode": "Omg", "TotalBalance": 0.0}]""" # noqa: E501
return MockResponse(200, response)
with patch.object(exchange.session, 'request', side_effect=mock_api_return):
balances, msg = exchange.query_balances()
assert msg == ''
assert balances == {
A_AUD: Balance(amount=FVal(2.5), usd_value=FVal(3.75)),
A_ETC: Balance(amount=FVal(100), usd_value=FVal(150)),
}
def test_query_trade_history(function_scope_independentreserve):
"""Happy path test for independentreserve trade history querying"""
exchange = function_scope_independentreserve
def mock_api_return(method, url, **kwargs): # pylint: disable=unused-argument
assert method == 'post'
response = """{"Data": [
{"AvgPrice": 603.7,
"CreatedTimestampUtc": "2017-11-22T22:54:40.3249401Z",
"FeePercent": 0.005,
"OrderGuid": "foo1",
"OrderType": "MarketOffer",
"Original": {"Outstanding": 0.0, "Volume": 0.5, "VolumeCurrencyType": "Primary"},
"Outstanding": 0.0,
"Price": null,
"PrimaryCurrencyCode": "Eth",
"SecondaryCurrencyCode": "Aud",
"Status": "Filled",
"Value": 301.85,
"Volume": 0.5
}, {
"AvgPrice": 257.25,
"CreatedTimestampUtc": "2017-07-28T09:39:19.8799244Z",
"FeePercent": 0.005,
"OrderGuid": "foo2",
"OrderType": "MarketBid",
"Original": {"Outstanding": 0.0, "Volume": 2.64117379, "VolumeCurrencyType": "Primary"},
"Outstanding": 0.0,
"Price": null,
"PrimaryCurrencyCode": "Eth",
"SecondaryCurrencyCode": "Aud",
"Status": "Filled",
"Value": 679.44,
"Volume": 2.64117379
}],
"PageSize": 50,
"TotalItems": 2,
"TotalPages": 1}
""" # noqa: E501
return MockResponse(200, response)
with patch.object(exchange.session, 'request', side_effect=mock_api_return):
trades = exchange.query_trade_history(
start_ts=0,
end_ts=1565732120,
only_cache=False,
)
expected_trades = [
Trade(
timestamp=1501234760,
location=Location.INDEPENDENTRESERVE,
base_asset=A_ETH,
quote_asset=A_AUD,
trade_type=TradeType.BUY,
amount=FVal('2.64117379'),
rate=FVal('257.25'),
fee=FVal('0.01320586895'),
fee_currency=A_ETH,
link='foo2',
), Trade(
timestamp=1511391280,
location=Location.INDEPENDENTRESERVE,
base_asset=A_ETH,
quote_asset=A_AUD,
trade_type=TradeType.SELL,
amount=FVal('0.5'),
rate=FVal('603.7'),
fee=FVal('0.0025'),
fee_currency=A_ETH,
link='foo1',
)]
assert trades == expected_trades[::-1]
# TODO: Make a test for asset movements.
# Would need more mocking as it would require mocking of multiple calls
| [
1,
529,
276,
1112,
420,
29958,
5450,
446,
4415,
2724,
601,
29914,
5450,
446,
4415,
2724,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29900,
29899,
29896,
29900,
29900,
29900,
13,
5215,
18116,
408,
1243,
29918,
25442,
886,
13,
3166,
443,
27958,
29889,
17640,
1053,
13261,
13,
13,
5215,
11451,
1688,
13,
13,
3166,
5731,
446,
4415,
2724,
29889,
10149,
292,
29889,
4984,
1973,
29889,
5521,
749,
1053,
7392,
749,
13,
3166,
5731,
446,
4415,
2724,
29889,
3075,
1934,
29889,
16596,
1053,
319,
29918,
29909,
15789,
29892,
319,
29918,
2544,
29907,
29892,
319,
29918,
2544,
29950,
13,
3166,
5731,
446,
4415,
2724,
29889,
12523,
29889,
24129,
1053,
853,
5203,
26405,
13,
3166,
5731,
446,
4415,
2724,
29889,
735,
25990,
29889,
1272,
29918,
4984,
1973,
1053,
17015,
29892,
27226,
29892,
27226,
1542,
13,
3166,
5731,
446,
4415,
2724,
29889,
735,
25990,
29889,
262,
18980,
690,
7143,
1053,
313,
13,
1678,
23292,
29918,
4986,
29918,
11686,
10249,
29892,
13,
1678,
25266,
690,
7143,
29892,
13,
1678,
7417,
690,
7143,
29918,
24129,
29892,
13,
29897,
13,
3166,
5731,
446,
4415,
2724,
29889,
29888,
791,
1053,
383,
1440,
13,
3166,
5731,
446,
4415,
2724,
29889,
21150,
29889,
13239,
29889,
17640,
1053,
26297,
5103,
13,
13,
13,
1753,
1243,
29918,
5479,
7295,
13,
1678,
14523,
353,
25266,
690,
7143,
877,
262,
18980,
690,
7143,
29896,
742,
525,
29874,
742,
289,
29915,
29874,
742,
1203,
3285,
1203,
3101,
13,
1678,
4974,
14523,
29889,
5479,
1275,
17015,
29889,
1177,
2287,
29925,
11794,
3919,
1525,
6304,
12064,
13,
1678,
4974,
14523,
29889,
978,
1275,
525,
262,
18980,
690,
7143,
29896,
29915,
13,
13,
13,
1753,
1243,
29918,
16596,
29918,
598,
29918,
5203,
7295,
13,
1678,
14523,
353,
25266,
690,
7143,
877,
262,
18980,
690,
7143,
29896,
742,
525,
29874,
742,
289,
29915,
29874,
742,
1203,
3285,
1203,
3101,
13,
1678,
2933,
353,
14523,
3032,
2754,
29918,
1972,
877,
657,
742,
525,
19858,
742,
525,
2577,
7211,
26666,
29907,
10880,
29907,
2631,
1495,
13,
1678,
363,
27550,
297,
2933,
29901,
13,
4706,
1018,
29901,
13,
9651,
7417,
690,
7143,
29918,
24129,
29898,
26095,
29897,
13,
4706,
5174,
853,
5203,
26405,
29901,
13,
9651,
1243,
29918,
25442,
886,
29889,
25442,
29898,
2659,
22709,
29898,
13,
18884,
285,
29915,
9692,
9815,
7601,
24342,
426,
26095,
29913,
297,
25266,
1666,
7143,
29889,
525,
13,
18884,
285,
29915,
14039,
363,
372,
756,
304,
367,
2715,
742,
13,
632,
876,
13,
13,
1678,
2933,
353,
14523,
3032,
2754,
29918,
1972,
877,
657,
742,
525,
19858,
742,
525,
2577,
7211,
11863,
653,
29907,
10880,
29907,
2631,
1495,
13,
1678,
363,
27550,
297,
2933,
29901,
13,
4706,
1018,
29901,
13,
9651,
7417,
690,
7143,
29918,
24129,
29898,
26095,
29897,
13,
4706,
5174,
853,
5203,
26405,
29901,
13,
9651,
1243,
29918,
25442,
886,
29889,
25442,
29898,
2659,
22709,
29898,
13,
18884,
285,
29915,
9692,
9815,
16723,
24342,
426,
26095,
29913,
297,
25266,
1666,
7143,
29889,
525,
13,
18884,
285,
29915,
14039,
363,
372,
756,
304,
367,
2715,
742,
13,
632,
876,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
877,
9344,
29918,
17640,
29918,
3784,
29918,
9175,
29918,
339,
6358,
742,
518,
5574,
2314,
13,
1753,
1243,
29918,
1972,
29918,
5521,
2925,
29898,
13,
4706,
740,
29918,
6078,
29918,
262,
18980,
690,
7143,
29892,
13,
4706,
25501,
381,
261,
29892,
29871,
396,
282,
2904,
524,
29901,
11262,
29922,
348,
3880,
29899,
23516,
13,
1125,
13,
1678,
9995,
3057,
599,
6411,
2925,
4133,
491,
25266,
1666,
7143,
526,
410,
1676,
287,
6284,
15945,
29908,
13,
1678,
14523,
353,
740,
29918,
6078,
29918,
262,
18980,
690,
7143,
13,
13,
1678,
822,
11187,
29918,
2754,
29918,
2457,
29898,
5696,
29892,
3142,
29892,
3579,
19290,
1125,
1678,
396,
282,
2904,
524,
29901,
11262,
29922,
348,
3880,
29899,
23516,
13,
4706,
4974,
1158,
1275,
525,
2490,
29915,
13,
4706,
2933,
353,
9995,
29961,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29909,
566,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29965,
4928,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29940,
8849,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29903,
29887,
29881,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29990,
3116,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29923,
386,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29990,
19080,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29909,
1388,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29928,
327,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
8110,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
6595,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29965,
4928,
29873,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29965,
4928,
29883,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29933,
305,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29931,
14246,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29924,
12748,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29928,
1794,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
6843,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29903,
23818,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29954,
2273,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29923,
359,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29990,
21457,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29923,
14246,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29933,
271,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29925,
29885,
4141,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29979,
7241,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29909,
1351,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
29999,
17697,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
29892,
376,
29907,
10880,
3399,
1115,
376,
5673,
29887,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29945,
29900,
29889,
29945,
29945,
6525,
15945,
29908,
29871,
396,
694,
25621,
29901,
382,
29945,
29900,
29896,
13,
4706,
736,
26297,
5103,
29898,
29906,
29900,
29900,
29892,
2933,
29897,
13,
13,
1678,
411,
13261,
29889,
3318,
29898,
6543,
29889,
7924,
29892,
525,
3827,
742,
2625,
29918,
15987,
29922,
17640,
29918,
2754,
29918,
2457,
1125,
13,
4706,
6411,
2925,
29892,
10191,
353,
14523,
29889,
1972,
29918,
5521,
2925,
580,
13,
13,
1678,
4974,
10191,
1275,
6629,
13,
1678,
21608,
29918,
28026,
353,
426,
29900,
29913,
13,
1678,
363,
24342,
29892,
17346,
297,
6411,
2925,
29889,
7076,
7295,
13,
4706,
4974,
24342,
297,
23292,
29918,
4986,
29918,
11686,
10249,
29889,
5975,
580,
13,
4706,
4974,
24342,
451,
297,
21608,
29918,
28026,
13,
4706,
21608,
29918,
28026,
29889,
1202,
29898,
24129,
29897,
13,
4706,
4974,
17346,
29889,
14506,
1275,
383,
1440,
877,
29896,
29945,
29900,
29889,
29945,
29945,
1495,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
877,
9344,
29918,
17640,
29918,
3784,
29918,
9175,
29918,
339,
6358,
742,
518,
5574,
2314,
13,
1753,
1243,
29918,
1972,
29918,
5372,
29918,
5521,
2925,
29898,
13,
4706,
740,
29918,
6078,
29918,
262,
18980,
690,
7143,
29892,
13,
4706,
25501,
381,
261,
29892,
29871,
396,
282,
2904,
524,
29901,
11262,
29922,
348,
3880,
29899,
23516,
13,
1125,
13,
1678,
9995,
14084,
763,
1243,
29918,
1972,
29918,
5521,
2925,
541,
1207,
1854,
29871,
29900,
6411,
2925,
526,
14993,
2986,
15945,
29908,
13,
1678,
14523,
353,
740,
29918,
6078,
29918,
262,
18980,
690,
7143,
13,
13,
1678,
822,
11187,
29918,
2754,
29918,
2457,
29898,
5696,
29892,
3142,
29892,
3579,
19290,
1125,
1678,
396,
282,
2904,
524,
29901,
11262,
29922,
348,
3880,
29899,
23516,
13,
4706,
4974,
1158,
1275,
525,
2490,
29915,
13,
4706,
2933,
353,
9995,
29961,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29896,
29889,
29906,
29892,
376,
29907,
10880,
3399,
1115,
376,
29909,
566,
613,
376,
11536,
22031,
749,
1115,
29871,
29906,
29889,
29945,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29965,
4928,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29940,
8849,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29903,
29887,
29881,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29990,
3116,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29923,
386,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29990,
19080,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29909,
1388,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29928,
327,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
8110,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
6595,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29965,
4928,
29873,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29965,
4928,
29883,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29933,
305,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29931,
14246,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29924,
12748,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29928,
1794,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
6843,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29903,
23818,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29954,
2273,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29923,
359,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29990,
21457,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29923,
14246,
613,
376,
11536,
22031,
749,
1115,
29871,
29896,
29900,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29933,
271,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29925,
29885,
4141,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29979,
7241,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29909,
1351,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
29999,
17697,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
1118,
13,
6377,
10601,
29954,
5416,
1115,
376,
5431,
613,
376,
10601,
5709,
1115,
376,
9966,
613,
376,
27635,
22031,
749,
1115,
29871,
29900,
29889,
29900,
29892,
376,
29907,
10880,
3399,
1115,
376,
5673,
29887,
613,
376,
11536,
22031,
749,
1115,
29871,
29900,
29889,
29900,
6525,
15945,
29908,
29871,
396,
694,
25621,
29901,
382,
29945,
29900,
29896,
13,
4706,
736,
26297,
5103,
29898,
29906,
29900,
29900,
29892,
2933,
29897,
13,
13,
1678,
411,
13261,
29889,
3318,
29898,
6543,
29889,
7924,
29892,
525,
3827,
742,
2625,
29918,
15987,
29922,
17640,
29918,
2754,
29918,
2457,
1125,
13,
4706,
6411,
2925,
29892,
10191,
353,
14523,
29889,
1972,
29918,
5521,
2925,
580,
13,
13,
1678,
4974,
10191,
1275,
6629,
13,
1678,
4974,
6411,
2925,
1275,
426,
13,
4706,
319,
29918,
29909,
15789,
29901,
7392,
749,
29898,
14506,
29922,
29943,
1440,
29898,
29906,
29889,
29945,
511,
502,
29881,
29918,
1767,
29922,
29943,
1440,
29898,
29941,
29889,
29955,
29945,
8243,
13,
4706,
319,
29918,
2544,
29907,
29901,
7392,
749,
29898,
14506,
29922,
29943,
1440,
29898,
29896,
29900,
29900,
511,
502,
29881,
29918,
1767,
29922,
29943,
1440,
29898,
29896,
29945,
29900,
8243,
13,
1678,
500,
13,
13,
13,
1753,
1243,
29918,
1972,
29918,
3018,
311,
29918,
18434,
29898,
2220,
29918,
6078,
29918,
262,
18980,
690,
7143,
1125,
13,
1678,
9995,
29950,
14862,
2224,
1243,
363,
7417,
690,
7143,
11302,
4955,
2346,
292,
15945,
29908,
13,
1678,
14523,
353,
740,
29918,
6078,
29918,
262,
18980,
690,
7143,
13,
13,
1678,
822,
11187,
29918,
2754,
29918,
2457,
29898,
5696,
29892,
3142,
29892,
3579,
19290,
1125,
1678,
396,
282,
2904,
524,
29901,
11262,
29922,
348,
3880,
29899,
23516,
13,
4706,
4974,
1158,
1275,
525,
2490,
29915,
13,
4706,
2933,
353,
9995,
6377,
1469,
1115,
518,
13,
4706,
8853,
12810,
29887,
13026,
1115,
29871,
29953,
29900,
29941,
29889,
29955,
29892,
13,
4706,
376,
20399,
27939,
29965,
14246,
1115,
376,
29906,
29900,
29896,
29955,
29899,
29896,
29896,
29899,
29906,
29906,
29911,
29906,
29906,
29901,
29945,
29946,
29901,
29946,
29900,
29889,
29941,
29906,
29946,
29929,
29946,
29900,
29896,
29999,
613,
13,
4706,
376,
29943,
3905,
27933,
1115,
29871,
29900,
29889,
29900,
29900,
29945,
29892,
13,
4706,
376,
7514,
29954,
5416,
1115,
376,
5431,
29896,
613,
13,
4706,
376,
7514,
1542,
1115,
376,
9802,
300,
2776,
571,
613,
13,
4706,
376,
26036,
1115,
8853,
3744,
11235,
1115,
29871,
29900,
29889,
29900,
29892,
376,
24679,
1115,
29871,
29900,
29889,
29945,
29892,
376,
24679,
29907,
10880,
1542,
1115,
376,
26666,
10758,
13,
4706,
376,
3744,
11235,
1115,
29871,
29900,
29889,
29900,
29892,
13,
4706,
376,
13026,
1115,
1870,
29892,
13,
4706,
376,
26666,
29907,
10880,
3399,
1115,
376,
29923,
386,
613,
13,
4706,
376,
11863,
653,
29907,
10880,
3399,
1115,
376,
29909,
566,
613,
13,
4706,
376,
5709,
1115,
376,
3434,
839,
613,
13,
4706,
376,
1917,
1115,
29871,
29941,
29900,
29896,
29889,
29947,
29945,
29892,
13,
4706,
376,
24679,
1115,
29871,
29900,
29889,
29945,
13,
4706,
2981,
426,
13,
4706,
376,
12810,
29887,
13026,
1115,
29871,
29906,
29945,
29955,
29889,
29906,
29945,
29892,
13,
4706,
376,
20399,
27939,
29965,
14246,
1115,
376,
29906,
29900,
29896,
29955,
29899,
29900,
29955,
29899,
29906,
29947,
29911,
29900,
29929,
29901,
29941,
29929,
29901,
29896,
29929,
29889,
29947,
29955,
29929,
29929,
29906,
29946,
29946,
29999,
613,
13,
4706,
376,
29943,
3905,
27933,
1115,
29871,
29900,
29889,
29900,
29900,
29945,
29892,
13,
4706,
376,
7514,
29954,
5416,
1115,
376,
5431,
29906,
613,
13,
4706,
376,
7514,
1542,
1115,
376,
9802,
300,
29933,
333,
613,
13,
4706,
376,
26036,
1115,
8853,
3744,
11235,
1115,
29871,
29900,
29889,
29900,
29892,
376,
24679,
1115,
29871,
29906,
29889,
29953,
29946,
29896,
29896,
29955,
29941,
29955,
29929,
29892,
376,
24679,
29907,
10880,
1542,
1115,
376,
26666,
10758,
13,
4706,
376,
3744,
11235,
1115,
29871,
29900,
29889,
29900,
29892,
13,
4706,
376,
13026,
1115,
1870,
29892,
13,
4706,
376,
26666,
29907,
10880,
3399,
1115,
376,
29923,
386,
613,
13,
4706,
376,
11863,
653,
29907,
10880,
3399,
1115,
376,
29909,
566,
613,
13,
4706,
376,
5709,
1115,
376,
3434,
839,
613,
13,
4706,
376,
1917,
1115,
29871,
29953,
29955,
29929,
29889,
29946,
29946,
29892,
13,
4706,
376,
24679,
1115,
29871,
29906,
29889,
29953,
29946,
29896,
29896,
29955,
29941,
29955,
29929,
13,
4706,
500,
1402,
13,
376,
5074,
3505,
1115,
29871,
29945,
29900,
29892,
13,
376,
11536,
6913,
1115,
29871,
29906,
29892,
13,
376,
11536,
27514,
1115,
29871,
29896,
29913,
13,
15945,
29908,
29871,
396,
694,
25621,
29901,
382,
29945,
29900,
29896,
13,
4706,
736,
26297,
5103,
29898,
29906,
29900,
29900,
29892,
2933,
29897,
13,
13,
1678,
411,
13261,
29889,
3318,
29898,
6543,
29889,
7924,
29892,
525,
3827,
742,
2625,
29918,
15987,
29922,
17640,
29918,
2754,
29918,
2457,
1125,
13,
4706,
534,
3076,
353,
14523,
29889,
1972,
29918,
3018,
311,
29918,
18434,
29898,
13,
9651,
1369,
29918,
1372,
29922,
29900,
29892,
13,
9651,
1095,
29918,
1372,
29922,
29896,
29945,
29953,
29945,
29955,
29941,
29906,
29896,
29906,
29900,
29892,
13,
9651,
871,
29918,
8173,
29922,
8824,
29892,
13,
4706,
1723,
13,
1678,
3806,
29918,
509,
3076,
353,
518,
13,
4706,
27226,
29898,
13,
9651,
14334,
29922,
29896,
29945,
29900,
29896,
29906,
29941,
29946,
29955,
29953,
29900,
29892,
13,
9651,
4423,
29922,
6508,
29889,
1177,
2287,
29925,
11794,
3919,
1525,
6304,
12064,
29892,
13,
9651,
2967,
29918,
24129,
29922,
29909,
29918,
2544,
29950,
29892,
13,
9651,
14978,
29918,
24129,
29922,
29909,
29918,
29909,
15789,
29892,
13,
9651,
11302,
29918,
1853,
29922,
5323,
311,
1542,
29889,
7838,
29979,
29892,
13,
9651,
5253,
29922,
29943,
1440,
877,
29906,
29889,
29953,
29946,
29896,
29896,
29955,
29941,
29955,
29929,
5477,
13,
9651,
6554,
29922,
29943,
1440,
877,
29906,
29945,
29955,
29889,
29906,
29945,
5477,
13,
9651,
27684,
29922,
29943,
1440,
877,
29900,
29889,
29900,
29896,
29941,
29906,
29900,
29945,
29947,
29953,
29947,
29929,
29945,
5477,
13,
9651,
27684,
29918,
26095,
29922,
29909,
29918,
2544,
29950,
29892,
13,
9651,
1544,
2433,
5431,
29906,
742,
13,
4706,
10353,
27226,
29898,
13,
9651,
14334,
29922,
29896,
29945,
29896,
29896,
29941,
29929,
29896,
29906,
29947,
29900,
29892,
13,
9651,
4423,
29922,
6508,
29889,
1177,
2287,
29925,
11794,
3919,
1525,
6304,
12064,
29892,
13,
9651,
2967,
29918,
24129,
29922,
29909,
29918,
2544,
29950,
29892,
13,
9651,
14978,
29918,
24129,
29922,
29909,
29918,
29909,
15789,
29892,
13,
9651,
11302,
29918,
1853,
29922,
5323,
311,
1542,
29889,
1660,
2208,
29892,
13,
9651,
5253,
29922,
29943,
1440,
877,
29900,
29889,
29945,
5477,
13,
9651,
6554,
29922,
29943,
1440,
877,
29953,
29900,
29941,
29889,
29955,
5477,
13,
9651,
27684,
29922,
29943,
1440,
877,
29900,
29889,
29900,
29900,
29906,
29945,
5477,
13,
9651,
27684,
29918,
26095,
29922,
29909,
29918,
2544,
29950,
29892,
13,
9651,
1544,
2433,
5431,
29896,
742,
13,
4706,
1723,
29962,
13,
1678,
4974,
534,
3076,
1275,
3806,
29918,
509,
3076,
29961,
1057,
29899,
29896,
29962,
13,
13,
13,
29937,
14402,
29901,
8561,
263,
1243,
363,
24342,
24147,
29889,
13,
29937,
10878,
817,
901,
11187,
292,
408,
372,
723,
1996,
11187,
292,
310,
2999,
5717,
13,
2
] |
explore.py | lribiere/explore-mit-bih-arrhythmia-db | 3 | 2193 | import plotly.graph_objects as go
import streamlit as st
import pandas as pd
from utils import *
import glob
import wfdb
import os
ANNOTATIONS_COL_NAME = 'annotations'
'''
# MIT-BIH Arrhythmia DB Exploration
'''
record_ids = [os.path.basename(file)[:-4] for file in glob.glob('data/*.dat')]
if len(record_ids) == 0:
st.write('Warning ! No data could be found under the ./data/ directory.',
'*\*.dat*, *\*.hea*, *\*.atr* files and such should be placed ',
'immediately under the ./data/ directory')
else:
record_ids.sort()
record_id = st.selectbox('Select a record id', record_ids)
record = wfdb.rdrecord(f'data/{record_id}')
annotation = wfdb.rdann(f'data/{record_id}', 'atr')
st.write('Signals found in this record :')
for idx, signal in enumerate(record.sig_name):
st.write(f'- `{signal}` : in {record.units[idx]}, with a frequency of '
f'{record.fs * record.samps_per_frame[idx]}hz')
st.write(f'Comments for this record : {record.comments}')
signals_df = pd.DataFrame(record.p_signal, columns=record.sig_name)
annot_serie = pd.Series(annotation.symbol, index=annotation.sample,
name=ANNOTATIONS_COL_NAME)
full_df = pd.concat([signals_df, annot_serie], axis=1)
''' ## Annotations '''
beat_annot_count = annot_serie.isin(dict(beat_annotations)).sum()
non_beat_annot_count = annot_serie.isin(dict(non_beat_annotations)).sum()
unique_annot = annot_serie.value_counts().index.values
st.write(f'This record contains `{annot_serie.size}` annotations '
f'among which `{beat_annot_count}` beat annotations and '
f'`{non_beat_annot_count}` non beat annotation(s).')
st.write('The annotations are the followings :')
for annot in unique_annot:
st.write(f'- `{annot}` : {annotation_definitions[annot]}')
st.write('More explanations on the annotations are available here : '
'https://archive.physionet.org/physiobank/annotations.shtml')
# Plot counts for each annotation
annot_counts_df = annot_serie \
.value_counts() \
.rename_axis(ANNOTATIONS_COL_NAME) \
.reset_index(name='counts')
bar_fig = go.Figure(data=[go.Bar(x=annot_counts_df[ANNOTATIONS_COL_NAME],
y=annot_counts_df['counts'],
text=annot_counts_df['counts'],
textposition='auto'
)])
bar_fig.update_layout(title='Annotations by count', yaxis_title='counts',
xaxis_title='annotations')
st.write(bar_fig)
''' ## Explore full dataset '''
signal = st.selectbox('Select a signal', record.sig_name)
# Plot signals and annotations
matching_rows_by_annot = {}
for annot in unique_annot:
matching_rows_by_annot[annot] = full_df[ANNOTATIONS_COL_NAME] == annot
fig = go.Figure(layout=go.Layout(title=go.layout.Title(
text='{} signal with annotations'.format(signal))))
fig.add_trace(go.Scatter(x=full_df.index.values,
y=full_df[signal],
mode='lines',
name=signal))
for annot, annot_matching_rows in matching_rows_by_annot.items():
fig.add_trace(go.Scatter(x=full_df.index[annot_matching_rows].values,
y=full_df[annot_matching_rows][signal].values,
mode='markers',
name='{} (annot)'.format(annot)))
st.plotly_chart(fig)
| [
1,
1053,
6492,
368,
29889,
4262,
29918,
12650,
408,
748,
13,
5215,
4840,
19411,
408,
380,
13,
5215,
11701,
408,
10518,
13,
3166,
3667,
29879,
1053,
334,
13,
5215,
13149,
13,
5215,
281,
29888,
2585,
13,
5215,
2897,
13,
13,
2190,
12256,
8098,
29903,
29918,
15032,
29918,
5813,
353,
525,
6735,
800,
29915,
13,
13,
12008,
13,
29937,
341,
1806,
29899,
12809,
29950,
826,
19046,
29265,
423,
6535,
1222,
572,
12418,
13,
12008,
13,
13,
11651,
29918,
4841,
353,
518,
359,
29889,
2084,
29889,
6500,
3871,
29898,
1445,
29897,
7503,
29899,
29946,
29962,
363,
934,
297,
13149,
29889,
23705,
877,
1272,
5515,
29889,
4130,
1495,
29962,
13,
13,
361,
7431,
29898,
11651,
29918,
4841,
29897,
1275,
29871,
29900,
29901,
13,
1678,
380,
29889,
3539,
877,
22709,
1738,
1939,
848,
1033,
367,
1476,
1090,
278,
11431,
1272,
29914,
3884,
29889,
742,
13,
632,
525,
17710,
10521,
4130,
15966,
334,
29905,
10521,
354,
29874,
15966,
334,
29905,
10521,
8141,
29930,
2066,
322,
1316,
881,
367,
7180,
13420,
13,
632,
525,
326,
4210,
2486,
1090,
278,
11431,
1272,
29914,
3884,
1495,
13,
2870,
29901,
13,
1678,
2407,
29918,
4841,
29889,
6605,
580,
13,
1678,
2407,
29918,
333,
353,
380,
29889,
2622,
1884,
877,
3549,
263,
2407,
1178,
742,
2407,
29918,
4841,
29897,
13,
1678,
2407,
353,
281,
29888,
2585,
29889,
5499,
11651,
29898,
29888,
29915,
1272,
19248,
11651,
29918,
333,
29913,
1495,
13,
1678,
17195,
353,
281,
29888,
2585,
29889,
5499,
812,
29898,
29888,
29915,
1272,
19248,
11651,
29918,
333,
29913,
742,
525,
8141,
1495,
13,
1678,
380,
29889,
3539,
877,
10140,
1338,
1476,
297,
445,
2407,
584,
1495,
13,
1678,
363,
22645,
29892,
7182,
297,
26985,
29898,
11651,
29889,
18816,
29918,
978,
1125,
13,
4706,
380,
29889,
3539,
29898,
29888,
28560,
23230,
25436,
10114,
584,
297,
426,
11651,
29889,
348,
1169,
29961,
13140,
29962,
1118,
411,
263,
10868,
310,
525,
13,
462,
285,
29915,
29912,
11651,
29889,
5847,
334,
2407,
29889,
13445,
567,
29918,
546,
29918,
2557,
29961,
13140,
12258,
29882,
29920,
1495,
13,
1678,
380,
29889,
3539,
29898,
29888,
29915,
1523,
1860,
363,
445,
2407,
584,
426,
11651,
29889,
21032,
29913,
1495,
13,
1678,
18470,
29918,
2176,
353,
10518,
29889,
17271,
29898,
11651,
29889,
29886,
29918,
25436,
29892,
4341,
29922,
11651,
29889,
18816,
29918,
978,
29897,
13,
1678,
9732,
29918,
15596,
353,
10518,
29889,
19204,
29898,
18317,
29889,
18098,
29892,
2380,
29922,
18317,
29889,
11249,
29892,
13,
462,
9651,
1024,
29922,
2190,
12256,
8098,
29903,
29918,
15032,
29918,
5813,
29897,
13,
1678,
2989,
29918,
2176,
353,
10518,
29889,
17685,
4197,
4530,
1338,
29918,
2176,
29892,
9732,
29918,
15596,
1402,
9685,
29922,
29896,
29897,
13,
13,
1678,
14550,
444,
530,
1333,
800,
14550,
13,
1678,
16646,
29918,
6735,
29918,
2798,
353,
9732,
29918,
15596,
29889,
275,
262,
29898,
8977,
29898,
915,
271,
29918,
6735,
800,
8106,
2083,
580,
13,
1678,
1661,
29918,
915,
271,
29918,
6735,
29918,
2798,
353,
9732,
29918,
15596,
29889,
275,
262,
29898,
8977,
29898,
5464,
29918,
915,
271,
29918,
6735,
800,
8106,
2083,
580,
13,
1678,
5412,
29918,
6735,
353,
9732,
29918,
15596,
29889,
1767,
29918,
2798,
29879,
2141,
2248,
29889,
5975,
13,
1678,
380,
29889,
3539,
29898,
29888,
29915,
4013,
2407,
3743,
23230,
6735,
29918,
15596,
29889,
2311,
10114,
25495,
525,
13,
632,
285,
29915,
314,
549,
607,
23230,
915,
271,
29918,
6735,
29918,
2798,
10114,
16646,
25495,
322,
525,
13,
632,
285,
11120,
29912,
5464,
29918,
915,
271,
29918,
6735,
29918,
2798,
10114,
1661,
16646,
17195,
29898,
29879,
467,
1495,
13,
1678,
380,
29889,
3539,
877,
1576,
25495,
526,
278,
1101,
886,
584,
1495,
13,
1678,
363,
9732,
297,
5412,
29918,
6735,
29901,
13,
4706,
380,
29889,
3539,
29898,
29888,
28560,
23230,
6735,
10114,
584,
426,
18317,
29918,
25476,
2187,
29961,
6735,
12258,
1495,
13,
1678,
380,
29889,
3539,
877,
20761,
7309,
800,
373,
278,
25495,
526,
3625,
1244,
584,
525,
13,
632,
525,
991,
597,
10867,
29889,
14017,
291,
300,
29889,
990,
29914,
14017,
601,
9157,
29914,
6735,
800,
29889,
29879,
1420,
1495,
13,
13,
1678,
396,
18399,
18139,
363,
1269,
17195,
13,
1678,
9732,
29918,
2798,
29879,
29918,
2176,
353,
9732,
29918,
15596,
320,
13,
4706,
869,
1767,
29918,
2798,
29879,
580,
320,
13,
4706,
869,
1267,
420,
29918,
8990,
29898,
2190,
12256,
8098,
29903,
29918,
15032,
29918,
5813,
29897,
320,
13,
4706,
869,
12071,
29918,
2248,
29898,
978,
2433,
2798,
29879,
1495,
13,
1678,
2594,
29918,
1003,
353,
748,
29889,
13080,
545,
29898,
1272,
11759,
1484,
29889,
4297,
29898,
29916,
29922,
6735,
29918,
2798,
29879,
29918,
2176,
29961,
2190,
12256,
8098,
29903,
29918,
15032,
29918,
5813,
1402,
13,
462,
462,
268,
343,
29922,
6735,
29918,
2798,
29879,
29918,
2176,
1839,
2798,
29879,
7464,
13,
462,
462,
268,
1426,
29922,
6735,
29918,
2798,
29879,
29918,
2176,
1839,
2798,
29879,
7464,
13,
462,
462,
268,
1426,
3283,
2433,
6921,
29915,
13,
462,
462,
268,
1723,
2314,
13,
1678,
2594,
29918,
1003,
29889,
5504,
29918,
2680,
29898,
3257,
2433,
2744,
1333,
800,
491,
2302,
742,
343,
8990,
29918,
3257,
2433,
2798,
29879,
742,
13,
462,
3986,
921,
8990,
29918,
3257,
2433,
6735,
800,
1495,
13,
1678,
380,
29889,
3539,
29898,
1646,
29918,
1003,
29897,
13,
13,
1678,
14550,
444,
1222,
572,
487,
2989,
8783,
14550,
13,
1678,
7182,
353,
380,
29889,
2622,
1884,
877,
3549,
263,
7182,
742,
2407,
29889,
18816,
29918,
978,
29897,
13,
1678,
396,
18399,
18470,
322,
25495,
13,
1678,
9686,
29918,
5727,
29918,
1609,
29918,
6735,
353,
6571,
13,
1678,
363,
9732,
297,
5412,
29918,
6735,
29901,
13,
4706,
9686,
29918,
5727,
29918,
1609,
29918,
6735,
29961,
6735,
29962,
353,
2989,
29918,
2176,
29961,
2190,
12256,
8098,
29903,
29918,
15032,
29918,
5813,
29962,
1275,
9732,
13,
1678,
2537,
353,
748,
29889,
13080,
545,
29898,
2680,
29922,
1484,
29889,
3453,
29898,
3257,
29922,
1484,
29889,
2680,
29889,
7030,
29898,
13,
4706,
1426,
2433,
8875,
7182,
411,
25495,
4286,
4830,
29898,
25436,
13697,
13,
1678,
2537,
29889,
1202,
29918,
15003,
29898,
1484,
29889,
4421,
2620,
29898,
29916,
29922,
8159,
29918,
2176,
29889,
2248,
29889,
5975,
29892,
13,
462,
632,
343,
29922,
8159,
29918,
2176,
29961,
25436,
1402,
13,
462,
632,
4464,
2433,
9012,
742,
13,
462,
632,
1024,
29922,
25436,
876,
13,
1678,
363,
9732,
29892,
9732,
29918,
4352,
292,
29918,
5727,
297,
9686,
29918,
5727,
29918,
1609,
29918,
6735,
29889,
7076,
7295,
13,
4706,
2537,
29889,
1202,
29918,
15003,
29898,
1484,
29889,
4421,
2620,
29898,
29916,
29922,
8159,
29918,
2176,
29889,
2248,
29961,
6735,
29918,
4352,
292,
29918,
5727,
1822,
5975,
29892,
13,
462,
462,
343,
29922,
8159,
29918,
2176,
29961,
6735,
29918,
4352,
292,
29918,
5727,
3816,
25436,
1822,
5975,
29892,
13,
462,
462,
4464,
2433,
3502,
414,
742,
13,
462,
462,
1024,
2433,
8875,
313,
6735,
29897,
4286,
4830,
29898,
6735,
4961,
13,
1678,
380,
29889,
5317,
368,
29918,
15425,
29898,
1003,
29897,
13,
2
] |
hcam_finder/ucam_finder.py | HiPERCAM/hcam_finder | 0 | 172107 | <gh_stars>0
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, unicode_literals, division
import itertools
from ginga.canvas.types.all import Line, CompoundObject
from ginga.util import wcs
from hcam_widgets.tkutils import get_root
from .finders import FovSetter
class UCAMFovSetter(FovSetter):
def window_string(self):
g = get_root(self).globals
if g.ipars.isFF:
retval = ''
else:
wframe = g.ipars.wframe
winlist = [
'xsl: {}, xsr: {}, ys: {}, nx: {}, ny: {}'.format(xsl, xsr, ys, nx, ny)
for (xsl, xsr, ys, nx, ny) in wframe
]
retval = '\n'.join(winlist)
return retval
def _make_ccd(self, image):
"""
Converts the current instrument settings to a ginga canvas object
"""
# get window pair object from top widget
g = get_root(self).globals
wframe = g.ipars.wframe
# all values in pixel coords of the FITS frame
# get centre
ctr_x, ctr_y = image.radectopix(self.ctr_ra_deg, self.ctr_dec_deg)
self.ctr_x, self.ctr_y = ctr_x, ctr_y
nx, ny = self.nxtot.value, self.nytot.value
mainCCD = self._make_win(0, 0, nx, ny, image,
fill=True, color='red',
fillalpha=0.1, name='mainCCD')
# dashed lines to mark quadrants of CCD
chip_ctr_ra, chip_ctr_dec = self._chip_cen()
x1, y1 = wcs.add_offset_radec(chip_ctr_ra, chip_ctr_dec,
0, self.fov_y/2)
x2, y2 = wcs.add_offset_radec(chip_ctr_ra, chip_ctr_dec,
0, -self.fov_y/2)
points = [image.radectopix(ra, dec) for (ra, dec) in (
(x1, y1), (x2, y2)
)]
points = list(itertools.chain.from_iterable(points))
vline = Line(*points, color='red', linestyle='dash', linewidth=2)
# emphasis on bottom of CCD
x1, y1 = wcs.add_offset_radec(chip_ctr_ra, chip_ctr_dec,
-self.fov_x/2, -self.fov_y/2)
x2, y2 = wcs.add_offset_radec(chip_ctr_ra, chip_ctr_dec,
self.fov_x/2, -self.fov_y/2)
points = [image.radectopix(ra, dec) for (ra, dec) in (
(x1, y1), (x2, y2)
)]
points = list(itertools.chain.from_iterable(points))
eline = Line(*points, color='red', linewidth=4)
# list of objects for compound object
obl = [mainCCD, vline, eline]
# iterate over window pairs
# these coords in ccd pixel vaues
if not g.ipars.isFF:
params = dict(fill=True, fillcolor='blue', fillalpha=0.3)
for xsl, xsr, ys, nx, ny in wframe:
obl.append(self._make_win(xsl, ys, nx, ny, image, **params))
obl.append(self._make_win(xsr, ys, nx, ny, image, **params))
obj = CompoundObject(*obl)
obj.editable = True
return obj
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
29892,
8380,
29918,
5215,
29892,
29104,
29918,
20889,
1338,
29892,
8542,
13,
5215,
4256,
8504,
13,
13,
3166,
12773,
29874,
29889,
15257,
29889,
8768,
29889,
497,
1053,
7407,
29892,
3831,
618,
2061,
13,
3166,
12773,
29874,
29889,
4422,
1053,
281,
2395,
13,
13,
3166,
298,
11108,
29918,
8030,
29879,
29889,
11178,
13239,
1053,
679,
29918,
4632,
13,
13,
3166,
869,
2886,
414,
1053,
383,
586,
22304,
13,
13,
13,
1990,
501,
29907,
5194,
29943,
586,
22304,
29898,
29943,
586,
22304,
1125,
13,
13,
1678,
822,
3474,
29918,
1807,
29898,
1311,
1125,
13,
4706,
330,
353,
679,
29918,
4632,
29898,
1311,
467,
23705,
1338,
13,
4706,
565,
330,
29889,
666,
1503,
29889,
275,
4198,
29901,
13,
9651,
3240,
791,
353,
6629,
13,
4706,
1683,
29901,
13,
9651,
281,
2557,
353,
330,
29889,
666,
1503,
29889,
29893,
2557,
13,
9651,
5401,
1761,
353,
518,
13,
18884,
525,
7836,
29901,
24335,
14492,
29878,
29901,
24335,
343,
29879,
29901,
24335,
302,
29916,
29901,
24335,
7098,
29901,
6571,
4286,
4830,
29898,
7836,
29892,
14492,
29878,
29892,
343,
29879,
29892,
302,
29916,
29892,
7098,
29897,
13,
18884,
363,
313,
7836,
29892,
14492,
29878,
29892,
343,
29879,
29892,
302,
29916,
29892,
7098,
29897,
297,
281,
2557,
13,
9651,
4514,
13,
9651,
3240,
791,
353,
11297,
29876,
4286,
7122,
29898,
5080,
1761,
29897,
13,
4706,
736,
3240,
791,
13,
13,
1678,
822,
903,
5675,
29918,
617,
29881,
29898,
1311,
29892,
1967,
1125,
13,
4706,
9995,
13,
4706,
1281,
369,
1372,
278,
1857,
11395,
6055,
304,
263,
12773,
29874,
10508,
1203,
13,
4706,
9995,
13,
4706,
396,
679,
3474,
5101,
1203,
515,
2246,
11109,
13,
4706,
330,
353,
679,
29918,
4632,
29898,
1311,
467,
23705,
1338,
13,
4706,
281,
2557,
353,
330,
29889,
666,
1503,
29889,
29893,
2557,
13,
13,
4706,
396,
599,
1819,
297,
15526,
1302,
4339,
310,
278,
383,
1806,
29903,
3515,
13,
4706,
396,
679,
8442,
13,
4706,
274,
509,
29918,
29916,
29892,
274,
509,
29918,
29891,
353,
1967,
29889,
15464,
312,
459,
861,
29898,
1311,
29889,
9988,
29918,
336,
29918,
12163,
29892,
1583,
29889,
9988,
29918,
7099,
29918,
12163,
29897,
13,
4706,
1583,
29889,
9988,
29918,
29916,
29892,
1583,
29889,
9988,
29918,
29891,
353,
274,
509,
29918,
29916,
29892,
274,
509,
29918,
29891,
13,
13,
4706,
302,
29916,
29892,
7098,
353,
1583,
29889,
29876,
486,
327,
29889,
1767,
29892,
1583,
29889,
1460,
4260,
29889,
1767,
13,
4706,
1667,
4174,
29928,
353,
1583,
3032,
5675,
29918,
5080,
29898,
29900,
29892,
29871,
29900,
29892,
302,
29916,
29892,
7098,
29892,
1967,
29892,
13,
462,
462,
5445,
29922,
5574,
29892,
2927,
2433,
1127,
742,
13,
462,
462,
5445,
2312,
29922,
29900,
29889,
29896,
29892,
1024,
2433,
3396,
4174,
29928,
1495,
13,
13,
4706,
396,
27526,
3454,
304,
2791,
15448,
1934,
310,
315,
6530,
13,
4706,
29830,
29918,
9988,
29918,
336,
29892,
29830,
29918,
9988,
29918,
7099,
353,
1583,
3032,
305,
666,
29918,
10278,
580,
13,
4706,
921,
29896,
29892,
343,
29896,
353,
281,
2395,
29889,
1202,
29918,
10289,
29918,
336,
7099,
29898,
305,
666,
29918,
9988,
29918,
336,
29892,
29830,
29918,
9988,
29918,
7099,
29892,
13,
462,
462,
539,
29900,
29892,
1583,
29889,
29888,
586,
29918,
29891,
29914,
29906,
29897,
13,
4706,
921,
29906,
29892,
343,
29906,
353,
281,
2395,
29889,
1202,
29918,
10289,
29918,
336,
7099,
29898,
305,
666,
29918,
9988,
29918,
336,
29892,
29830,
29918,
9988,
29918,
7099,
29892,
13,
462,
462,
539,
29900,
29892,
448,
1311,
29889,
29888,
586,
29918,
29891,
29914,
29906,
29897,
13,
4706,
3291,
353,
518,
3027,
29889,
15464,
312,
459,
861,
29898,
336,
29892,
1602,
29897,
363,
313,
336,
29892,
1602,
29897,
297,
313,
13,
9651,
313,
29916,
29896,
29892,
343,
29896,
511,
313,
29916,
29906,
29892,
343,
29906,
29897,
13,
4706,
1723,
29962,
13,
4706,
3291,
353,
1051,
29898,
1524,
8504,
29889,
14153,
29889,
3166,
29918,
1524,
519,
29898,
9748,
876,
13,
4706,
325,
1220,
353,
7407,
10456,
9748,
29892,
2927,
2433,
1127,
742,
6276,
342,
1508,
2433,
14592,
742,
1196,
2103,
29922,
29906,
29897,
13,
13,
4706,
396,
19310,
275,
373,
5970,
310,
315,
6530,
13,
4706,
921,
29896,
29892,
343,
29896,
353,
281,
2395,
29889,
1202,
29918,
10289,
29918,
336,
7099,
29898,
305,
666,
29918,
9988,
29918,
336,
29892,
29830,
29918,
9988,
29918,
7099,
29892,
13,
462,
462,
418,
448,
1311,
29889,
29888,
586,
29918,
29916,
29914,
29906,
29892,
448,
1311,
29889,
29888,
586,
29918,
29891,
29914,
29906,
29897,
13,
4706,
921,
29906,
29892,
343,
29906,
353,
281,
2395,
29889,
1202,
29918,
10289,
29918,
336,
7099,
29898,
305,
666,
29918,
9988,
29918,
336,
29892,
29830,
29918,
9988,
29918,
7099,
29892,
13,
462,
462,
418,
1583,
29889,
29888,
586,
29918,
29916,
29914,
29906,
29892,
448,
1311,
29889,
29888,
586,
29918,
29891,
29914,
29906,
29897,
13,
4706,
3291,
353,
518,
3027,
29889,
15464,
312,
459,
861,
29898,
336,
29892,
1602,
29897,
363,
313,
336,
29892,
1602,
29897,
297,
313,
13,
9651,
313,
29916,
29896,
29892,
343,
29896,
511,
313,
29916,
29906,
29892,
343,
29906,
29897,
13,
4706,
1723,
29962,
13,
4706,
3291,
353,
1051,
29898,
1524,
8504,
29889,
14153,
29889,
3166,
29918,
1524,
519,
29898,
9748,
876,
13,
4706,
560,
457,
353,
7407,
10456,
9748,
29892,
2927,
2433,
1127,
742,
1196,
2103,
29922,
29946,
29897,
13,
13,
4706,
396,
1051,
310,
3618,
363,
752,
618,
1203,
13,
4706,
704,
29880,
353,
518,
3396,
4174,
29928,
29892,
325,
1220,
29892,
560,
457,
29962,
13,
13,
4706,
396,
13649,
975,
3474,
11000,
13,
4706,
396,
1438,
1302,
4339,
297,
274,
2252,
15526,
325,
585,
267,
13,
4706,
565,
451,
330,
29889,
666,
1503,
29889,
275,
4198,
29901,
13,
9651,
8636,
353,
9657,
29898,
5589,
29922,
5574,
29892,
5445,
2780,
2433,
9539,
742,
5445,
2312,
29922,
29900,
29889,
29941,
29897,
13,
9651,
363,
921,
2536,
29892,
14492,
29878,
29892,
343,
29879,
29892,
302,
29916,
29892,
7098,
297,
281,
2557,
29901,
13,
18884,
704,
29880,
29889,
4397,
29898,
1311,
3032,
5675,
29918,
5080,
29898,
7836,
29892,
343,
29879,
29892,
302,
29916,
29892,
7098,
29892,
1967,
29892,
3579,
7529,
876,
13,
18884,
704,
29880,
29889,
4397,
29898,
1311,
3032,
5675,
29918,
5080,
29898,
10351,
29878,
29892,
343,
29879,
29892,
302,
29916,
29892,
7098,
29892,
1967,
29892,
3579,
7529,
876,
13,
13,
4706,
5446,
353,
3831,
618,
2061,
10456,
711,
29880,
29897,
13,
4706,
5446,
29889,
5628,
519,
353,
5852,
13,
4706,
736,
5446,
13,
2
] |
webapi/webapi/resources/testurl.py | shovradas/proxy-fellow | 1 | 78404 | <reponame>shovradas/proxy-fellow
import datetime
import time
from flask import url_for
from flask_restful import Resource, abort
from webargs.flaskparser import use_args
from bson.objectid import ObjectId
from core.proxy_checker import HttpProxyChecker
from webapi import api, mongo
from webapi.common import util
from webapi.schemas import TesturlSchema, TesturlSchemaEmbedded, params_schema
testurl_schema = TesturlSchema()
testurls_schema = TesturlSchema(many=True)
testurl_schema_embedded = TesturlSchemaEmbedded()
testurls_schema_embedded = TesturlSchemaEmbedded(many=True)
@api.resource('/api/v1/testurls/<id>')
class TestUrl(Resource):
@use_args(params_schema, location="query")
def get(self, args, id):
util.abort_if_invalid_id_format(id)
if args['embed']:
docs = mongo.db.testurls.aggregate([
{'$match': {'_id': ObjectId(id)}},
{
"$lookup": {
"from": "proxytesturls",
"let": {"testurl_id": "$_id"},
"pipeline": [{"$match": {"$expr": {"$eq": ["$testurlId", "$$testurl_id"]}}},
{
"$lookup": {
"from": "proxies",
"let": {"proxy_id": "$proxyId"},
"pipeline": [{"$match": {"$expr": {"$eq": ["$_id", "$$proxy_id"]}}}],
"as": "proxy"
}
},
{"$unwind": "$proxy"},
{
"$project": {
"_id": "$proxy._id",
"providerId": "$proxy.providerId",
"ip": "$proxy.ip",
"port": "$proxy.port",
"funcTestDate": "$proxy.funcTestDate",
"lastFoundDate": "$proxy.lastFoundDate",
"discoveredDate": "$proxy.discoveredDate",
"anonymity": "$proxy.anonymity",
"validationTestDate": "$validationTestDate",
"validationTestStatus": "$validationTestStatus"
}
}],
"as": "proxies"
}
}
])
docs = list(docs)
util.abort_if_doesnt_exist(docs)
return testurl_schema_embedded.dump(docs[0])
doc = mongo.db.testurls.find_one({'_id': ObjectId(id)})
util.abort_if_doesnt_exist(doc)
return testurl_schema.dump(doc)
def delete(self, id):
util.abort_if_invalid_id_format(id)
mongo.db.proxytesturls.delete_many({'testurlId': ObjectId(id)})
mongo.db.testurls.delete_one({'_id': ObjectId(id)})
return '', 204
@use_args(testurl_schema, location='json_or_form')
@use_args(params_schema, location="query")
def put(self, testurl_new, params, id):
util.abort_if_invalid_id_format(id)
testurl = mongo.db.testurls.find_one({'_id': ObjectId(id)})
util.abort_if_doesnt_exist(testurl)
for k, v in testurl_new.items():
testurl[k] = v
mongo.db.testurls.update_one({'_id': ObjectId(id)}, {'$set': testurl})
if params['validate']:
validate_testurl(testurl['_id'])
return '', 204
def patch(self, id):
util.abort_if_invalid_id_format(id)
if not validate_testurl(id):
abort(500, message='Error occurred while syncing', status="error")
return '', 204
@api.resource('/api/v1/testurls')
class TestUrlList(Resource):
@use_args(params_schema, location="query")
def get(self, args):
if args['embed']:
docs = mongo.db.testurls.aggregate([
{
"$lookup": {
"from": "proxytesturls",
"let": {"testurl_id": "$_id"},
"pipeline": [{"$match": {"$expr": {"$eq": ["$testurlId", "$$testurl_id"]}}},
{
"$lookup": {
"from": "proxies",
"let": {"proxy_id": "$proxyId"},
"pipeline": [{"$match": {"$expr": {"$eq": ["$_id", "$$proxy_id"]}}}],
"as": "proxy"
}
},
{"$unwind": "$proxy"},
{
"$project": {
"_id": "$proxy._id",
"providerId": "$proxy.providerId",
"ip": "$proxy.ip",
"port": "$proxy.port",
"funcTestDate": "$proxy.funcTestDate",
"lastFoundDate": "$proxy.lastFoundDate",
"discoveredDate": "$proxy.discoveredDate",
"anonymity": "$proxy.anonymity",
"validationTestDate": "$validationTestDate",
"validationTestStatus": "$validationTestStatus"
}
}],
"as": "proxies"
}
},
{'$skip': args['offset']},
{'$limit': args['limit']}
])
return testurls_schema_embedded.dump(docs)
docs = mongo.db.testurls.find().skip(args['offset']).limit(args['limit'])
return testurls_schema.dump(docs)
@use_args(testurl_schema, location='json_or_form')
@use_args(params_schema, location="query")
def post(self, testurl, params):
result = mongo.db.testurls.insert_one(testurl)
testurl = mongo.db.testurls.find_one({'_id': result.inserted_id})
if params['validate']:
validate_testurl(testurl['_id'])
return testurl_schema.dump(testurl), 201, {'location': url_for('testurl', id=testurl['_id'])}
def patch(self):
testurls = mongo.db.testurls.find()
for testurl in testurls:
validate_testurl(testurl['_id'])
return '', 204
def validate_testurl(testurl_id):
testurl = mongo.db.testurls.find_one({'_id': ObjectId(testurl_id)})
util.abort_if_doesnt_exist(testurl)
cfg = mongo.db.configurations.find_one({'status': True})
if not cfg:
cfg = {
'syncInterval': 10,
'maxAge': 1,
'downloadDelay': 1,
'proxyTestTimeout': 1
}
proxies = list(mongo.db.proxies.find())
proxy_checker = HttpProxyChecker()
valid_proxy_count = 0
for proxy in proxies:
try:
proxy_address = f"{proxy['ip']}:{proxy['port']}"
# Checking if online
result = proxy_checker.check_proxy(proxy_address, cfg['proxyTestTimeout'])
if result['status'] == 'online':
proxy['anonymity'] = result['anonymity']
proxy['funcTestDate'] = datetime.datetime.now()
try:
mongo.db.proxies.update_one({'_id': proxy['_id']}, {'$set': proxy})
except:
print('error: while syncing proxy')
continue
else:
try:
mongo.db.proxytesturls.delete_many({'proxyId': proxy['_id']})
mongo.db.proxies.delete_one({'_id': proxy['_id']})
continue
except:
print('error: while deleting proxy')
continue
###############
# Validating
result = proxy_checker.validate_proxy(proxy_address, testurl['url'], cfg['proxyTestTimeout'])
proxytesturl = {
'proxyId': proxy['_id'],
'testurlId': testurl['_id'],
'validationTestDate': datetime.datetime.now(),
'validationTestStatus': result['status']
}
mongo.db.proxytesturls.update_one(
{'proxyId': proxy['_id'], 'testurlId': testurl['_id']},
{'$set': proxytesturl},
upsert=True
)
if result['status'] == 'success':
valid_proxy_count += 1
except:
print('error: validate_testurl')
continue
try:
testurl['validationAttempt'] = {
'attemptDate': datetime.datetime.now(),
'validProxyCount': valid_proxy_count,
'status': 'success' if (valid_proxy_count !=0 and valid_proxy_count == len(proxies)) else ('partial' if valid_proxy_count>0 else 'failed')
}
mongo.db.testurls.update_one({'_id': testurl['_id']}, {'$set': testurl})
return True
except:
return False
| [
1,
529,
276,
1112,
420,
29958,
845,
586,
3665,
294,
29914,
14701,
29899,
29888,
4743,
13,
5215,
12865,
13,
5215,
931,
13,
13,
3166,
29784,
1053,
3142,
29918,
1454,
13,
3166,
29784,
29918,
5060,
1319,
1053,
18981,
29892,
27450,
13,
3166,
1856,
5085,
29889,
1579,
1278,
16680,
1053,
671,
29918,
5085,
13,
3166,
289,
1100,
29889,
3318,
333,
1053,
4669,
1204,
13,
3166,
7136,
29889,
14701,
29918,
3198,
261,
1053,
9056,
14048,
5596,
261,
13,
3166,
1856,
2754,
1053,
7882,
29892,
19476,
13,
3166,
1856,
2754,
29889,
9435,
1053,
3667,
13,
3166,
1856,
2754,
29889,
11993,
1053,
4321,
2271,
12763,
29892,
4321,
2271,
12763,
6026,
2580,
7176,
29892,
8636,
29918,
11010,
13,
13,
1688,
2271,
29918,
11010,
353,
4321,
2271,
12763,
580,
13,
1688,
26045,
29918,
11010,
353,
4321,
2271,
12763,
29898,
13011,
29922,
5574,
29897,
13,
13,
1688,
2271,
29918,
11010,
29918,
17987,
7176,
353,
4321,
2271,
12763,
6026,
2580,
7176,
580,
13,
1688,
26045,
29918,
11010,
29918,
17987,
7176,
353,
4321,
2271,
12763,
6026,
2580,
7176,
29898,
13011,
29922,
5574,
29897,
13,
13,
13,
29992,
2754,
29889,
10314,
11219,
2754,
29914,
29894,
29896,
29914,
1688,
26045,
29914,
29966,
333,
29958,
1495,
13,
1990,
4321,
5983,
29898,
6848,
1125,
13,
1678,
732,
1509,
29918,
5085,
29898,
7529,
29918,
11010,
29892,
4423,
543,
1972,
1159,
13,
1678,
822,
679,
29898,
1311,
29892,
6389,
29892,
1178,
1125,
13,
4706,
3667,
29889,
370,
441,
29918,
361,
29918,
20965,
29918,
333,
29918,
4830,
29898,
333,
29897,
13,
4706,
565,
6389,
1839,
17987,
2033,
29901,
13,
9651,
10561,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
26193,
403,
4197,
13,
18884,
11117,
29938,
4352,
2396,
11117,
29918,
333,
2396,
4669,
1204,
29898,
333,
29897,
11656,
13,
18884,
426,
13,
462,
1678,
3908,
20401,
1115,
426,
13,
462,
4706,
376,
3166,
1115,
376,
14701,
1688,
26045,
613,
13,
462,
4706,
376,
1026,
1115,
8853,
1688,
2271,
29918,
333,
1115,
3908,
29918,
333,
10758,
13,
462,
4706,
376,
13096,
5570,
1115,
518,
6377,
29938,
4352,
1115,
8853,
29938,
13338,
1115,
8853,
29938,
1837,
1115,
6796,
29938,
1688,
2271,
1204,
613,
3908,
29938,
1688,
2271,
29918,
333,
3108,
930,
1118,
13,
462,
462,
268,
426,
13,
462,
462,
308,
3908,
20401,
1115,
426,
13,
462,
462,
632,
376,
3166,
1115,
376,
771,
29916,
583,
613,
13,
462,
462,
632,
376,
1026,
1115,
8853,
14701,
29918,
333,
1115,
3908,
14701,
1204,
10758,
13,
462,
462,
632,
376,
13096,
5570,
1115,
518,
6377,
29938,
4352,
1115,
8853,
29938,
13338,
1115,
8853,
29938,
1837,
1115,
6796,
14630,
333,
613,
3908,
29938,
14701,
29918,
333,
3108,
12499,
1402,
13,
462,
462,
632,
376,
294,
1115,
376,
14701,
29908,
13,
462,
462,
308,
500,
13,
462,
462,
268,
2981,
13,
462,
462,
268,
8853,
29938,
348,
14800,
1115,
3908,
14701,
10758,
13,
462,
462,
268,
426,
13,
462,
462,
308,
3908,
4836,
1115,
426,
13,
462,
462,
632,
11119,
333,
1115,
3908,
14701,
3032,
333,
613,
13,
462,
462,
632,
376,
18121,
1204,
1115,
3908,
14701,
29889,
18121,
1204,
613,
13,
462,
462,
632,
376,
666,
1115,
3908,
14701,
29889,
666,
613,
13,
462,
462,
632,
376,
637,
1115,
3908,
14701,
29889,
637,
613,
13,
462,
462,
632,
376,
9891,
3057,
2539,
1115,
3908,
14701,
29889,
9891,
3057,
2539,
613,
13,
462,
462,
632,
376,
4230,
9692,
2539,
1115,
3908,
14701,
29889,
4230,
9692,
2539,
613,
13,
462,
462,
632,
376,
2218,
11911,
287,
2539,
1115,
3908,
14701,
29889,
2218,
11911,
287,
2539,
613,
13,
462,
462,
632,
376,
273,
4735,
537,
1115,
3908,
14701,
29889,
273,
4735,
537,
613,
13,
462,
462,
632,
376,
18157,
3057,
2539,
1115,
3908,
18157,
3057,
2539,
613,
13,
462,
462,
632,
376,
18157,
3057,
5709,
1115,
3908,
18157,
3057,
5709,
29908,
13,
462,
462,
308,
500,
13,
462,
462,
268,
500,
1402,
13,
462,
4706,
376,
294,
1115,
376,
771,
29916,
583,
29908,
13,
462,
1678,
500,
13,
18884,
500,
13,
632,
2314,
13,
9651,
10561,
353,
1051,
29898,
2640,
29897,
13,
9651,
3667,
29889,
370,
441,
29918,
361,
29918,
13221,
593,
29918,
28997,
29898,
2640,
29897,
13,
9651,
736,
1243,
2271,
29918,
11010,
29918,
17987,
7176,
29889,
15070,
29898,
2640,
29961,
29900,
2314,
13,
13,
4706,
1574,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
2886,
29918,
650,
3319,
15972,
333,
2396,
4669,
1204,
29898,
333,
26972,
13,
4706,
3667,
29889,
370,
441,
29918,
361,
29918,
13221,
593,
29918,
28997,
29898,
1514,
29897,
13,
4706,
736,
1243,
2271,
29918,
11010,
29889,
15070,
29898,
1514,
29897,
13,
13,
1678,
822,
5217,
29898,
1311,
29892,
1178,
1125,
13,
4706,
3667,
29889,
370,
441,
29918,
361,
29918,
20965,
29918,
333,
29918,
4830,
29898,
333,
29897,
13,
4706,
19476,
29889,
2585,
29889,
14701,
1688,
26045,
29889,
8143,
29918,
13011,
3319,
29915,
1688,
2271,
1204,
2396,
4669,
1204,
29898,
333,
26972,
13,
4706,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
8143,
29918,
650,
3319,
15972,
333,
2396,
4669,
1204,
29898,
333,
26972,
13,
4706,
736,
15516,
29871,
29906,
29900,
29946,
13,
13,
1678,
732,
1509,
29918,
5085,
29898,
1688,
2271,
29918,
11010,
29892,
4423,
2433,
3126,
29918,
272,
29918,
689,
1495,
13,
1678,
732,
1509,
29918,
5085,
29898,
7529,
29918,
11010,
29892,
4423,
543,
1972,
1159,
13,
1678,
822,
1925,
29898,
1311,
29892,
1243,
2271,
29918,
1482,
29892,
8636,
29892,
1178,
1125,
13,
4706,
3667,
29889,
370,
441,
29918,
361,
29918,
20965,
29918,
333,
29918,
4830,
29898,
333,
29897,
13,
4706,
1243,
2271,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
2886,
29918,
650,
3319,
15972,
333,
2396,
4669,
1204,
29898,
333,
26972,
13,
4706,
3667,
29889,
370,
441,
29918,
361,
29918,
13221,
593,
29918,
28997,
29898,
1688,
2271,
29897,
13,
13,
4706,
363,
413,
29892,
325,
297,
1243,
2271,
29918,
1482,
29889,
7076,
7295,
13,
9651,
1243,
2271,
29961,
29895,
29962,
353,
325,
13,
13,
4706,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
5504,
29918,
650,
3319,
15972,
333,
2396,
4669,
1204,
29898,
333,
19230,
11117,
29938,
842,
2396,
1243,
2271,
1800,
13,
13,
4706,
565,
8636,
1839,
15480,
2033,
29901,
13,
9651,
12725,
29918,
1688,
2271,
29898,
1688,
2271,
1839,
29918,
333,
11287,
13,
13,
4706,
736,
15516,
29871,
29906,
29900,
29946,
13,
13,
1678,
822,
13261,
29898,
1311,
29892,
1178,
1125,
13,
4706,
3667,
29889,
370,
441,
29918,
361,
29918,
20965,
29918,
333,
29918,
4830,
29898,
333,
29897,
13,
13,
4706,
565,
451,
12725,
29918,
1688,
2271,
29898,
333,
1125,
13,
9651,
27450,
29898,
29945,
29900,
29900,
29892,
2643,
2433,
2392,
10761,
1550,
16523,
292,
742,
4660,
543,
2704,
1159,
13,
13,
4706,
736,
15516,
29871,
29906,
29900,
29946,
13,
13,
13,
29992,
2754,
29889,
10314,
11219,
2754,
29914,
29894,
29896,
29914,
1688,
26045,
1495,
13,
1990,
4321,
5983,
1293,
29898,
6848,
1125,
13,
1678,
732,
1509,
29918,
5085,
29898,
7529,
29918,
11010,
29892,
4423,
543,
1972,
1159,
13,
1678,
822,
679,
29898,
1311,
29892,
6389,
1125,
13,
4706,
565,
6389,
1839,
17987,
2033,
29901,
13,
9651,
10561,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
26193,
403,
4197,
13,
18884,
426,
13,
462,
1678,
3908,
20401,
1115,
426,
13,
462,
4706,
376,
3166,
1115,
376,
14701,
1688,
26045,
613,
13,
462,
4706,
376,
1026,
1115,
8853,
1688,
2271,
29918,
333,
1115,
3908,
29918,
333,
10758,
13,
462,
4706,
376,
13096,
5570,
1115,
518,
6377,
29938,
4352,
1115,
8853,
29938,
13338,
1115,
8853,
29938,
1837,
1115,
6796,
29938,
1688,
2271,
1204,
613,
3908,
29938,
1688,
2271,
29918,
333,
3108,
930,
1118,
13,
462,
462,
268,
426,
13,
462,
462,
308,
3908,
20401,
1115,
426,
13,
462,
462,
632,
376,
3166,
1115,
376,
771,
29916,
583,
613,
13,
462,
462,
632,
376,
1026,
1115,
8853,
14701,
29918,
333,
1115,
3908,
14701,
1204,
10758,
13,
462,
462,
632,
376,
13096,
5570,
1115,
518,
6377,
29938,
4352,
1115,
8853,
29938,
13338,
1115,
8853,
29938,
1837,
1115,
6796,
14630,
333,
613,
3908,
29938,
14701,
29918,
333,
3108,
12499,
1402,
13,
462,
462,
632,
376,
294,
1115,
376,
14701,
29908,
13,
462,
462,
308,
500,
13,
462,
462,
268,
2981,
13,
462,
462,
268,
8853,
29938,
348,
14800,
1115,
3908,
14701,
10758,
13,
462,
462,
268,
426,
13,
462,
462,
308,
3908,
4836,
1115,
426,
13,
462,
462,
632,
11119,
333,
1115,
3908,
14701,
3032,
333,
613,
13,
462,
462,
632,
376,
18121,
1204,
1115,
3908,
14701,
29889,
18121,
1204,
613,
13,
462,
462,
632,
376,
666,
1115,
3908,
14701,
29889,
666,
613,
13,
462,
462,
632,
376,
637,
1115,
3908,
14701,
29889,
637,
613,
13,
462,
462,
632,
376,
9891,
3057,
2539,
1115,
3908,
14701,
29889,
9891,
3057,
2539,
613,
13,
462,
462,
632,
376,
4230,
9692,
2539,
1115,
3908,
14701,
29889,
4230,
9692,
2539,
613,
13,
462,
462,
632,
376,
2218,
11911,
287,
2539,
1115,
3908,
14701,
29889,
2218,
11911,
287,
2539,
613,
13,
462,
462,
632,
376,
273,
4735,
537,
1115,
3908,
14701,
29889,
273,
4735,
537,
613,
13,
462,
462,
632,
376,
18157,
3057,
2539,
1115,
3908,
18157,
3057,
2539,
613,
13,
462,
462,
632,
376,
18157,
3057,
5709,
1115,
3908,
18157,
3057,
5709,
29908,
13,
462,
462,
308,
500,
13,
462,
462,
268,
500,
1402,
13,
462,
4706,
376,
294,
1115,
376,
771,
29916,
583,
29908,
13,
462,
1678,
500,
13,
18884,
2981,
13,
18884,
11117,
29938,
11014,
2396,
6389,
1839,
10289,
2033,
1118,
13,
18884,
11117,
29938,
13400,
2396,
6389,
1839,
13400,
2033,
29913,
13,
632,
2314,
13,
9651,
736,
1243,
26045,
29918,
11010,
29918,
17987,
7176,
29889,
15070,
29898,
2640,
29897,
13,
13,
4706,
10561,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
2886,
2141,
11014,
29898,
5085,
1839,
10289,
2033,
467,
13400,
29898,
5085,
1839,
13400,
11287,
13,
4706,
736,
1243,
26045,
29918,
11010,
29889,
15070,
29898,
2640,
29897,
13,
13,
1678,
732,
1509,
29918,
5085,
29898,
1688,
2271,
29918,
11010,
29892,
4423,
2433,
3126,
29918,
272,
29918,
689,
1495,
13,
1678,
732,
1509,
29918,
5085,
29898,
7529,
29918,
11010,
29892,
4423,
543,
1972,
1159,
13,
1678,
822,
1400,
29898,
1311,
29892,
1243,
2271,
29892,
8636,
1125,
13,
4706,
1121,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
7851,
29918,
650,
29898,
1688,
2271,
29897,
13,
4706,
1243,
2271,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
2886,
29918,
650,
3319,
15972,
333,
2396,
1121,
29889,
7851,
287,
29918,
333,
1800,
13,
4706,
565,
8636,
1839,
15480,
2033,
29901,
13,
9651,
12725,
29918,
1688,
2271,
29898,
1688,
2271,
1839,
29918,
333,
11287,
13,
4706,
736,
1243,
2271,
29918,
11010,
29889,
15070,
29898,
1688,
2271,
511,
29871,
29906,
29900,
29896,
29892,
11117,
5479,
2396,
3142,
29918,
1454,
877,
1688,
2271,
742,
1178,
29922,
1688,
2271,
1839,
29918,
333,
2033,
2915,
13,
13,
1678,
822,
13261,
29898,
1311,
1125,
13,
4706,
1243,
26045,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
2886,
580,
13,
4706,
363,
1243,
2271,
297,
1243,
26045,
29901,
13,
9651,
12725,
29918,
1688,
2271,
29898,
1688,
2271,
1839,
29918,
333,
11287,
13,
4706,
736,
15516,
29871,
29906,
29900,
29946,
13,
13,
13,
1753,
12725,
29918,
1688,
2271,
29898,
1688,
2271,
29918,
333,
1125,
13,
1678,
1243,
2271,
353,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
2886,
29918,
650,
3319,
15972,
333,
2396,
4669,
1204,
29898,
1688,
2271,
29918,
333,
26972,
13,
1678,
3667,
29889,
370,
441,
29918,
361,
29918,
13221,
593,
29918,
28997,
29898,
1688,
2271,
29897,
13,
13,
1678,
274,
16434,
353,
19476,
29889,
2585,
29889,
2917,
332,
800,
29889,
2886,
29918,
650,
3319,
29915,
4882,
2396,
5852,
1800,
13,
1678,
565,
451,
274,
16434,
29901,
13,
4706,
274,
16434,
353,
426,
13,
9651,
525,
16593,
12506,
2396,
29871,
29896,
29900,
29892,
13,
9651,
525,
3317,
22406,
2396,
29871,
29896,
29892,
13,
9651,
525,
10382,
24996,
2396,
29871,
29896,
29892,
13,
9651,
525,
14701,
3057,
10851,
2396,
29871,
29896,
13,
4706,
500,
13,
13,
1678,
410,
29916,
583,
353,
1051,
29898,
29885,
7443,
29889,
2585,
29889,
771,
29916,
583,
29889,
2886,
3101,
13,
1678,
10166,
29918,
3198,
261,
353,
9056,
14048,
5596,
261,
580,
13,
1678,
2854,
29918,
14701,
29918,
2798,
353,
29871,
29900,
13,
1678,
363,
10166,
297,
410,
29916,
583,
29901,
13,
4706,
1018,
29901,
13,
9651,
10166,
29918,
7328,
353,
285,
29908,
29912,
14701,
1839,
666,
2033,
6177,
29912,
14701,
1839,
637,
2033,
5038,
13,
9651,
396,
5399,
292,
565,
7395,
13,
9651,
1121,
353,
10166,
29918,
3198,
261,
29889,
3198,
29918,
14701,
29898,
14701,
29918,
7328,
29892,
274,
16434,
1839,
14701,
3057,
10851,
11287,
13,
9651,
565,
1121,
1839,
4882,
2033,
1275,
525,
14627,
2396,
13,
18884,
10166,
1839,
273,
4735,
537,
2033,
353,
1121,
1839,
273,
4735,
537,
2033,
13,
18884,
10166,
1839,
9891,
3057,
2539,
2033,
353,
12865,
29889,
12673,
29889,
3707,
580,
13,
18884,
1018,
29901,
13,
462,
1678,
19476,
29889,
2585,
29889,
771,
29916,
583,
29889,
5504,
29918,
650,
3319,
15972,
333,
2396,
10166,
1839,
29918,
333,
2033,
1118,
11117,
29938,
842,
2396,
10166,
1800,
13,
18884,
5174,
29901,
13,
462,
1678,
1596,
877,
2704,
29901,
1550,
16523,
292,
10166,
1495,
13,
462,
1678,
6773,
13,
9651,
1683,
29901,
13,
18884,
1018,
29901,
13,
462,
1678,
19476,
29889,
2585,
29889,
14701,
1688,
26045,
29889,
8143,
29918,
13011,
3319,
29915,
14701,
1204,
2396,
10166,
1839,
29918,
333,
2033,
1800,
13,
462,
1678,
19476,
29889,
2585,
29889,
771,
29916,
583,
29889,
8143,
29918,
650,
3319,
15972,
333,
2396,
10166,
1839,
29918,
333,
2033,
1800,
13,
462,
1678,
6773,
13,
18884,
5174,
29901,
13,
462,
1678,
1596,
877,
2704,
29901,
1550,
21228,
10166,
1495,
13,
462,
1678,
6773,
13,
9651,
835,
7346,
4136,
13,
13,
9651,
396,
15758,
1218,
13,
9651,
1121,
353,
10166,
29918,
3198,
261,
29889,
15480,
29918,
14701,
29898,
14701,
29918,
7328,
29892,
1243,
2271,
1839,
2271,
7464,
274,
16434,
1839,
14701,
3057,
10851,
11287,
13,
9651,
10166,
1688,
2271,
353,
426,
13,
18884,
525,
14701,
1204,
2396,
10166,
1839,
29918,
333,
7464,
13,
18884,
525,
1688,
2271,
1204,
2396,
1243,
2271,
1839,
29918,
333,
7464,
13,
18884,
525,
18157,
3057,
2539,
2396,
12865,
29889,
12673,
29889,
3707,
3285,
13,
18884,
525,
18157,
3057,
5709,
2396,
1121,
1839,
4882,
2033,
13,
9651,
500,
13,
9651,
19476,
29889,
2585,
29889,
14701,
1688,
26045,
29889,
5504,
29918,
650,
29898,
13,
18884,
11117,
14701,
1204,
2396,
10166,
1839,
29918,
333,
7464,
525,
1688,
2271,
1204,
2396,
1243,
2271,
1839,
29918,
333,
2033,
1118,
13,
18884,
11117,
29938,
842,
2396,
10166,
1688,
2271,
1118,
13,
18884,
24081,
814,
29922,
5574,
13,
9651,
1723,
13,
9651,
565,
1121,
1839,
4882,
2033,
1275,
525,
8698,
2396,
13,
18884,
2854,
29918,
14701,
29918,
2798,
4619,
29871,
29896,
13,
4706,
5174,
29901,
13,
9651,
1596,
877,
2704,
29901,
12725,
29918,
1688,
2271,
1495,
13,
9651,
6773,
13,
1678,
1018,
29901,
13,
4706,
1243,
2271,
1839,
18157,
4165,
3456,
2033,
353,
426,
13,
9651,
525,
1131,
3456,
2539,
2396,
12865,
29889,
12673,
29889,
3707,
3285,
13,
9651,
525,
3084,
14048,
3981,
2396,
2854,
29918,
14701,
29918,
2798,
29892,
13,
9651,
525,
4882,
2396,
525,
8698,
29915,
565,
313,
3084,
29918,
14701,
29918,
2798,
2804,
29900,
322,
2854,
29918,
14701,
29918,
2798,
1275,
7431,
29898,
771,
29916,
583,
876,
1683,
6702,
3846,
29915,
565,
2854,
29918,
14701,
29918,
2798,
29958,
29900,
1683,
525,
26061,
1495,
13,
4706,
500,
13,
4706,
19476,
29889,
2585,
29889,
1688,
26045,
29889,
5504,
29918,
650,
3319,
15972,
333,
2396,
1243,
2271,
1839,
29918,
333,
2033,
1118,
11117,
29938,
842,
2396,
1243,
2271,
1800,
13,
4706,
736,
5852,
13,
1678,
5174,
29901,
13,
4706,
736,
7700,
13,
2
] |
libs/clustering/ensembles/utils.py | greenelab/phenoplier | 3 | 6214 | """
Contains functions to generate and combine a clustering ensemble.
"""
import numpy as np
import pandas as pd
from sklearn.metrics import pairwise_distances
from sklearn.metrics import adjusted_rand_score as ari
from sklearn.metrics import adjusted_mutual_info_score as ami
from sklearn.metrics import normalized_mutual_info_score as nmi
from tqdm import tqdm
from clustering.utils import reset_estimator, compare_arrays
def generate_ensemble(data, clusterers: dict, attributes: list, affinity_matrix=None):
"""
It generates an ensemble from the data given a set of clusterers (a
clusterer is an instance of a clustering algorithm with a fixed set of
parameters).
Args:
data:
A numpy array, pandas dataframe, or any other structure supported
by the clusterers as data input.
clusterers:
A dictionary with clusterers specified in this format: { 'k-means
#1': KMeans(n_clusters=2), ... }
attributes:
A list of attributes to save in the final dataframe; for example,
including "n_clusters" will extract this attribute from the
estimator and include it in the final dataframe returned.
affinity_matrix:
If the clustering algorithm is AgglomerativeClustering (from
sklearn) and the linkage method is different than ward (which only
support euclidean distance), the affinity_matrix is given as data
input to the estimator instead of data.
Returns:
A pandas DataFrame with all the partitions generated by the clusterers.
Columns include the clusterer name/id, the partition, the estimator
parameters (obtained with the get_params() method) and any other
attribute specified.
"""
ensemble = []
for clus_name, clus_obj in tqdm(clusterers.items(), total=len(clusterers)):
# get partition
#
# for agglomerative clustering both data and affinity_matrix should be
# given; for ward linkage, data is used, and for the other linkage
# methods the affinity_matrix is used
if (type(clus_obj).__name__ == "AgglomerativeClustering") and (
clus_obj.linkage != "ward"
):
partition = clus_obj.fit_predict(affinity_matrix).astype(float)
else:
partition = clus_obj.fit_predict(data).astype(float)
# remove from partition noisy points (for example, if using DBSCAN)
partition[partition < 0] = np.nan
# get number of clusters
partition_no_nan = partition[~np.isnan(partition)]
n_clusters = np.unique(partition_no_nan).shape[0]
# stop if n_clusters <= 1
if n_clusters <= 1:
reset_estimator(clus_obj)
continue
res = pd.Series(
{
"clusterer_id": clus_name,
"clusterer_params": str(clus_obj.get_params()),
"partition": partition,
}
)
for attr in attributes:
if attr == "n_clusters" and not hasattr(clus_obj, attr):
res[attr] = n_clusters
else:
res[attr] = getattr(clus_obj, attr)
ensemble.append(res)
# for some estimators such as DBSCAN this is needed, because otherwise
# the estimator saves references of huge data structures not needed in
# this context
reset_estimator(clus_obj)
return pd.DataFrame(ensemble).set_index("clusterer_id")
def get_ensemble_distance_matrix(ensemble, n_jobs=1):
"""
Given an ensemble, it computes the coassociation matrix (a distance matrix
for all objects using the ensemble information). For each object pair, the
coassociation matrix contains the percentage of times the pair of objects
was clustered together in the ensemble.
Args:
ensemble:
A numpy array representing a set of clustering solutions on the same
data. Each row is a clustering solution (partition) and columns are
objects.
n_jobs:
The number of jobs used by the pairwise_distance matrix from
sklearn.
Returns:
A numpy array representing a square distance matrix for all objects
(coassociation matrix).
"""
def _compare(x, y):
xy = np.array([x, y]).T
xy = xy[~np.isnan(xy).any(axis=1)]
return (xy[:, 0] != xy[:, 1]).sum() / xy.shape[0]
return pairwise_distances(
ensemble.T, metric=_compare, n_jobs=n_jobs, force_all_finite="allow-nan"
)
def supraconsensus(ensemble, k, methods, selection_criterion, n_jobs=1, use_tqdm=False):
"""
It combines a clustering ensemble using a set of methods that the user can
specify. Each of these methods combines the ensemble and returns a single
partition. This function returns the combined partition that maximizes the
selection criterion.
Args:
ensemble:
a clustering ensemble (rows are partitions, columns are objects).
k:
the final number of clusters for the combined partition.
methods:
a list of methods to apply on the ensemble; each returns a combined
partition.
selection_criterion:
a function that represents the selection criterion; this function
has to accept an ensemble as the first argument, and a partition as
the second one.
n_jobs:
number of jobs.
use_tqdm:
ensembles/disables the use of tqdm to show a progress bar.
Returns:
Returns a tuple: (partition, best method name, best criterion value)
"""
from concurrent.futures import ProcessPoolExecutor, as_completed
methods_results = {}
with ProcessPoolExecutor(max_workers=n_jobs) as executor:
tasks = {executor.submit(m, ensemble, k): m.__name__ for m in methods}
for future in tqdm(
as_completed(tasks),
total=len(tasks),
disable=(not use_tqdm),
ncols=100,
):
method_name = tasks[future]
part = future.result()
criterion_value = selection_criterion(ensemble, part)
methods_results[method_name] = {
"partition": part,
"criterion_value": criterion_value,
}
# select the best performing method according to the selection criterion
best_method = max(
methods_results, key=lambda x: methods_results[x]["criterion_value"]
)
best_method_results = methods_results[best_method]
return (
best_method_results["partition"],
best_method,
best_method_results["criterion_value"],
)
def run_method_and_compute_agreement(method_func, ensemble_data, ensemble, k, **kwargs):
"""
Runs a consensus clustering method on the ensemble data, obtains the
consolidated partition with the desired number of clusters, and computes
a series of performance measures.
Args:
method_func:
A consensus function (first argument is either the ensemble or
the coassociation matrix derived from the ensemble).
ensemble_data:
A numpy array with the ensemble data that will be given to the
specified method. For evidence accumulation methods, this is the
coassociation matrix (a square matrix with the distance between
object pairs derived from the ensemble).
ensemble:
A numpy array representing the ensemble (partitions in rows, objects
in columns).
k:
The number of clusters to obtain from the ensemble data using the
specified method.
kwargs:
Other parameters passed to `method_func`.
Returns:
It returns a tuple with the data partition derived from the ensemble
data using the specified method, and some performance measures of this
partition.
"""
part = method_func(ensemble_data, k, **kwargs)
nmi_values = np.array(
[
compare_arrays(ensemble_member, part, nmi, use_weighting=True)
for ensemble_member in ensemble
]
)
ami_values = np.array(
[
compare_arrays(ensemble_member, part, ami, use_weighting=True)
for ensemble_member in ensemble
]
)
ari_values = np.array(
[
compare_arrays(ensemble_member, part, ari, use_weighting=True)
for ensemble_member in ensemble
]
)
performance_values = {
"ari_mean": np.mean(ari_values),
"ari_median": np.median(ari_values),
"ari_std": np.std(ari_values),
"ami_mean": np.mean(ami_values),
"ami_median": np.median(ami_values),
"ami_std": np.std(ami_values),
"nmi_mean": np.mean(nmi_values),
"nmi_median": np.median(nmi_values),
"nmi_std": np.std(nmi_values),
}
return part, performance_values
| [
1,
9995,
13,
21409,
3168,
304,
5706,
322,
14405,
263,
16993,
3241,
21285,
29889,
13,
15945,
29908,
13,
5215,
12655,
408,
7442,
13,
5215,
11701,
408,
10518,
13,
3166,
2071,
19668,
29889,
2527,
10817,
1053,
5101,
3538,
29918,
5721,
2925,
13,
3166,
2071,
19668,
29889,
2527,
10817,
1053,
10365,
287,
29918,
9502,
29918,
13628,
408,
263,
374,
13,
3166,
2071,
19668,
29889,
2527,
10817,
1053,
10365,
287,
29918,
6149,
950,
29918,
3888,
29918,
13628,
408,
18926,
13,
3166,
2071,
19668,
29889,
2527,
10817,
1053,
4226,
1891,
29918,
6149,
950,
29918,
3888,
29918,
13628,
408,
302,
2460,
13,
3166,
260,
29939,
18933,
1053,
260,
29939,
18933,
13,
13,
3166,
16993,
3241,
29889,
13239,
1053,
10092,
29918,
342,
326,
1061,
29892,
7252,
29918,
2378,
29879,
13,
13,
13,
1753,
5706,
29918,
24031,
29898,
1272,
29892,
9867,
414,
29901,
9657,
29892,
8393,
29901,
1051,
29892,
2756,
13593,
29918,
5344,
29922,
8516,
1125,
13,
1678,
9995,
13,
1678,
739,
16785,
385,
21285,
515,
278,
848,
2183,
263,
731,
310,
9867,
414,
313,
29874,
13,
1678,
9867,
261,
338,
385,
2777,
310,
263,
16993,
3241,
5687,
411,
263,
4343,
731,
310,
13,
1678,
4128,
467,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
848,
29901,
13,
9651,
319,
12655,
1409,
29892,
11701,
12205,
29892,
470,
738,
916,
3829,
6969,
13,
9651,
491,
278,
9867,
414,
408,
848,
1881,
29889,
13,
4706,
9867,
414,
29901,
13,
9651,
319,
8600,
411,
9867,
414,
6790,
297,
445,
3402,
29901,
426,
525,
29895,
29899,
1004,
550,
13,
9651,
396,
29896,
2396,
476,
6816,
550,
29898,
29876,
29918,
695,
504,
414,
29922,
29906,
511,
2023,
500,
13,
4706,
8393,
29901,
13,
9651,
319,
1051,
310,
8393,
304,
4078,
297,
278,
2186,
12205,
29936,
363,
1342,
29892,
13,
9651,
3704,
376,
29876,
29918,
695,
504,
414,
29908,
674,
6597,
445,
5352,
515,
278,
13,
9651,
4844,
1061,
322,
3160,
372,
297,
278,
2186,
12205,
4133,
29889,
13,
4706,
2756,
13593,
29918,
5344,
29901,
13,
9651,
960,
278,
16993,
3241,
5687,
338,
319,
1505,
29880,
12392,
1230,
6821,
504,
3241,
313,
3166,
13,
9651,
2071,
19668,
29897,
322,
278,
1544,
482,
1158,
338,
1422,
1135,
281,
538,
313,
4716,
871,
13,
9651,
2304,
321,
27511,
5418,
511,
278,
2756,
13593,
29918,
5344,
338,
2183,
408,
848,
13,
9651,
1881,
304,
278,
4844,
1061,
2012,
310,
848,
29889,
13,
13,
1678,
16969,
29901,
13,
4706,
319,
11701,
3630,
4308,
411,
599,
278,
23629,
5759,
491,
278,
9867,
414,
29889,
13,
4706,
12481,
29879,
3160,
278,
9867,
261,
1024,
29914,
333,
29892,
278,
8877,
29892,
278,
4844,
1061,
13,
4706,
4128,
313,
711,
2408,
287,
411,
278,
679,
29918,
7529,
580,
1158,
29897,
322,
738,
916,
13,
4706,
5352,
6790,
29889,
13,
1678,
9995,
13,
1678,
21285,
353,
5159,
13,
13,
1678,
363,
1067,
375,
29918,
978,
29892,
1067,
375,
29918,
5415,
297,
260,
29939,
18933,
29898,
19594,
414,
29889,
7076,
3285,
3001,
29922,
2435,
29898,
19594,
414,
22164,
13,
4706,
396,
679,
8877,
13,
4706,
396,
13,
4706,
396,
363,
946,
3820,
12392,
1230,
16993,
3241,
1716,
848,
322,
2756,
13593,
29918,
5344,
881,
367,
13,
4706,
396,
2183,
29936,
363,
281,
538,
1544,
482,
29892,
848,
338,
1304,
29892,
322,
363,
278,
916,
1544,
482,
13,
4706,
396,
3519,
278,
2756,
13593,
29918,
5344,
338,
1304,
13,
4706,
565,
313,
1853,
29898,
7009,
29918,
5415,
467,
1649,
978,
1649,
1275,
376,
29909,
1505,
29880,
12392,
1230,
6821,
504,
3241,
1159,
322,
313,
13,
9651,
1067,
375,
29918,
5415,
29889,
2324,
482,
2804,
376,
1328,
29908,
13,
308,
1125,
13,
9651,
8877,
353,
1067,
375,
29918,
5415,
29889,
9202,
29918,
27711,
29898,
3470,
13593,
29918,
5344,
467,
579,
668,
29898,
7411,
29897,
13,
4706,
1683,
29901,
13,
9651,
8877,
353,
1067,
375,
29918,
5415,
29889,
9202,
29918,
27711,
29898,
1272,
467,
579,
668,
29898,
7411,
29897,
13,
13,
4706,
396,
3349,
515,
8877,
694,
13344,
3291,
313,
1454,
1342,
29892,
565,
773,
6535,
7187,
2190,
29897,
13,
4706,
8877,
29961,
16707,
529,
29871,
29900,
29962,
353,
7442,
29889,
13707,
13,
13,
4706,
396,
679,
1353,
310,
24554,
13,
4706,
8877,
29918,
1217,
29918,
13707,
353,
8877,
29961,
30022,
9302,
29889,
275,
13707,
29898,
16707,
4638,
13,
4706,
302,
29918,
695,
504,
414,
353,
7442,
29889,
13092,
29898,
16707,
29918,
1217,
29918,
13707,
467,
12181,
29961,
29900,
29962,
13,
13,
4706,
396,
5040,
565,
302,
29918,
695,
504,
414,
5277,
29871,
29896,
13,
4706,
565,
302,
29918,
695,
504,
414,
5277,
29871,
29896,
29901,
13,
9651,
10092,
29918,
342,
326,
1061,
29898,
7009,
29918,
5415,
29897,
13,
9651,
6773,
13,
13,
4706,
620,
353,
10518,
29889,
19204,
29898,
13,
9651,
426,
13,
18884,
376,
19594,
261,
29918,
333,
1115,
1067,
375,
29918,
978,
29892,
13,
18884,
376,
19594,
261,
29918,
7529,
1115,
851,
29898,
7009,
29918,
5415,
29889,
657,
29918,
7529,
25739,
13,
18884,
376,
16707,
1115,
8877,
29892,
13,
9651,
500,
13,
4706,
1723,
13,
13,
4706,
363,
12421,
297,
8393,
29901,
13,
9651,
565,
12421,
1275,
376,
29876,
29918,
695,
504,
414,
29908,
322,
451,
756,
5552,
29898,
7009,
29918,
5415,
29892,
12421,
1125,
13,
18884,
620,
29961,
5552,
29962,
353,
302,
29918,
695,
504,
414,
13,
9651,
1683,
29901,
13,
18884,
620,
29961,
5552,
29962,
353,
679,
5552,
29898,
7009,
29918,
5415,
29892,
12421,
29897,
13,
13,
4706,
21285,
29889,
4397,
29898,
690,
29897,
13,
13,
4706,
396,
363,
777,
4844,
4097,
1316,
408,
6535,
7187,
2190,
445,
338,
4312,
29892,
1363,
6467,
13,
4706,
396,
278,
4844,
1061,
27401,
9282,
310,
12176,
848,
12286,
451,
4312,
297,
13,
4706,
396,
445,
3030,
13,
4706,
10092,
29918,
342,
326,
1061,
29898,
7009,
29918,
5415,
29897,
13,
13,
1678,
736,
10518,
29889,
17271,
29898,
24031,
467,
842,
29918,
2248,
703,
19594,
261,
29918,
333,
1159,
13,
13,
13,
1753,
679,
29918,
24031,
29918,
19244,
29918,
5344,
29898,
24031,
29892,
302,
29918,
9057,
29879,
29922,
29896,
1125,
13,
1678,
9995,
13,
1678,
11221,
385,
21285,
29892,
372,
2912,
267,
278,
1302,
21264,
362,
4636,
313,
29874,
5418,
4636,
13,
1678,
363,
599,
3618,
773,
278,
21285,
2472,
467,
1152,
1269,
1203,
5101,
29892,
278,
13,
1678,
1302,
21264,
362,
4636,
3743,
278,
19649,
310,
3064,
278,
5101,
310,
3618,
13,
1678,
471,
9867,
287,
4208,
297,
278,
21285,
29889,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
21285,
29901,
13,
9651,
319,
12655,
1409,
15783,
263,
731,
310,
16993,
3241,
6851,
373,
278,
1021,
13,
9651,
848,
29889,
7806,
1948,
338,
263,
16993,
3241,
1650,
313,
16707,
29897,
322,
4341,
526,
13,
9651,
3618,
29889,
13,
4706,
302,
29918,
9057,
29879,
29901,
13,
9651,
450,
1353,
310,
17643,
1304,
491,
278,
5101,
3538,
29918,
19244,
4636,
515,
13,
9651,
2071,
19668,
29889,
13,
13,
1678,
16969,
29901,
13,
4706,
319,
12655,
1409,
15783,
263,
6862,
5418,
4636,
363,
599,
3618,
13,
4706,
313,
1111,
21264,
362,
4636,
467,
13,
1678,
9995,
13,
13,
1678,
822,
903,
18307,
29898,
29916,
29892,
343,
1125,
13,
4706,
921,
29891,
353,
7442,
29889,
2378,
4197,
29916,
29892,
343,
14664,
29911,
13,
4706,
921,
29891,
353,
921,
29891,
29961,
30022,
9302,
29889,
275,
13707,
29898,
3594,
467,
1384,
29898,
8990,
29922,
29896,
4638,
13,
4706,
736,
313,
3594,
7503,
29892,
29871,
29900,
29962,
2804,
921,
29891,
7503,
29892,
29871,
29896,
14664,
2083,
580,
847,
921,
29891,
29889,
12181,
29961,
29900,
29962,
13,
13,
1678,
736,
5101,
3538,
29918,
5721,
2925,
29898,
13,
4706,
21285,
29889,
29911,
29892,
12714,
29922,
29918,
18307,
29892,
302,
29918,
9057,
29879,
29922,
29876,
29918,
9057,
29879,
29892,
4889,
29918,
497,
29918,
18925,
543,
9536,
29899,
13707,
29908,
13,
1678,
1723,
13,
13,
13,
1753,
13159,
336,
3200,
8841,
29898,
24031,
29892,
413,
29892,
3519,
29892,
9262,
29918,
29883,
5385,
291,
29892,
302,
29918,
9057,
29879,
29922,
29896,
29892,
671,
29918,
29873,
29939,
18933,
29922,
8824,
1125,
13,
1678,
9995,
13,
1678,
739,
4145,
1475,
263,
16993,
3241,
21285,
773,
263,
731,
310,
3519,
393,
278,
1404,
508,
13,
1678,
6084,
29889,
7806,
310,
1438,
3519,
4145,
1475,
278,
21285,
322,
3639,
263,
2323,
13,
1678,
8877,
29889,
910,
740,
3639,
278,
12420,
8877,
393,
5256,
7093,
278,
13,
1678,
9262,
28770,
291,
29889,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
21285,
29901,
13,
9651,
263,
16993,
3241,
21285,
313,
5727,
526,
23629,
29892,
4341,
526,
3618,
467,
13,
4706,
413,
29901,
13,
9651,
278,
2186,
1353,
310,
24554,
363,
278,
12420,
8877,
29889,
13,
4706,
3519,
29901,
13,
9651,
263,
1051,
310,
3519,
304,
3394,
373,
278,
21285,
29936,
1269,
3639,
263,
12420,
13,
9651,
8877,
29889,
13,
4706,
9262,
29918,
29883,
5385,
291,
29901,
13,
9651,
263,
740,
393,
11524,
278,
9262,
28770,
291,
29936,
445,
740,
13,
9651,
756,
304,
3544,
385,
21285,
408,
278,
937,
2980,
29892,
322,
263,
8877,
408,
13,
9651,
278,
1473,
697,
29889,
13,
4706,
302,
29918,
9057,
29879,
29901,
13,
9651,
1353,
310,
17643,
29889,
13,
4706,
671,
29918,
29873,
29939,
18933,
29901,
13,
9651,
5662,
1590,
793,
29914,
2218,
1849,
278,
671,
310,
260,
29939,
18933,
304,
1510,
263,
6728,
2594,
29889,
13,
13,
1678,
16969,
29901,
13,
4706,
16969,
263,
18761,
29901,
313,
16707,
29892,
1900,
1158,
1024,
29892,
1900,
28770,
291,
995,
29897,
13,
1678,
9995,
13,
1678,
515,
21984,
29889,
29888,
329,
1973,
1053,
10554,
11426,
13366,
29892,
408,
29918,
5729,
9446,
13,
13,
1678,
3519,
29918,
9902,
353,
6571,
13,
13,
1678,
411,
10554,
11426,
13366,
29898,
3317,
29918,
1287,
414,
29922,
29876,
29918,
9057,
29879,
29897,
408,
2279,
3406,
29901,
13,
4706,
9595,
353,
426,
4258,
3406,
29889,
7892,
29898,
29885,
29892,
21285,
29892,
413,
1125,
286,
17255,
978,
1649,
363,
286,
297,
3519,
29913,
13,
13,
4706,
363,
5434,
297,
260,
29939,
18933,
29898,
13,
9651,
408,
29918,
5729,
9446,
29898,
20673,
511,
13,
9651,
3001,
29922,
2435,
29898,
20673,
511,
13,
9651,
11262,
7607,
1333,
671,
29918,
29873,
29939,
18933,
511,
13,
9651,
302,
22724,
29922,
29896,
29900,
29900,
29892,
13,
308,
1125,
13,
9651,
1158,
29918,
978,
353,
9595,
29961,
29888,
9130,
29962,
13,
9651,
760,
353,
5434,
29889,
2914,
580,
13,
9651,
28770,
291,
29918,
1767,
353,
9262,
29918,
29883,
5385,
291,
29898,
24031,
29892,
760,
29897,
13,
13,
9651,
3519,
29918,
9902,
29961,
5696,
29918,
978,
29962,
353,
426,
13,
18884,
376,
16707,
1115,
760,
29892,
13,
18884,
376,
29883,
5385,
291,
29918,
1767,
1115,
28770,
291,
29918,
1767,
29892,
13,
9651,
500,
13,
13,
1678,
396,
1831,
278,
1900,
15859,
1158,
5034,
304,
278,
9262,
28770,
291,
13,
1678,
1900,
29918,
5696,
353,
4236,
29898,
13,
4706,
3519,
29918,
9902,
29892,
1820,
29922,
2892,
921,
29901,
3519,
29918,
9902,
29961,
29916,
29962,
3366,
29883,
5385,
291,
29918,
1767,
3108,
13,
1678,
1723,
13,
1678,
1900,
29918,
5696,
29918,
9902,
353,
3519,
29918,
9902,
29961,
13318,
29918,
5696,
29962,
13,
13,
1678,
736,
313,
13,
4706,
1900,
29918,
5696,
29918,
9902,
3366,
16707,
12436,
13,
4706,
1900,
29918,
5696,
29892,
13,
4706,
1900,
29918,
5696,
29918,
9902,
3366,
29883,
5385,
291,
29918,
1767,
12436,
13,
1678,
1723,
13,
13,
13,
1753,
1065,
29918,
5696,
29918,
392,
29918,
26017,
29918,
351,
276,
882,
29898,
5696,
29918,
9891,
29892,
21285,
29918,
1272,
29892,
21285,
29892,
413,
29892,
3579,
19290,
1125,
13,
1678,
9995,
13,
1678,
390,
6948,
263,
1136,
8841,
16993,
3241,
1158,
373,
278,
21285,
848,
29892,
4017,
29879,
278,
13,
1678,
1136,
17211,
630,
8877,
411,
278,
7429,
1353,
310,
24554,
29892,
322,
2912,
267,
13,
1678,
263,
3652,
310,
4180,
15366,
29889,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
1158,
29918,
9891,
29901,
13,
9651,
319,
1136,
8841,
740,
313,
4102,
2980,
338,
2845,
278,
21285,
470,
13,
9651,
278,
1302,
21264,
362,
4636,
10723,
515,
278,
21285,
467,
13,
4706,
21285,
29918,
1272,
29901,
13,
9651,
319,
12655,
1409,
411,
278,
21285,
848,
393,
674,
367,
2183,
304,
278,
13,
9651,
6790,
1158,
29889,
1152,
10757,
18414,
2785,
3519,
29892,
445,
338,
278,
13,
9651,
1302,
21264,
362,
4636,
313,
29874,
6862,
4636,
411,
278,
5418,
1546,
13,
9651,
1203,
11000,
10723,
515,
278,
21285,
467,
13,
4706,
21285,
29901,
13,
9651,
319,
12655,
1409,
15783,
278,
21285,
313,
1595,
2187,
297,
4206,
29892,
3618,
13,
9651,
297,
4341,
467,
13,
4706,
413,
29901,
13,
9651,
450,
1353,
310,
24554,
304,
4017,
515,
278,
21285,
848,
773,
278,
13,
9651,
6790,
1158,
29889,
13,
4706,
9049,
5085,
29901,
13,
9651,
5901,
4128,
4502,
304,
421,
5696,
29918,
9891,
1412,
13,
13,
1678,
16969,
29901,
13,
4706,
739,
3639,
263,
18761,
411,
278,
848,
8877,
10723,
515,
278,
21285,
13,
4706,
848,
773,
278,
6790,
1158,
29892,
322,
777,
4180,
15366,
310,
445,
13,
4706,
8877,
29889,
13,
1678,
9995,
13,
1678,
760,
353,
1158,
29918,
9891,
29898,
24031,
29918,
1272,
29892,
413,
29892,
3579,
19290,
29897,
13,
13,
1678,
302,
2460,
29918,
5975,
353,
7442,
29889,
2378,
29898,
13,
4706,
518,
13,
9651,
7252,
29918,
2378,
29879,
29898,
24031,
29918,
14242,
29892,
760,
29892,
302,
2460,
29892,
671,
29918,
7915,
292,
29922,
5574,
29897,
13,
9651,
363,
21285,
29918,
14242,
297,
21285,
13,
4706,
4514,
13,
1678,
1723,
13,
13,
1678,
18926,
29918,
5975,
353,
7442,
29889,
2378,
29898,
13,
4706,
518,
13,
9651,
7252,
29918,
2378,
29879,
29898,
24031,
29918,
14242,
29892,
760,
29892,
18926,
29892,
671,
29918,
7915,
292,
29922,
5574,
29897,
13,
9651,
363,
21285,
29918,
14242,
297,
21285,
13,
4706,
4514,
13,
1678,
1723,
13,
13,
1678,
263,
374,
29918,
5975,
353,
7442,
29889,
2378,
29898,
13,
4706,
518,
13,
9651,
7252,
29918,
2378,
29879,
29898,
24031,
29918,
14242,
29892,
760,
29892,
263,
374,
29892,
671,
29918,
7915,
292,
29922,
5574,
29897,
13,
9651,
363,
21285,
29918,
14242,
297,
21285,
13,
4706,
4514,
13,
1678,
1723,
13,
13,
1678,
4180,
29918,
5975,
353,
426,
13,
4706,
376,
1306,
29918,
12676,
1115,
7442,
29889,
12676,
29898,
1306,
29918,
5975,
511,
13,
4706,
376,
1306,
29918,
2168,
713,
1115,
7442,
29889,
2168,
713,
29898,
1306,
29918,
5975,
511,
13,
4706,
376,
1306,
29918,
4172,
1115,
7442,
29889,
4172,
29898,
1306,
29918,
5975,
511,
13,
4706,
376,
4479,
29918,
12676,
1115,
7442,
29889,
12676,
29898,
4479,
29918,
5975,
511,
13,
4706,
376,
4479,
29918,
2168,
713,
1115,
7442,
29889,
2168,
713,
29898,
4479,
29918,
5975,
511,
13,
4706,
376,
4479,
29918,
4172,
1115,
7442,
29889,
4172,
29898,
4479,
29918,
5975,
511,
13,
4706,
376,
29876,
2460,
29918,
12676,
1115,
7442,
29889,
12676,
29898,
29876,
2460,
29918,
5975,
511,
13,
4706,
376,
29876,
2460,
29918,
2168,
713,
1115,
7442,
29889,
2168,
713,
29898,
29876,
2460,
29918,
5975,
511,
13,
4706,
376,
29876,
2460,
29918,
4172,
1115,
7442,
29889,
4172,
29898,
29876,
2460,
29918,
5975,
511,
13,
1678,
500,
13,
13,
1678,
736,
760,
29892,
4180,
29918,
5975,
13,
2
] |
rest_slack/app_settings.py | jordaneremieff/django-rest-slack | 1 | 41413 | <reponame>jordaneremieff/django-rest-slack<gh_stars>1-10
import os
from django.conf import settings
SLACK_CLIENT_ID = getattr(settings, 'SLACK_CLIENT_ID', os.environ.get('SLACK_CLIENT_ID'))
SLACK_CLIENT_SECRET = getattr(settings, 'SLACK_CLIENT_SECRET', os.environ.get('SLACK_CLIENT_SECRET'))
SLACK_VERIFICATION_TOKEN = getattr(settings, 'SLACK_VERIFICATION_TOKEN', os.environ.get('SLACK_VERIFICATION_TOKEN'))
SLACK_BOT_USER_TOKEN = getattr(settings, 'SLACK_BOT_USER_TOKEN', os.environ.get('SLACK_BOT_USER_TOKEN'))
REST_FRAMEWORK = getattr(settings, 'REST_FRAMEWORK', {'EXCEPTION_HANDLER': 'rest_framework.views.exception_handler'})
| [
1,
529,
276,
1112,
420,
29958,
29926,
536,
273,
14992,
347,
600,
29914,
14095,
29899,
5060,
29899,
29879,
2364,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
2897,
13,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
13,
13,
12750,
11375,
29918,
27205,
3919,
29918,
1367,
353,
679,
5552,
29898,
11027,
29892,
525,
12750,
11375,
29918,
27205,
3919,
29918,
1367,
742,
2897,
29889,
21813,
29889,
657,
877,
12750,
11375,
29918,
27205,
3919,
29918,
1367,
8785,
13,
13,
13,
12750,
11375,
29918,
27205,
3919,
29918,
1660,
22245,
29911,
353,
29871,
679,
5552,
29898,
11027,
29892,
525,
12750,
11375,
29918,
27205,
3919,
29918,
1660,
22245,
29911,
742,
2897,
29889,
21813,
29889,
657,
877,
12750,
11375,
29918,
27205,
3919,
29918,
1660,
22245,
29911,
8785,
13,
13,
13,
12750,
11375,
29918,
5348,
6545,
28541,
29918,
4986,
29968,
1430,
353,
679,
5552,
29898,
11027,
29892,
525,
12750,
11375,
29918,
5348,
6545,
28541,
29918,
4986,
29968,
1430,
742,
2897,
29889,
21813,
29889,
657,
877,
12750,
11375,
29918,
5348,
6545,
28541,
29918,
4986,
29968,
1430,
8785,
13,
13,
13,
12750,
11375,
29918,
29933,
2891,
29918,
11889,
29918,
4986,
29968,
1430,
353,
679,
5552,
29898,
11027,
29892,
525,
12750,
11375,
29918,
29933,
2891,
29918,
11889,
29918,
4986,
29968,
1430,
742,
2897,
29889,
21813,
29889,
657,
877,
12750,
11375,
29918,
29933,
2891,
29918,
11889,
29918,
4986,
29968,
1430,
8785,
13,
13,
13,
1525,
1254,
29918,
29943,
4717,
2303,
11686,
29968,
353,
679,
5552,
29898,
11027,
29892,
525,
1525,
1254,
29918,
29943,
4717,
2303,
11686,
29968,
742,
11117,
5746,
4741,
7982,
2725,
29918,
29950,
9468,
29931,
1001,
2396,
525,
5060,
29918,
4468,
29889,
7406,
29889,
11739,
29918,
13789,
29915,
1800,
13,
2
] |
Src/Python/Recently Used List/test_rul.py | foutoucour/TDD-Katas | 4 | 100603 | import unittest
from rul import RecentlyUsedList
class RecentlyUsedListTests(unittest.TestCase):
def test_creating_a_new_list(self):
rul = RecentlyUsedList()
self.assertEqual(len(rul), 0)
def test_inserting_an_item(self):
rul = RecentlyUsedList()
item = 'item'
rul.insert(item)
self.assertEqual(len(rul), 1)
self.assertEqual(rul[0], item)
def test_inserting_two_unique_items(self):
rul = RecentlyUsedList()
rul.insert('first')
most_recent_item = 'second'
rul.insert(most_recent_item)
self.assertEqual(rul[0], most_recent_item)
def test_inserting_a_duplicate(self):
rul = RecentlyUsedList()
duplicate = 'b'
for item in 'a', duplicate, 'c', duplicate:
rul.insert(item)
self.assertEqual(len(rul), 3)
self.assertEqual(rul[0], duplicate)
| [
1,
1053,
443,
27958,
13,
3166,
364,
352,
1053,
3599,
2705,
29965,
8485,
1293,
13,
13,
1990,
3599,
2705,
29965,
8485,
1293,
24376,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
1678,
822,
1243,
29918,
1037,
1218,
29918,
29874,
29918,
1482,
29918,
1761,
29898,
1311,
1125,
13,
4706,
364,
352,
353,
3599,
2705,
29965,
8485,
1293,
580,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
29878,
352,
511,
29871,
29900,
29897,
13,
13,
1678,
822,
1243,
29918,
262,
643,
1259,
29918,
273,
29918,
667,
29898,
1311,
1125,
13,
4706,
364,
352,
353,
3599,
2705,
29965,
8485,
1293,
580,
13,
4706,
2944,
353,
525,
667,
29915,
13,
4706,
364,
352,
29889,
7851,
29898,
667,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
29878,
352,
511,
29871,
29896,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29878,
352,
29961,
29900,
1402,
2944,
29897,
13,
13,
1678,
822,
1243,
29918,
262,
643,
1259,
29918,
10184,
29918,
13092,
29918,
7076,
29898,
1311,
1125,
13,
4706,
364,
352,
353,
3599,
2705,
29965,
8485,
1293,
580,
13,
4706,
364,
352,
29889,
7851,
877,
4102,
1495,
13,
4706,
1556,
29918,
276,
1760,
29918,
667,
353,
525,
7496,
29915,
13,
4706,
364,
352,
29889,
7851,
29898,
3242,
29918,
276,
1760,
29918,
667,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29878,
352,
29961,
29900,
1402,
1556,
29918,
276,
1760,
29918,
667,
29897,
13,
13,
1678,
822,
1243,
29918,
262,
643,
1259,
29918,
29874,
29918,
20908,
5926,
29898,
1311,
1125,
13,
4706,
364,
352,
353,
3599,
2705,
29965,
8485,
1293,
580,
13,
4706,
7929,
353,
525,
29890,
29915,
13,
4706,
363,
2944,
297,
525,
29874,
742,
7929,
29892,
525,
29883,
742,
7929,
29901,
13,
9651,
364,
352,
29889,
7851,
29898,
667,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2435,
29898,
29878,
352,
511,
29871,
29941,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29878,
352,
29961,
29900,
1402,
7929,
29897,
13,
2
] |
tests/BasicLrTraining.py | felipessalvatore/logical-robustness | 0 | 120083 | <reponame>felipessalvatore/logical-robustness<filename>tests/BasicLrTraining.py
import numpy as np
import pandas as pd
import os
import sys
import inspect
import unittest
from joblib import load
currentdir = os.path.dirname(
os.path.abspath(
inspect.getfile(
inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from src.lr.text_processing.util import pre_process_nli_df # noqa
from src.lr.training.util import get_binary_label, get_ternary_label # noqa
from src.lr.models.logistic_regression import LRWrapper # noqa
from src.lr.training.language_representation import BOW, Tfidf # noqa
data_path = parentdir + "/src/data/toy/train.csv"
assert os.path.exists(data_path)
class BasicLrTraining(unittest.TestCase):
@classmethod
def setUp(cls):
df = pd.read_csv(data_path)
pre_process_nli_df(df)
cls.df = df
cls.path = "test.joblib"
@classmethod
def tearDown(cls):
if os.path.exists(cls.path):
os.remove(cls.path)
def test_train_binary_BOW(self):
hyperparams = {"RepresentationFunction": BOW,
"num_words": 500,
"label_translation": get_binary_label,
"penalty": "l2",
"C": 1,
'solver': 'lbfgs'}
lr = LRWrapper(hyperparams)
lr.fit(self.df)
acc = lr.get_acc(self.df)
baseline = (
(self.df.label.value_counts() /
self.df.shape[0])[
1:]).sum()
msg = "acc = {:.2f} baseline = {:.2f}".format(acc, baseline)
self.assertTrue(acc > baseline, msg)
def test_train_ternary_Tfidf(self):
hyperparams = {"RepresentationFunction": Tfidf,
"max_features": 500,
"label_translation": get_ternary_label,
"penalty": "l2",
"C": 1,
'solver': 'lbfgs'}
lr = LRWrapper(hyperparams)
lr.fit(self.df)
acc = lr.get_acc(self.df)
baseline = 0.4
msg = "acc = {:.2f} baseline = {:.2f}".format(acc, baseline)
self.assertTrue(acc > baseline, msg)
def test_save(self):
hyperparams = {"RepresentationFunction": Tfidf,
"max_features": 500,
"label_translation": get_ternary_label,
"penalty": "l2",
"C": 1,
'solver': 'lbfgs'}
lr = LRWrapper(hyperparams)
lr.fit(self.df)
scores = lr.get_acc(self.df)
lr.save(self.path)
del lr
lr = load(self.path)
new_scores = lr.get_acc(self.df)
msg = "problem to save results"
self.assertTrue(scores == new_scores, msg)
if __name__ == '__main__':
unittest.main(verbosity=2)
| [
1,
529,
276,
1112,
420,
29958,
13287,
666,
404,
284,
29894,
6082,
29914,
1188,
936,
29899,
13716,
504,
2264,
29966,
9507,
29958,
21150,
29914,
16616,
29931,
29878,
5323,
2827,
29889,
2272,
13,
5215,
12655,
408,
7442,
13,
5215,
11701,
408,
10518,
13,
5215,
2897,
13,
5215,
10876,
13,
5215,
16096,
13,
5215,
443,
27958,
13,
3166,
4982,
1982,
1053,
2254,
13,
13,
13,
3784,
3972,
353,
2897,
29889,
2084,
29889,
25721,
29898,
13,
1678,
2897,
29889,
2084,
29889,
370,
1028,
493,
29898,
13,
4706,
16096,
29889,
657,
1445,
29898,
13,
9651,
16096,
29889,
3784,
2557,
580,
4961,
13,
3560,
3972,
353,
2897,
29889,
2084,
29889,
25721,
29898,
3784,
3972,
29897,
13,
9675,
29889,
2084,
29889,
7851,
29898,
29900,
29892,
3847,
3972,
29897,
13,
13,
3166,
4765,
29889,
29212,
29889,
726,
29918,
19170,
29889,
4422,
1053,
758,
29918,
5014,
29918,
29876,
492,
29918,
2176,
29871,
396,
694,
25621,
13,
3166,
4765,
29889,
29212,
29889,
26495,
29889,
4422,
1053,
679,
29918,
19541,
29918,
1643,
29892,
679,
29918,
725,
653,
29918,
1643,
29871,
396,
694,
25621,
13,
3166,
4765,
29889,
29212,
29889,
9794,
29889,
1188,
4695,
29918,
276,
11476,
1053,
365,
29934,
15646,
29871,
396,
694,
25621,
13,
3166,
4765,
29889,
29212,
29889,
26495,
29889,
11675,
29918,
276,
26081,
1053,
350,
9806,
29892,
323,
29888,
333,
29888,
29871,
396,
694,
25621,
13,
13,
13,
1272,
29918,
2084,
353,
3847,
3972,
718,
5591,
4351,
29914,
1272,
29914,
517,
29891,
29914,
14968,
29889,
7638,
29908,
13,
9294,
2897,
29889,
2084,
29889,
9933,
29898,
1272,
29918,
2084,
29897,
13,
13,
13,
1990,
19219,
29931,
29878,
5323,
2827,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
731,
3373,
29898,
25932,
1125,
13,
4706,
4489,
353,
10518,
29889,
949,
29918,
7638,
29898,
1272,
29918,
2084,
29897,
13,
4706,
758,
29918,
5014,
29918,
29876,
492,
29918,
2176,
29898,
2176,
29897,
13,
4706,
1067,
29879,
29889,
2176,
353,
4489,
13,
4706,
1067,
29879,
29889,
2084,
353,
376,
1688,
29889,
9057,
1982,
29908,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
734,
279,
6767,
29898,
25932,
1125,
13,
4706,
565,
2897,
29889,
2084,
29889,
9933,
29898,
25932,
29889,
2084,
1125,
13,
9651,
2897,
29889,
5992,
29898,
25932,
29889,
2084,
29897,
13,
13,
1678,
822,
1243,
29918,
14968,
29918,
19541,
29918,
8456,
29956,
29898,
1311,
1125,
13,
4706,
11266,
7529,
353,
8853,
1123,
26081,
6678,
1115,
350,
9806,
29892,
13,
462,
539,
376,
1949,
29918,
9303,
1115,
29871,
29945,
29900,
29900,
29892,
13,
462,
539,
376,
1643,
29918,
3286,
18411,
1115,
679,
29918,
19541,
29918,
1643,
29892,
13,
462,
539,
376,
2238,
18745,
1115,
376,
29880,
29906,
613,
13,
462,
539,
376,
29907,
1115,
29871,
29896,
29892,
13,
462,
539,
525,
2929,
369,
2396,
525,
29880,
1635,
3174,
10827,
13,
4706,
301,
29878,
353,
365,
29934,
15646,
29898,
24947,
7529,
29897,
13,
4706,
301,
29878,
29889,
9202,
29898,
1311,
29889,
2176,
29897,
13,
4706,
1035,
353,
301,
29878,
29889,
657,
29918,
5753,
29898,
1311,
29889,
2176,
29897,
13,
4706,
2362,
5570,
353,
313,
13,
9651,
313,
1311,
29889,
2176,
29889,
1643,
29889,
1767,
29918,
2798,
29879,
580,
847,
13,
632,
1583,
29889,
2176,
29889,
12181,
29961,
29900,
2314,
29961,
13,
462,
29896,
29901,
14664,
2083,
580,
13,
4706,
10191,
353,
376,
5753,
353,
12365,
29889,
29906,
29888,
29913,
2362,
5570,
29871,
353,
12365,
29889,
29906,
29888,
29913,
1642,
4830,
29898,
5753,
29892,
2362,
5570,
29897,
13,
4706,
1583,
29889,
9294,
5574,
29898,
5753,
1405,
2362,
5570,
29892,
10191,
29897,
13,
13,
1678,
822,
1243,
29918,
14968,
29918,
725,
653,
29918,
29911,
29888,
333,
29888,
29898,
1311,
1125,
13,
4706,
11266,
7529,
353,
8853,
1123,
26081,
6678,
1115,
323,
29888,
333,
29888,
29892,
13,
462,
539,
376,
3317,
29918,
22100,
1115,
29871,
29945,
29900,
29900,
29892,
13,
462,
539,
376,
1643,
29918,
3286,
18411,
1115,
679,
29918,
725,
653,
29918,
1643,
29892,
13,
462,
539,
376,
2238,
18745,
1115,
376,
29880,
29906,
613,
13,
462,
539,
376,
29907,
1115,
29871,
29896,
29892,
13,
462,
539,
525,
2929,
369,
2396,
525,
29880,
1635,
3174,
10827,
13,
4706,
301,
29878,
353,
365,
29934,
15646,
29898,
24947,
7529,
29897,
13,
4706,
301,
29878,
29889,
9202,
29898,
1311,
29889,
2176,
29897,
13,
4706,
1035,
353,
301,
29878,
29889,
657,
29918,
5753,
29898,
1311,
29889,
2176,
29897,
13,
4706,
2362,
5570,
353,
29871,
29900,
29889,
29946,
13,
4706,
10191,
353,
376,
5753,
353,
12365,
29889,
29906,
29888,
29913,
2362,
5570,
29871,
353,
12365,
29889,
29906,
29888,
29913,
1642,
4830,
29898,
5753,
29892,
2362,
5570,
29897,
13,
4706,
1583,
29889,
9294,
5574,
29898,
5753,
1405,
2362,
5570,
29892,
10191,
29897,
13,
13,
1678,
822,
1243,
29918,
7620,
29898,
1311,
1125,
13,
4706,
11266,
7529,
353,
8853,
1123,
26081,
6678,
1115,
323,
29888,
333,
29888,
29892,
13,
462,
539,
376,
3317,
29918,
22100,
1115,
29871,
29945,
29900,
29900,
29892,
13,
462,
539,
376,
1643,
29918,
3286,
18411,
1115,
679,
29918,
725,
653,
29918,
1643,
29892,
13,
462,
539,
376,
2238,
18745,
1115,
376,
29880,
29906,
613,
13,
462,
539,
376,
29907,
1115,
29871,
29896,
29892,
13,
462,
539,
525,
2929,
369,
2396,
525,
29880,
1635,
3174,
10827,
13,
4706,
301,
29878,
353,
365,
29934,
15646,
29898,
24947,
7529,
29897,
13,
4706,
301,
29878,
29889,
9202,
29898,
1311,
29889,
2176,
29897,
13,
4706,
19435,
353,
301,
29878,
29889,
657,
29918,
5753,
29898,
1311,
29889,
2176,
29897,
13,
4706,
301,
29878,
29889,
7620,
29898,
1311,
29889,
2084,
29897,
13,
4706,
628,
301,
29878,
13,
4706,
301,
29878,
353,
2254,
29898,
1311,
29889,
2084,
29897,
13,
4706,
716,
29918,
1557,
2361,
353,
301,
29878,
29889,
657,
29918,
5753,
29898,
1311,
29889,
2176,
29897,
13,
4706,
10191,
353,
376,
17199,
304,
4078,
2582,
29908,
13,
4706,
1583,
29889,
9294,
5574,
29898,
1557,
2361,
1275,
716,
29918,
1557,
2361,
29892,
10191,
29897,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
443,
27958,
29889,
3396,
29898,
18248,
359,
537,
29922,
29906,
29897,
13,
2
] |
Game_AI_and_Reinforcement_Learning/ConnectX/v2/actor.py | BEPb/Python-100-days | 16 | 46340 | """
Python 3.9 программа самостоятельной игры агентов текущего и предыдущего покаления
программа на Python по изучению обучения с подкреплением - Reinforcement Learning
Название файла actor.py
Version: 0.1
Author: <NAME>
Date: 2021-12-23
"""
import numpy as np
import parl
import os
from alphazero_agent import create_agent
from MCTS import MCTS
from Arena import Arena
from utils import win_loss_draw
@parl.remote_class(wait=False)
class Actor(object):
def __init__(self, game, args, seed): # инициализация класса
np.random.seed(seed)
os.environ['OMP_NUM_THREADS'] = "1"
self.game = game # экземпляр (объект) класса доски и игры между двумя игроками
self.args = args # принимает все аргументы из главной программы
# 'master_address': 'localhost:8010', # главный адрес кластера xparl
# 'actors_num': 1, # количество удаленных участников
# 'numIters': 1, # общее количество итераций
# 'numEps': 1, # Количество полных игр с самостоятельной игрой для моделирования во время новой итерации.
# 'arenaCompare': 50, # Количество игр, которые нужно сыграть во время игры на арене (питтинг)
# 'numMCTSSims': 800, # Количество игровых ходов для моделирования MCTS.
# 'updateThreshold': 0.8, # пороговое или большее количество игр
# 'cpuct': 4, # CPUCT parameter
# 'dirichletAlpha': 1.0, # альфа-параметр шума дирихле
# 'numItersForTrainExamplesHistory': 20, # история примеров из последних итераций
# 'checkpoint': './saved_model/', # папка для сохранения моделей и обучающих примеров
# neural network of previous generation
# нейронная сеть предыдущего поколения
self.previous_agent = create_agent(self.game, cuda=False)
# neural network of current generation
# нейронная сеть текущего поколения
self.current_agent = create_agent(self.game, cuda=False)
# MCTS of previous generation
# MCTS предыдущего поколения
self.previous_mcts = MCTS(
self.game, self.previous_agent, self.args, dirichlet_noise=True)
# MCTS of current generation
# MCTS текущего поколения
self.current_mcts = MCTS(
self.game, self.current_agent, self.args, dirichlet_noise=True)
def self_play(self, current_weights, game_num):
"""
Сбор данных о тренировках путем самостоятельной игры.
Аргументы:
current_weights (numpy.array): последние веса нейронной сети
game_num (int): номер игры для самостоятельной игры
Возврат:
train_examples (список): примеры формы (canonicalBoard, currPlayer, pi, v)
"""
print('Самостоятельная игра одного из созданных агентов (использует одно ядро)')
# update weights of current neural network with latest weights
# обновить веса текущей нейронной сети с последними весами
self.current_agent.set_weights(current_weights)
train_examples = [] # создаем пустую таблицу (список) тренировки
for _ in range(game_num):
print('Начинается игра №', _)
# reset node state of MCTS
print('сбросить состояние узла MCTS')
self.current_mcts = MCTS(self.game, self.current_agent, self.args, dirichlet_noise=True)
print('тренировка узла MCTS')
train_examples.extend(self._executeEpisode())
# _executeEpisode() - функция одной игры
return train_examples
def pitting(self, previous_weights, current_weights, games_num):
"""Борьба между агентом предыдущего поколения и агентом текущего поколения
Аргументы:
previous_weights (numpy.array): веса нейронной сети предыдущего поколения
current_weights (numpy.array): веса нейронной сети текущего поколения
game_num (int): количество боев в игре
Возврат:
кортеж из (номер игры, в которой выиграл предыдущий агент, номер игры, в которой выиграл текущий агент,
номер игры, в которой был проведен розыгрыш)
"""
print('Борьба')
# update weights of previous and current neural network
# обновить веса предыдущей и текущей нейронной сети
self.previous_agent.set_weights(previous_weights)
self.current_agent.set_weights(current_weights)
# reset node state of MCTS
# сбросить состояние узла MCTS
print('сбросить состояние узла MCTS перед ареной')
self.previous_mcts = MCTS(self.game, self.previous_agent, self.args)
self.current_mcts = MCTS(self.game, self.current_agent, self.args)
arena = Arena(
lambda x: np.argmax(self.previous_mcts.getActionProb(x, temp=0)),
lambda x: np.argmax(self.current_mcts.getActionProb(x, temp=0)),
self.game)
previous_wins, current_wins, draws = arena.playGames(games_num)
return (previous_wins, current_wins, draws) # возвращает количество предудущих побед, текущих побед и ничьих
def evaluate_test_dataset(self, current_weights, test_dataset):
"""
Оценить эффективность новейших нейронных сетей
Аргументы:
current_weights (numpy.array): последние веса нейронной сети
test_dataset (список): номер игры для самостоятельной игры
Возврат:
кортеж из (количество совершенных ходов, количество хороших ходов)
"""
print('Эволюция')
# update weights of current neural network with latest weights
# обновить веса текущей нейронной сети с последними весами
self.current_agent.set_weights(current_weights)
# определяем качество проведенной игры
perfect_move_count, good_move_count = 0, 0
for data in test_dataset:
self.current_mcts = MCTS(self.game, self.current_agent, self.args) # обращаемся к дереву MCTS
x = self.game.getCanonicalForm(data['board'], data['player'])
agent_move = int(np.argmax(self.current_mcts.getActionProb(x, temp=0))) # количество ходов
moves = data["move_score"] # список очков
perfect_score = max(moves) # определяем максимальное значение в списке очков
perfect_moves = [i for i in range(7) if moves[i] == perfect_score] # выбираем 7 лучших
if agent_move in perfect_moves:
perfect_move_count += 1 # подсчет идеальных ходов
print('perfect_move_count', perfect_move_count)
print('Определяем победа\пройгрыш\ничья - ', win_loss_draw(moves[agent_move]))
if win_loss_draw(moves[agent_move]) == win_loss_draw(perfect_score):
good_move_count += 1 # подсчет хороших ходов
print('good_move_count', good_move_count)
return (perfect_move_count, good_move_count)
def _executeEpisode(self): # функция одной игры
"""
Эта функция выполняет один эпизод самостоятельной игры, начиная с игрока 1.
По ходу игры каждый ход добавляется в качестве обучающего примера к
trainExamples. Игра длится до конца. После игры
заканчивается, результат игры используется для присвоения значений каждому примеру
в поезде Примеры.
Он использует temp = 1, если episodeStep <tempThresholdStep, и после этого
использует temp = 0.
Возврат:
trainExamples: список примеров формы (canonicalBoard, currPlayer, pi, v)
pi - вектор политики, проинформированный MCTS, v - +1, если
игрок в конце концов выиграл игру, иначе -1.
"""
print('Эпизод одной игры')
trainExamples = []
board = self.game.getInitBoard()
self.curPlayer = 1
episodeStep = 0
while True:
episodeStep += 1
print('Самостоятельная игра агентов текущего поколения и предыдущего, ход = ', episodeStep)
canonicalBoard = self.game.getCanonicalForm(board, self.curPlayer)
temp = int(episodeStep < self.args.tempThresholdStep)
pi = self.current_mcts.getActionProb(canonicalBoard, temp=temp)
sym = self.game.getSymmetries(canonicalBoard, pi)
for b, p in sym: # board, pi
trainExamples.append([b, self.curPlayer, p, None])
action = np.random.choice(len(pi), p=pi)
board, self.curPlayer = self.game.getNextState(
board, self.curPlayer, action)
r = self.game.getGameEnded(board, self.curPlayer)
if r != 0:
return [(x[0], x[2], r * ((-1)**(x[1] != self.curPlayer)))
for x in trainExamples]
| [
1,
9995,
13,
11980,
29871,
29941,
29889,
29929,
20796,
1155,
8761,
6428,
28787,
10689,
3541,
1097,
29969,
3648,
516,
2399,
1382,
2402,
588,
606,
2102,
4184,
1520,
2402,
588,
25693,
6052,
13,
5945,
2194,
29959,
1155,
665,
5132,
733,
29307,
1093,
7506,
27572,
12395,
531,
3693,
10179,
29964,
27414,
448,
18334,
1454,
13561,
29257,
13,
19193,
7617,
1755,
6725,
29977,
684,
11339,
29889,
2272,
13,
13,
6594,
29901,
29871,
29900,
29889,
29896,
13,
13720,
29901,
529,
5813,
29958,
13,
2539,
29901,
29871,
29906,
29900,
29906,
29896,
29899,
29896,
29906,
29899,
29906,
29941,
13,
15945,
29908,
13,
5215,
12655,
408,
7442,
13,
5215,
24590,
13,
5215,
2897,
13,
3166,
394,
561,
834,
1489,
29918,
14748,
1053,
1653,
29918,
14748,
13,
3166,
341,
1783,
29903,
1053,
341,
1783,
29903,
13,
3166,
26053,
1053,
26053,
13,
3166,
3667,
29879,
1053,
5401,
29918,
6758,
29918,
4012,
13,
13,
13,
29992,
862,
29880,
29889,
16674,
29918,
1990,
29898,
10685,
29922,
8824,
29897,
13,
1990,
319,
2801,
29898,
3318,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3748,
29892,
6389,
29892,
16717,
1125,
29871,
396,
606,
11026,
12172,
1902,
5274,
9955,
13637,
13,
4706,
7442,
29889,
8172,
29889,
26776,
29898,
26776,
29897,
13,
4706,
2897,
29889,
21813,
1839,
29949,
3580,
29918,
13967,
29918,
4690,
16310,
29903,
2033,
353,
376,
29896,
29908,
13,
4706,
1583,
29889,
11802,
353,
3748,
29871,
396,
18796,
20117,
29964,
13550,
313,
4389,
30055,
3506,
29932,
29897,
9955,
13637,
1447,
1305,
606,
10689,
3541,
11012,
14700,
5010,
10689,
576,
13021,
13,
4706,
1583,
29889,
5085,
353,
6389,
29871,
396,
1695,
7949,
1257,
6495,
5339,
3325,
2387,
3327,
1866,
13986,
2082,
20796,
5588,
13,
4706,
396,
268,
525,
6207,
29918,
7328,
2396,
525,
7640,
29901,
29947,
29900,
29896,
29900,
742,
29871,
396,
13986,
2370,
11437,
19961,
9955,
4267,
494,
921,
862,
29880,
13,
4706,
396,
268,
525,
627,
943,
29918,
1949,
2396,
29871,
29896,
29892,
29871,
396,
13142,
22339,
19871,
2510,
2430,
19234,
10308,
13,
4706,
396,
268,
525,
1949,
29902,
2153,
2396,
29871,
29896,
29892,
29871,
396,
11471,
29919,
13142,
22339,
606,
6713,
15071,
13,
4706,
396,
268,
525,
1949,
29923,
567,
2396,
29871,
29896,
29892,
29871,
396,
3840,
644,
22339,
7372,
2430,
10689,
29927,
531,
8761,
6428,
28787,
10689,
6318,
3807,
2569,
23890,
4962,
1587,
1786,
8409,
6968,
10848,
606,
6713,
3540,
29889,
13,
4706,
396,
268,
525,
279,
2386,
6843,
598,
2396,
29871,
29945,
29900,
29892,
29871,
396,
3840,
644,
22339,
10689,
29927,
29892,
15261,
26367,
9907,
14295,
2194,
1413,
1786,
8409,
10689,
3541,
665,
1097,
587,
821,
313,
1668,
29932,
7894,
29969,
29897,
13,
4706,
396,
268,
525,
1949,
29924,
1783,
1799,
9893,
2396,
29871,
29947,
29900,
29900,
29892,
29871,
396,
3840,
644,
22339,
10689,
2899,
9240,
6785,
5752,
3807,
2569,
23890,
4962,
1587,
341,
1783,
29903,
29889,
13,
4706,
396,
268,
525,
5504,
1349,
12268,
2396,
29871,
29900,
29889,
29947,
29892,
29871,
396,
733,
576,
18763,
29919,
7082,
9935,
29656,
13142,
22339,
10689,
29927,
13,
4706,
396,
268,
525,
21970,
312,
2396,
29871,
29946,
29892,
29871,
396,
10808,
1783,
3443,
13,
4706,
396,
268,
525,
3972,
436,
1026,
28630,
2396,
29871,
29896,
29889,
29900,
29892,
29871,
396,
12668,
8685,
29899,
20691,
12274,
29927,
3354,
29960,
1155,
4355,
641,
29988,
753,
13,
4706,
396,
268,
525,
1949,
29902,
2153,
2831,
5323,
262,
1252,
9422,
20570,
2396,
29871,
29906,
29900,
29892,
29871,
396,
7874,
4941,
1695,
5508,
516,
1866,
17235,
3065,
606,
6713,
15071,
13,
4706,
396,
268,
525,
3198,
3149,
2396,
19283,
17314,
29918,
4299,
29914,
742,
29871,
396,
4554,
29964,
642,
3807,
27618,
15530,
2569,
1216,
6188,
606,
27572,
1282,
17200,
1695,
5508,
516,
13,
13,
13,
4706,
396,
19677,
3564,
310,
3517,
12623,
13,
4706,
396,
25755,
6887,
3162,
531,
1257,
29978,
2102,
4184,
1520,
2402,
588,
733,
551,
6052,
13,
4706,
1583,
29889,
24957,
29918,
14748,
353,
1653,
29918,
14748,
29898,
1311,
29889,
11802,
29892,
274,
6191,
29922,
8824,
29897,
13,
4706,
396,
19677,
3564,
310,
1857,
12623,
13,
4706,
396,
25755,
6887,
3162,
531,
1257,
29978,
2399,
1382,
2402,
588,
733,
551,
6052,
13,
4706,
1583,
29889,
3784,
29918,
14748,
353,
1653,
29918,
14748,
29898,
1311,
29889,
11802,
29892,
274,
6191,
29922,
8824,
29897,
13,
13,
4706,
396,
341,
1783,
29903,
310,
3517,
12623,
13,
4706,
396,
341,
1783,
29903,
2102,
4184,
1520,
2402,
588,
733,
551,
6052,
13,
4706,
1583,
29889,
24957,
29918,
29885,
312,
29879,
353,
341,
1783,
29903,
29898,
13,
9651,
1583,
29889,
11802,
29892,
1583,
29889,
24957,
29918,
14748,
29892,
1583,
29889,
5085,
29892,
4516,
436,
1026,
29918,
1217,
895,
29922,
5574,
29897,
13,
4706,
396,
341,
1783,
29903,
310,
1857,
12623,
13,
4706,
396,
341,
1783,
29903,
2399,
1382,
2402,
588,
733,
551,
6052,
13,
4706,
1583,
29889,
3784,
29918,
29885,
312,
29879,
353,
341,
1783,
29903,
29898,
13,
9651,
1583,
29889,
11802,
29892,
1583,
29889,
3784,
29918,
14748,
29892,
1583,
29889,
5085,
29892,
4516,
436,
1026,
29918,
1217,
895,
29922,
5574,
29897,
13,
13,
1678,
822,
1583,
29918,
1456,
29898,
1311,
29892,
1857,
29918,
705,
5861,
29892,
3748,
29918,
1949,
1125,
13,
4706,
9995,
13,
9651,
857,
7677,
11650,
2430,
614,
8847,
507,
2899,
9666,
8430,
12933,
8761,
6428,
28787,
10689,
3541,
29889,
13,
308,
6164,
3325,
2387,
3327,
29901,
13,
632,
1857,
29918,
705,
5861,
313,
23749,
29889,
2378,
1125,
17235,
1755,
3340,
2019,
25755,
6887,
2082,
1586,
811,
13,
632,
3748,
29918,
1949,
313,
524,
1125,
29871,
2815,
780,
10689,
3541,
3807,
8761,
6428,
28787,
10689,
3541,
13,
308,
5123,
29972,
18524,
29932,
29901,
13,
632,
7945,
29918,
19057,
313,
29935,
18021,
1125,
1695,
5508,
29982,
9116,
5588,
313,
3068,
265,
936,
28397,
29892,
16256,
9075,
29892,
2930,
29892,
325,
29897,
13,
4706,
9995,
13,
13,
4706,
1596,
877,
28897,
1630,
6428,
2584,
3162,
13781,
24356,
1866,
1778,
29972,
6798,
2430,
1097,
29969,
3648,
516,
313,
29917,
3565,
693,
3923,
1257,
17636,
2282,
26166,
29897,
1495,
13,
4706,
396,
2767,
18177,
310,
1857,
19677,
3564,
411,
9281,
18177,
13,
4706,
396,
1604,
29921,
1928,
1413,
3340,
2019,
2399,
1382,
2402,
29977,
25755,
6887,
2082,
1586,
811,
531,
17235,
9822,
3340,
2019,
989,
13,
4706,
1583,
29889,
3784,
29918,
14748,
29889,
842,
29918,
705,
5861,
29898,
3784,
29918,
705,
5861,
29897,
13,
13,
4706,
7945,
29918,
19057,
353,
5159,
259,
396,
14507,
3098,
8430,
3936,
30005,
1710,
5116,
9062,
313,
29935,
18021,
29897,
8847,
507,
2899,
717,
13,
4706,
363,
903,
297,
3464,
29898,
11802,
29918,
1949,
1125,
13,
9651,
1596,
877,
19193,
14005,
4364,
13781,
8981,
742,
24459,
13,
9651,
396,
10092,
2943,
2106,
310,
341,
1783,
29903,
13,
9651,
1596,
877,
29935,
20176,
1325,
1413,
13882,
1755,
26008,
684,
341,
1783,
29903,
1495,
13,
9651,
1583,
29889,
3784,
29918,
29885,
312,
29879,
353,
341,
1783,
29903,
29898,
1311,
29889,
11802,
29892,
1583,
29889,
3784,
29918,
14748,
29892,
1583,
29889,
5085,
29892,
4516,
436,
1026,
29918,
1217,
895,
29922,
5574,
29897,
13,
9651,
1596,
877,
11414,
507,
2899,
642,
26008,
684,
341,
1783,
29903,
1495,
13,
9651,
7945,
29918,
19057,
29889,
21843,
29898,
1311,
3032,
7978,
29923,
12907,
3101,
13,
9651,
396,
903,
7978,
29923,
12907,
580,
448,
20153,
5274,
25816,
10689,
3541,
13,
4706,
736,
7945,
29918,
19057,
13,
13,
1678,
822,
282,
5367,
29898,
1311,
29892,
3517,
29918,
705,
5861,
29892,
1857,
29918,
705,
5861,
29892,
8090,
29918,
1949,
1125,
13,
4706,
9995,
30031,
1419,
29978,
3102,
11012,
1097,
11933,
4816,
2102,
4184,
1520,
2402,
588,
733,
551,
6052,
606,
1097,
11933,
4816,
2399,
1382,
2402,
588,
733,
551,
6052,
13,
308,
6164,
3325,
2387,
3327,
29901,
13,
632,
3517,
29918,
705,
5861,
313,
23749,
29889,
2378,
1125,
3340,
2019,
25755,
6887,
2082,
1586,
811,
2102,
4184,
1520,
2402,
588,
733,
551,
6052,
13,
632,
1857,
29918,
705,
5861,
313,
23749,
29889,
2378,
1125,
3340,
2019,
25755,
6887,
2082,
1586,
811,
2399,
1382,
2402,
588,
733,
551,
6052,
13,
632,
3748,
29918,
1949,
313,
524,
1125,
13142,
22339,
3419,
4020,
490,
10689,
587,
13,
308,
5123,
29972,
18524,
29932,
29901,
13,
632,
13511,
730,
29998,
1866,
313,
2815,
780,
10689,
3541,
29892,
490,
20935,
2771,
25087,
29944,
2102,
4184,
1520,
23113,
1097,
29969,
3648,
29892,
29871,
2815,
780,
10689,
3541,
29892,
490,
20935,
2771,
25087,
29944,
2399,
1382,
23113,
1097,
29969,
3648,
29892,
13,
795,
2815,
780,
10689,
3541,
29892,
490,
20935,
4601,
23590,
4466,
1561,
4536,
29969,
3541,
30002,
29897,
13,
4706,
9995,
13,
4706,
1596,
877,
30031,
1419,
29978,
3102,
1495,
13,
4706,
396,
2767,
18177,
310,
3517,
322,
1857,
19677,
3564,
13,
4706,
396,
1604,
29921,
1928,
1413,
3340,
2019,
2102,
4184,
1520,
2402,
29977,
606,
2399,
1382,
2402,
29977,
25755,
6887,
2082,
1586,
811,
13,
4706,
1583,
29889,
24957,
29918,
14748,
29889,
842,
29918,
705,
5861,
29898,
24957,
29918,
705,
5861,
29897,
13,
4706,
1583,
29889,
3784,
29918,
14748,
29889,
842,
29918,
705,
5861,
29898,
3784,
29918,
705,
5861,
29897,
13,
13,
4706,
396,
10092,
2943,
2106,
310,
341,
1783,
29903,
13,
4706,
396,
531,
20176,
1325,
1413,
13882,
1755,
26008,
684,
341,
1783,
29903,
13,
4706,
1596,
877,
29935,
20176,
1325,
1413,
13882,
1755,
26008,
684,
341,
1783,
29903,
17702,
1097,
587,
2082,
1495,
13,
4706,
1583,
29889,
24957,
29918,
29885,
312,
29879,
353,
341,
1783,
29903,
29898,
1311,
29889,
11802,
29892,
1583,
29889,
24957,
29918,
14748,
29892,
1583,
29889,
5085,
29897,
13,
4706,
1583,
29889,
3784,
29918,
29885,
312,
29879,
353,
341,
1783,
29903,
29898,
1311,
29889,
11802,
29892,
1583,
29889,
3784,
29918,
14748,
29892,
1583,
29889,
5085,
29897,
13,
13,
4706,
564,
2386,
353,
26053,
29898,
13,
9651,
14013,
921,
29901,
7442,
29889,
1191,
3317,
29898,
1311,
29889,
24957,
29918,
29885,
312,
29879,
29889,
657,
4276,
1184,
29890,
29898,
29916,
29892,
5694,
29922,
29900,
8243,
13,
9651,
14013,
921,
29901,
7442,
29889,
1191,
3317,
29898,
1311,
29889,
3784,
29918,
29885,
312,
29879,
29889,
657,
4276,
1184,
29890,
29898,
29916,
29892,
5694,
29922,
29900,
8243,
13,
9651,
1583,
29889,
11802,
29897,
13,
4706,
3517,
29918,
29893,
1144,
29892,
1857,
29918,
29893,
1144,
29892,
4216,
29879,
353,
564,
2386,
29889,
1456,
29954,
1280,
29898,
29887,
1280,
29918,
1949,
29897,
13,
13,
4706,
736,
313,
24957,
29918,
29893,
1144,
29892,
1857,
29918,
29893,
1144,
29892,
4216,
29879,
29897,
29871,
396,
6849,
18524,
4826,
1257,
13142,
22339,
2102,
1520,
1520,
22319,
15393,
29957,
29892,
2399,
1382,
22319,
15393,
29957,
606,
7380,
19943,
15139,
13,
13,
1678,
822,
14707,
29918,
1688,
29918,
24713,
29898,
1311,
29892,
1857,
29918,
705,
5861,
29892,
1243,
29918,
24713,
1125,
13,
4706,
9995,
13,
4706,
1651,
2421,
507,
1413,
2352,
30011,
18201,
3499,
6122,
13074,
3215,
9994,
25755,
6887,
2430,
1586,
14469,
13,
308,
6164,
3325,
2387,
3327,
29901,
13,
632,
1857,
29918,
705,
5861,
313,
23749,
29889,
2378,
1125,
17235,
1755,
3340,
2019,
25755,
6887,
2082,
1586,
811,
13,
632,
1243,
29918,
24713,
313,
29935,
18021,
1125,
29871,
2815,
780,
10689,
3541,
3807,
8761,
6428,
28787,
10689,
3541,
13,
308,
5123,
29972,
18524,
29932,
29901,
13,
632,
13511,
730,
29998,
1866,
313,
29798,
22339,
28485,
10084,
2430,
6785,
5752,
29892,
13142,
22339,
6785,
576,
9994,
6785,
5752,
29897,
13,
4706,
9995,
13,
4706,
1596,
877,
30082,
19654,
5274,
1495,
13,
4706,
396,
2767,
18177,
310,
1857,
19677,
3564,
411,
9281,
18177,
13,
4706,
396,
1604,
29921,
1928,
1413,
3340,
2019,
2399,
1382,
2402,
29977,
25755,
6887,
2082,
1586,
811,
531,
17235,
9822,
3340,
2019,
989,
13,
4706,
1583,
29889,
3784,
29918,
14748,
29889,
842,
29918,
705,
5861,
29898,
3784,
29918,
705,
5861,
29897,
13,
13,
4706,
396,
20658,
1225,
3098,
18432,
3501,
23590,
4466,
2082,
10689,
3541,
13,
4706,
4922,
29918,
11631,
29918,
2798,
29892,
1781,
29918,
11631,
29918,
2798,
353,
29871,
29900,
29892,
29871,
29900,
13,
4706,
363,
848,
297,
1243,
29918,
24713,
29901,
13,
9651,
1583,
29889,
3784,
29918,
29885,
312,
29879,
353,
341,
1783,
29903,
29898,
1311,
29889,
11802,
29892,
1583,
29889,
3784,
29918,
14748,
29892,
1583,
29889,
5085,
29897,
29871,
396,
9111,
4826,
3098,
1198,
1186,
10247,
5944,
341,
1783,
29903,
13,
13,
9651,
921,
353,
1583,
29889,
11802,
29889,
657,
6028,
265,
936,
2500,
29898,
1272,
1839,
3377,
7464,
848,
1839,
9106,
11287,
13,
9651,
10823,
29918,
11631,
353,
938,
29898,
9302,
29889,
1191,
3317,
29898,
1311,
29889,
3784,
29918,
29885,
312,
29879,
29889,
657,
4276,
1184,
29890,
29898,
29916,
29892,
5694,
29922,
29900,
4961,
29871,
396,
13142,
22339,
6785,
5752,
13,
13,
9651,
16229,
353,
848,
3366,
11631,
29918,
13628,
3108,
29871,
396,
531,
18021,
614,
29981,
2530,
13,
9651,
4922,
29918,
13628,
353,
4236,
29898,
13529,
267,
29897,
29871,
396,
20658,
1225,
3098,
2394,
11153,
28494,
5209,
6253,
12854,
490,
531,
8993,
2476,
614,
29981,
2530,
13,
9651,
4922,
29918,
13529,
267,
353,
518,
29875,
363,
474,
297,
3464,
29898,
29955,
29897,
565,
16229,
29961,
29875,
29962,
1275,
4922,
29918,
13628,
29962,
29871,
396,
2771,
20338,
3098,
29871,
29955,
23321,
9994,
13,
13,
9651,
565,
10823,
29918,
11631,
297,
4922,
29918,
13529,
267,
29901,
13,
18884,
4922,
29918,
11631,
29918,
2798,
4619,
29871,
29896,
29871,
396,
3693,
29935,
1093,
29932,
28866,
4393,
2430,
6785,
5752,
13,
18884,
1596,
877,
546,
3647,
29918,
11631,
29918,
2798,
742,
4922,
29918,
11631,
29918,
2798,
29897,
13,
13,
9651,
1596,
877,
30038,
16143,
1225,
3098,
15393,
840,
29905,
5945,
29977,
29969,
3541,
30002,
29905,
507,
29981,
14252,
448,
13420,
5401,
29918,
6758,
29918,
4012,
29898,
13529,
267,
29961,
14748,
29918,
11631,
12622,
13,
9651,
565,
5401,
29918,
6758,
29918,
4012,
29898,
13529,
267,
29961,
14748,
29918,
11631,
2314,
1275,
5401,
29918,
6758,
29918,
4012,
29898,
546,
3647,
29918,
13628,
1125,
13,
18884,
1781,
29918,
11631,
29918,
2798,
4619,
29871,
29896,
29871,
396,
3693,
29935,
1093,
29932,
6785,
576,
9994,
6785,
5752,
13,
18884,
1596,
877,
16773,
29918,
11631,
29918,
2798,
742,
1781,
29918,
11631,
29918,
2798,
29897,
13,
13,
4706,
736,
313,
546,
3647,
29918,
11631,
29918,
2798,
29892,
1781,
29918,
11631,
29918,
2798,
29897,
13,
13,
1678,
822,
903,
7978,
29923,
12907,
29898,
1311,
1125,
29871,
396,
20153,
5274,
25816,
10689,
3541,
13,
4706,
9995,
13,
4706,
4767,
676,
20153,
5274,
27056,
1200,
1257,
15515,
2352,
1668,
4734,
29957,
8761,
6428,
28787,
10689,
3541,
29892,
665,
1499,
3162,
531,
10689,
576,
642,
29871,
29896,
29889,
13,
308,
2195,
6785,
1520,
10689,
3541,
1787,
24057,
29977,
6785,
29957,
1447,
3102,
7593,
4364,
490,
22285,
27572,
1282,
26920,
1695,
1488,
494,
1186,
13,
308,
7945,
1252,
9422,
29889,
2081,
2194,
662,
644,
7489,
1447,
3920,
3432,
29889,
12485,
10689,
3541,
13,
308,
1077,
6244,
1499,
25107,
29892,
13439,
29932,
10689,
3541,
24160,
4364,
3807,
27167,
18072,
1587,
6253,
1093,
2332,
1787,
29998,
1802,
1805,
1695,
5508,
29960,
13,
308,
490,
733,
5836,
1216,
7203,
5508,
29982,
29889,
13,
13,
308,
16456,
24160,
1257,
5694,
353,
29871,
29896,
29892,
1694,
12068,
12720,
14448,
529,
7382,
1349,
12268,
14448,
29892,
606,
9017,
16827,
13,
308,
24160,
1257,
5694,
353,
29871,
29900,
29889,
13,
13,
308,
5123,
29972,
18524,
29932,
29901,
13,
632,
7945,
1252,
9422,
29901,
531,
18021,
1695,
5508,
516,
9116,
5588,
313,
3068,
265,
936,
28397,
29892,
16256,
9075,
29892,
2930,
29892,
325,
29897,
13,
462,
9651,
2930,
448,
3340,
8331,
10595,
24807,
29892,
1471,
8197,
6696,
989,
11866,
2370,
341,
1783,
29903,
29892,
325,
448,
718,
29896,
29892,
1694,
12068,
13,
462,
9651,
10689,
16635,
490,
20776,
3920,
23728,
2771,
25087,
29944,
10689,
1086,
29892,
606,
477,
1093,
448,
29896,
29889,
13,
4706,
9995,
13,
4706,
1596,
877,
30082,
1668,
4734,
29957,
25816,
10689,
3541,
1495,
13,
4706,
7945,
1252,
9422,
353,
5159,
13,
4706,
7613,
353,
1583,
29889,
11802,
29889,
657,
6644,
28397,
580,
13,
4706,
1583,
29889,
2764,
9075,
353,
29871,
29896,
13,
4706,
12720,
14448,
353,
29871,
29900,
13,
13,
4706,
1550,
5852,
29901,
13,
9651,
12720,
14448,
4619,
29871,
29896,
13,
9651,
1596,
877,
28897,
1630,
6428,
2584,
3162,
13781,
1097,
29969,
3648,
516,
2399,
1382,
2402,
588,
733,
551,
6052,
606,
2102,
4184,
1520,
2402,
588,
29892,
6785,
29957,
353,
13420,
12720,
14448,
29897,
13,
9651,
24420,
28397,
353,
1583,
29889,
11802,
29889,
657,
6028,
265,
936,
2500,
29898,
3377,
29892,
1583,
29889,
2764,
9075,
29897,
13,
9651,
5694,
353,
938,
29898,
1022,
275,
356,
14448,
529,
1583,
29889,
5085,
29889,
7382,
1349,
12268,
14448,
29897,
13,
13,
9651,
2930,
353,
1583,
29889,
3784,
29918,
29885,
312,
29879,
29889,
657,
4276,
1184,
29890,
29898,
3068,
265,
936,
28397,
29892,
5694,
29922,
7382,
29897,
13,
9651,
5016,
353,
1583,
29889,
11802,
29889,
657,
25548,
2527,
2722,
29898,
3068,
265,
936,
28397,
29892,
2930,
29897,
13,
9651,
363,
289,
29892,
282,
297,
5016,
29901,
29871,
396,
7613,
29892,
2930,
13,
18884,
7945,
1252,
9422,
29889,
4397,
4197,
29890,
29892,
1583,
29889,
2764,
9075,
29892,
282,
29892,
6213,
2314,
13,
13,
9651,
3158,
353,
7442,
29889,
8172,
29889,
16957,
29898,
2435,
29898,
1631,
511,
282,
29922,
1631,
29897,
13,
9651,
7613,
29892,
1583,
29889,
2764,
9075,
353,
1583,
29889,
11802,
29889,
657,
9190,
2792,
29898,
13,
18884,
7613,
29892,
1583,
29889,
2764,
9075,
29892,
3158,
29897,
13,
13,
9651,
364,
353,
1583,
29889,
11802,
29889,
657,
14199,
5044,
287,
29898,
3377,
29892,
1583,
29889,
2764,
9075,
29897,
13,
13,
9651,
565,
364,
2804,
29871,
29900,
29901,
13,
18884,
736,
17288,
29916,
29961,
29900,
1402,
921,
29961,
29906,
1402,
364,
334,
5135,
29899,
29896,
29897,
1068,
29898,
29916,
29961,
29896,
29962,
2804,
1583,
29889,
2764,
9075,
4961,
13,
462,
4706,
363,
921,
297,
7945,
1252,
9422,
29962,
13,
2
] |
src/common/timestamp.py | vkhaydarov/PlantEye | 1 | 48421 | <reponame>vkhaydarov/PlantEye
from time import time
def get_timestamp():
return int(round(time() * 1000)) | [
1,
529,
276,
1112,
420,
29958,
29894,
15339,
388,
16702,
586,
29914,
3247,
424,
29923,
4099,
13,
3166,
931,
1053,
931,
13,
13,
13,
1753,
679,
29918,
16394,
7295,
13,
1678,
736,
938,
29898,
14486,
29898,
2230,
580,
334,
29871,
29896,
29900,
29900,
29900,
876,
2
] |
Models/LeNet-5/train.py | sujatasaini/Japanese-character-recognition-using-DropBlock | 2 | 82995 | <reponame>sujatasaini/Japanese-character-recognition-using-DropBlock<gh_stars>1-10
# Import the libraries
from keras import backend as K
from keras.datasets import mnist
from keras.layers.convolutional import Conv2D, MaxPooling2D
from keras.layers.core import Activation, Flatten, Dense
from keras.models import Sequential
from keras.utils import np_utils
from keras.initializers import Constant
from keras.optimizers import Adam
import matplotlib.pyplot as plt
# Load the dataset
(X_train, y_train), (X_test, y_test) = mnist.load_data()
X_train = X_train.astype('float32') / 255
X_test = X_test.astype('float32') / 255
X_test = X_test.reshape(X_test.shape[0], 1, 28, 28)
X_train = X_train.reshape(X_train.shape[0], 1, 28, 28)
y_test = np_utils.to_categorical(y_test, 10)
y_train = np_utils.to_categorical(y_train, 10)
# Build the model
K.set_image_dim_ordering("th")
#LeNet
model = Sequential()
model.add(Conv2D(20, kernel_size=5, padding="same", input_shape=(1,28,28)))
model.add(Activation("relu"))
model.add(MaxPooling2D())
model.add(Conv2D(50, kernel_size=5, border_mode="same"))
model.add(Activation("relu"))
model.add(MaxPooling2D())
model.add(Flatten())
model.add(Dense(500))
model.add(Activation("relu"))
model.add(Dense(10))
model.add(Activation("softmax"))
# Compile the model
model.compile(loss="categorical_crossentropy", optimizer=Adam(), metrics=["accuracy"])
# Train the model
history = model.fit(X_train, y_train, batch_size=128, epochs=20, verbose=1, validation_split=0.2)
score = model.evaluate(X_test, y_test, verbose=1)
print("Test score:", score[0])
print("Test accuracy:", score[1])
print(history.history.keys())
# Plot the graph of the model
plt.plot(history.history['acc'])
plt.plot(history.history['val_acc'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()
| [
1,
529,
276,
1112,
420,
29958,
2146,
29926,
271,
294,
475,
29875,
29914,
29967,
21419,
968,
29899,
18609,
29899,
29423,
654,
29899,
4746,
29899,
15063,
7445,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
29937,
16032,
278,
9562,
13,
3166,
13023,
294,
1053,
14998,
408,
476,
13,
3166,
13023,
294,
29889,
14538,
1691,
1053,
28597,
391,
13,
3166,
13023,
294,
29889,
29277,
29889,
535,
4068,
284,
1053,
1281,
29894,
29906,
29928,
29892,
5918,
11426,
292,
29906,
29928,
13,
3166,
13023,
294,
29889,
29277,
29889,
3221,
1053,
21775,
362,
29892,
2379,
8606,
29892,
360,
1947,
13,
3166,
13023,
294,
29889,
9794,
1053,
922,
339,
2556,
13,
3166,
13023,
294,
29889,
13239,
1053,
7442,
29918,
13239,
13,
3166,
13023,
294,
29889,
11228,
19427,
1053,
28601,
13,
3166,
13023,
294,
29889,
20640,
19427,
1053,
11783,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
29871,
13,
29937,
16012,
278,
8783,
13,
13,
29898,
29990,
29918,
14968,
29892,
343,
29918,
14968,
511,
313,
29990,
29918,
1688,
29892,
343,
29918,
1688,
29897,
353,
28597,
391,
29889,
1359,
29918,
1272,
580,
13,
29871,
13,
29990,
29918,
14968,
353,
1060,
29918,
14968,
29889,
579,
668,
877,
7411,
29941,
29906,
1495,
847,
29871,
29906,
29945,
29945,
13,
29990,
29918,
1688,
353,
1060,
29918,
1688,
29889,
579,
668,
877,
7411,
29941,
29906,
1495,
847,
29871,
29906,
29945,
29945,
13,
29990,
29918,
1688,
353,
1060,
29918,
1688,
29889,
690,
14443,
29898,
29990,
29918,
1688,
29889,
12181,
29961,
29900,
1402,
29871,
29896,
29892,
29871,
29906,
29947,
29892,
29871,
29906,
29947,
29897,
13,
29990,
29918,
14968,
353,
1060,
29918,
14968,
29889,
690,
14443,
29898,
29990,
29918,
14968,
29889,
12181,
29961,
29900,
1402,
29871,
29896,
29892,
29871,
29906,
29947,
29892,
29871,
29906,
29947,
29897,
13,
29871,
13,
29891,
29918,
1688,
353,
7442,
29918,
13239,
29889,
517,
29918,
29883,
20440,
936,
29898,
29891,
29918,
1688,
29892,
29871,
29896,
29900,
29897,
13,
29891,
29918,
14968,
353,
7442,
29918,
13239,
29889,
517,
29918,
29883,
20440,
936,
29898,
29891,
29918,
14968,
29892,
29871,
29896,
29900,
29897,
13,
13,
29937,
8878,
278,
1904,
13,
29968,
29889,
842,
29918,
3027,
29918,
6229,
29918,
2098,
292,
703,
386,
1159,
13,
29937,
3226,
6779,
13,
4299,
353,
922,
339,
2556,
580,
13,
4299,
29889,
1202,
29898,
1168,
29894,
29906,
29928,
29898,
29906,
29900,
29892,
8466,
29918,
2311,
29922,
29945,
29892,
7164,
543,
17642,
613,
1881,
29918,
12181,
7607,
29896,
29892,
29906,
29947,
29892,
29906,
29947,
4961,
13,
4299,
29889,
1202,
29898,
21786,
362,
703,
2674,
29884,
5783,
13,
4299,
29889,
1202,
29898,
7976,
11426,
292,
29906,
29928,
3101,
13,
29871,
13,
4299,
29889,
1202,
29898,
1168,
29894,
29906,
29928,
29898,
29945,
29900,
29892,
8466,
29918,
2311,
29922,
29945,
29892,
5139,
29918,
8513,
543,
17642,
5783,
13,
4299,
29889,
1202,
29898,
21786,
362,
703,
2674,
29884,
5783,
13,
4299,
29889,
1202,
29898,
7976,
11426,
292,
29906,
29928,
3101,
13,
29871,
13,
4299,
29889,
1202,
29898,
29943,
5066,
841,
3101,
13,
4299,
29889,
1202,
29898,
29928,
1947,
29898,
29945,
29900,
29900,
876,
13,
4299,
29889,
1202,
29898,
21786,
362,
703,
2674,
29884,
5783,
13,
29871,
13,
4299,
29889,
1202,
29898,
29928,
1947,
29898,
29896,
29900,
876,
13,
4299,
29889,
1202,
29898,
21786,
362,
703,
2695,
3317,
5783,
13,
13,
29937,
3831,
488,
278,
1904,
13,
4299,
29889,
12198,
29898,
6758,
543,
29883,
20440,
936,
29918,
19128,
296,
14441,
613,
5994,
3950,
29922,
3253,
314,
3285,
21556,
29922,
3366,
562,
2764,
4135,
20068,
13,
13,
29937,
28186,
278,
1904,
13,
18434,
353,
1904,
29889,
9202,
29898,
29990,
29918,
14968,
29892,
343,
29918,
14968,
29892,
9853,
29918,
2311,
29922,
29896,
29906,
29947,
29892,
21502,
12168,
29922,
29906,
29900,
29892,
26952,
29922,
29896,
29892,
8845,
29918,
5451,
29922,
29900,
29889,
29906,
29897,
13,
13628,
353,
1904,
29889,
24219,
403,
29898,
29990,
29918,
1688,
29892,
343,
29918,
1688,
29892,
26952,
29922,
29896,
29897,
13,
2158,
703,
3057,
8158,
29901,
613,
8158,
29961,
29900,
2314,
13,
2158,
703,
3057,
13600,
29901,
613,
8158,
29961,
29896,
2314,
13,
2158,
29898,
18434,
29889,
18434,
29889,
8149,
3101,
13,
13,
29937,
18399,
278,
3983,
310,
278,
1904,
13,
572,
29873,
29889,
5317,
29898,
18434,
29889,
18434,
1839,
5753,
11287,
13,
572,
29873,
29889,
5317,
29898,
18434,
29889,
18434,
1839,
791,
29918,
5753,
11287,
13,
572,
29873,
29889,
3257,
877,
4299,
13600,
1495,
13,
572,
29873,
29889,
29891,
1643,
877,
562,
2764,
4135,
1495,
13,
572,
29873,
29889,
29916,
1643,
877,
1022,
2878,
1495,
13,
572,
29873,
29889,
26172,
18959,
14968,
742,
525,
1688,
7464,
1180,
2433,
21064,
2175,
1495,
13,
572,
29873,
29889,
4294,
580,
13,
29871,
13,
572,
29873,
29889,
5317,
29898,
18434,
29889,
18434,
1839,
6758,
11287,
13,
572,
29873,
29889,
5317,
29898,
18434,
29889,
18434,
1839,
791,
29918,
6758,
11287,
13,
572,
29873,
29889,
3257,
877,
4299,
6410,
1495,
13,
572,
29873,
29889,
29891,
1643,
877,
6758,
1495,
13,
572,
29873,
29889,
29916,
1643,
877,
1022,
2878,
1495,
13,
572,
29873,
29889,
26172,
18959,
14968,
742,
525,
1688,
7464,
1180,
2433,
21064,
2175,
1495,
13,
572,
29873,
29889,
4294,
580,
13,
2
] |
scripts/main.py | xdze2/trilobot | 0 | 68144 | <gh_stars>0
import time
import asyncio
import rx
from rx.scheduler.eventloop import AsyncIOScheduler
import rx.operators as op
import time
import matplotlib.pyplot as plt
import numpy as np
import pigpio
from pyrobot.drive import Mobility
from pyrobot.hardware.sonar import UltraSoundSensor
from pyrobot.gpio_mapping import SonarGpio
from pyrobot.rgb_leds import RgbUnderlighting, HsvColor, ColorMap
gpio = pigpio.pi()
distance_sensor = UltraSoundSensor(gpio_echo=SonarGpio.ECHO, gpio_trig=SonarGpio.TRIG, gpio=gpio)
mob = Mobility()
cm = ColorMap(0, 1500, 'gist_heat')
leds = RgbUnderlighting()
async_loop = asyncio.get_event_loop()
scheduler = AsyncIOScheduler(async_loop)
print('init done')
distance_measure = (
rx.interval(0.100, scheduler=scheduler)
.pipe(
op.map( lambda t: (t, distance_sensor.measure_cm()) ),
op.scan( lambda acc, x: (x[0], 0.5*acc[1] + 0.5*x[1]) )
)
)
(
distance_measure.pipe(
op.buffer_with_time(.5),
op.map(lambda grp: np.mean([u[1] for u in grp]))
).subscribe(
lambda dist_avg: leds.change_color(cm.get_rgb(dist_avg), 'front'),
on_error = lambda e: print("Error : {0}".format(e)),
on_completed = lambda: print("Job Done!"),
scheduler=scheduler
)
)
distance_measure.subscribe(
lambda x: print(x),
)
# test.pipe(op.delay(1.4), op.map(lambda x:x**2)).subscribe(
# lambda x: print("The square is {0}".format(x)),
# on_error = lambda e: print("Error : {0}".format(e)),
# on_completed = lambda: print("Job Done!"),
# scheduler=scheduler
# )
# test2 = rx.interval(3., scheduler=scheduler)
# print('done')
# test2.subscribe(
# lambda x: print("The 2 value is {0}".format(x)),
# on_error = lambda e: print("Error : {0}".format(e)),
# on_completed = lambda: print("Job Done!"),
# scheduler=scheduler
# )
async_loop.run_forever()
print("done")
async_loop.close()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
13,
5215,
931,
13,
5215,
408,
948,
3934,
13,
13,
5215,
364,
29916,
13,
3166,
364,
29916,
29889,
816,
14952,
29889,
3696,
7888,
1053,
20688,
25925,
305,
14952,
13,
5215,
364,
29916,
29889,
3372,
4097,
408,
1015,
13,
13,
5215,
931,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
12655,
408,
7442,
13,
5215,
282,
335,
16168,
13,
3166,
11451,
307,
7451,
29889,
21594,
1053,
341,
711,
1793,
13,
3166,
11451,
307,
7451,
29889,
6800,
2519,
29889,
1100,
279,
1053,
18514,
336,
29456,
29903,
6073,
13,
3166,
11451,
307,
7451,
29889,
29887,
16168,
29918,
20698,
1053,
5791,
279,
29954,
16168,
13,
3166,
11451,
307,
7451,
29889,
23973,
29918,
839,
29879,
1053,
390,
26300,
29177,
4366,
292,
29892,
379,
4501,
3306,
29892,
9159,
3388,
13,
13,
13,
29887,
16168,
353,
282,
335,
16168,
29889,
1631,
580,
13,
13,
19244,
29918,
29879,
6073,
353,
18514,
336,
29456,
29903,
6073,
29898,
29887,
16168,
29918,
8057,
29922,
29903,
265,
279,
29954,
16168,
29889,
29923,
3210,
29949,
29892,
330,
16168,
29918,
509,
335,
29922,
29903,
265,
279,
29954,
16168,
29889,
29911,
22789,
29892,
330,
16168,
29922,
29887,
16168,
29897,
13,
13,
13,
29885,
711,
353,
341,
711,
1793,
580,
13,
13,
13,
4912,
353,
9159,
3388,
29898,
29900,
29892,
29871,
29896,
29945,
29900,
29900,
29892,
525,
29887,
391,
29918,
354,
271,
1495,
13,
839,
29879,
353,
390,
26300,
29177,
4366,
292,
580,
13,
13,
13,
12674,
29918,
7888,
353,
408,
948,
3934,
29889,
657,
29918,
3696,
29918,
7888,
580,
13,
816,
14952,
353,
20688,
25925,
305,
14952,
29898,
12674,
29918,
7888,
29897,
13,
13,
13,
2158,
877,
2344,
2309,
1495,
13,
13,
19244,
29918,
26658,
353,
313,
13,
259,
364,
29916,
29889,
19207,
29898,
29900,
29889,
29896,
29900,
29900,
29892,
1364,
14952,
29922,
816,
14952,
29897,
13,
418,
869,
17760,
29898,
13,
308,
1015,
29889,
1958,
29898,
14013,
260,
29901,
313,
29873,
29892,
5418,
29918,
29879,
6073,
29889,
26658,
29918,
4912,
3101,
10353,
13,
308,
1015,
29889,
16192,
29898,
14013,
1035,
29892,
921,
29901,
313,
29916,
29961,
29900,
1402,
29871,
29900,
29889,
29945,
29930,
5753,
29961,
29896,
29962,
718,
29871,
29900,
29889,
29945,
29930,
29916,
29961,
29896,
2314,
1723,
29871,
13,
418,
1723,
13,
29897,
13,
29898,
13,
259,
5418,
29918,
26658,
29889,
17760,
29898,
13,
418,
1015,
29889,
9040,
29918,
2541,
29918,
2230,
11891,
29945,
511,
13,
418,
1015,
29889,
1958,
29898,
2892,
867,
29886,
29901,
7442,
29889,
12676,
4197,
29884,
29961,
29896,
29962,
363,
318,
297,
867,
29886,
12622,
13,
259,
13742,
19496,
29898,
13,
418,
14013,
1320,
29918,
485,
29887,
29901,
5331,
29879,
29889,
3167,
29918,
2780,
29898,
4912,
29889,
657,
29918,
23973,
29898,
5721,
29918,
485,
29887,
511,
525,
8862,
5477,
13,
418,
373,
29918,
2704,
353,
14013,
321,
29901,
1596,
703,
2392,
584,
426,
29900,
29913,
1642,
4830,
29898,
29872,
8243,
13,
418,
373,
29918,
5729,
9446,
353,
14013,
29901,
1596,
703,
11947,
25679,
3850,
511,
13,
418,
1364,
14952,
29922,
816,
14952,
13,
259,
1723,
13,
29897,
13,
19244,
29918,
26658,
29889,
19496,
29898,
13,
259,
14013,
921,
29901,
1596,
29898,
29916,
511,
13,
29897,
13,
29937,
1243,
29889,
17760,
29898,
459,
29889,
18829,
29898,
29896,
29889,
29946,
511,
1015,
29889,
1958,
29898,
2892,
921,
29901,
29916,
1068,
29906,
8106,
19496,
29898,
13,
29937,
1678,
14013,
921,
29901,
1596,
703,
1576,
6862,
338,
426,
29900,
29913,
1642,
4830,
29898,
29916,
8243,
13,
29937,
1678,
373,
29918,
2704,
353,
14013,
321,
29901,
1596,
703,
2392,
584,
426,
29900,
29913,
1642,
4830,
29898,
29872,
8243,
13,
29937,
1678,
373,
29918,
5729,
9446,
353,
14013,
29901,
1596,
703,
11947,
25679,
3850,
511,
13,
29937,
1678,
1364,
14952,
29922,
816,
14952,
13,
29937,
1723,
13,
13,
13,
29937,
1243,
29906,
353,
364,
29916,
29889,
19207,
29898,
29941,
1696,
1364,
14952,
29922,
816,
14952,
29897,
13,
13,
29937,
1596,
877,
15091,
1495,
13,
29937,
1243,
29906,
29889,
19496,
29898,
13,
29937,
1678,
14013,
921,
29901,
1596,
703,
1576,
29871,
29906,
995,
338,
426,
29900,
29913,
1642,
4830,
29898,
29916,
8243,
13,
29937,
1678,
373,
29918,
2704,
353,
14013,
321,
29901,
1596,
703,
2392,
584,
426,
29900,
29913,
1642,
4830,
29898,
29872,
8243,
13,
29937,
1678,
373,
29918,
5729,
9446,
353,
14013,
29901,
1596,
703,
11947,
25679,
3850,
511,
13,
29937,
1678,
1364,
14952,
29922,
816,
14952,
13,
29937,
1723,
13,
13,
13,
13,
13,
12674,
29918,
7888,
29889,
3389,
29918,
1079,
369,
580,
13,
2158,
703,
15091,
1159,
13,
12674,
29918,
7888,
29889,
5358,
580,
13,
2
] |
DeepLearning/Utils/prepare_corpus.py | neuralconcept/DrWhoAI | 3 | 110026 | # coding=utf-8
"""
Build vocab with a set max vocab size.
Build token ids given the vocab.
Do get_data.py first.
"""
# from __future__ import unicode_literals, print_function, division
import os
import subprocess
import re
from unidecode import unidecode
from nltk import word_tokenize
from DeepLearning.Utils import CACHE_DIR
from DeepLearning.Utils.data_utils import create_vocabulary, data_to_token_ids
from DeepLearning.Utils.genTrainingData import PERSON_FILENAME, DOCTOR_FILENAME, TRAIN_SUFFIX, DEV_SUFFIX
from DeepLearning.Utils.genTrainingData import PERSON_PATH, DOCTOR_PATH, PERSON_TRAIN_PATH, PERSON_DEV_PATH, DOCTOR_TRAIN_PATH, DOCTOR_DEV_PATH
# TODO: integrate all this in AIBot.py
PERSON_VOCAB_FILENAME = "person.vocab"
DOCTOR_VOCAB_FILENAME = "doctor.vocab"
PERSON_VOCAB_MAX = 20000
DOCTOR_VOCAB_MAX = 20000
IDS_SUFFIX = ".ids"
PERSON_VOCAB_PATH = os.path.join(CACHE_DIR, PERSON_VOCAB_FILENAME)
DOCTOR_VOCAB_PATH = os.path.join(CACHE_DIR, DOCTOR_VOCAB_FILENAME)
PERSON_TRAIN_IDS_PATH = os.path.join(CACHE_DIR, "person" + TRAIN_SUFFIX + IDS_SUFFIX)
PERSON_DEV_IDS_PATH = os.path.join(CACHE_DIR, "person" + DEV_SUFFIX + IDS_SUFFIX)
DOCTOR_TRAIN_IDS_PATH = os.path.join(CACHE_DIR, "doctor" + TRAIN_SUFFIX + IDS_SUFFIX)
DOCTOR_DEV_IDS_PATH = os.path.join(CACHE_DIR, "doctor" + DEV_SUFFIX + IDS_SUFFIX)
_WORD_SPLIT = re.compile("([.,!?\"':;)(])")
def _tokenizer(sentence):
"""Very basic tokenizer: split the sentence into a list of tokens + lower()."""
words = []
for space_separated_fragment in sentence.lower().strip().split():
words.extend(re.split(_WORD_SPLIT, space_separated_fragment))
return [w for w in words if w]
def tokenizer(sentence): # TODO: not working for apostrophes
sentence = sentence.strip().lower()
if type(sentence) != unicode:
sentence = unicode(sentence, encoding='utf-8', errors='replace')
sentence = unidecode(sentence)
sentence = sentence.replace("' ", "'")
return word_tokenize(sentence)
def build_vocab():
create_vocabulary(PERSON_VOCAB_PATH, PERSON_PATH, PERSON_VOCAB_MAX, tokenizer=tokenizer)
create_vocabulary(DOCTOR_VOCAB_PATH, DOCTOR_PATH, DOCTOR_VOCAB_MAX, tokenizer=tokenizer)
print( subprocess.check_output(['wc', '-l', PERSON_VOCAB_PATH]) )
print( subprocess.check_output(['wc', '-l', DOCTOR_VOCAB_PATH]) )
def build_ids():
data_to_token_ids(PERSON_TRAIN_PATH, PERSON_TRAIN_IDS_PATH, PERSON_VOCAB_PATH, tokenizer=tokenizer)
data_to_token_ids(PERSON_DEV_PATH, PERSON_DEV_IDS_PATH, PERSON_VOCAB_PATH, tokenizer=tokenizer)
data_to_token_ids(DOCTOR_TRAIN_PATH, DOCTOR_TRAIN_IDS_PATH, DOCTOR_VOCAB_PATH, tokenizer=tokenizer)
data_to_token_ids(DOCTOR_DEV_PATH, DOCTOR_DEV_IDS_PATH, DOCTOR_VOCAB_PATH, tokenizer=tokenizer)
print( subprocess.check_output(['wc', '-l', PERSON_TRAIN_IDS_PATH]) )
print( subprocess.check_output(['wc', '-l', PERSON_DEV_IDS_PATH]) )
print( subprocess.check_output(['wc', '-l', DOCTOR_TRAIN_IDS_PATH]) )
print( subprocess.check_output(['wc', '-l', DOCTOR_DEV_IDS_PATH]) )
def split_parallel_set(split_size=30000):
# split the dataset into train and dev sets (i'm using shell scripts)
subprocess.call(['split', '-l', str(split_size), PERSON_PATH])
subprocess.call(['mv', 'xaa', PERSON_TRAIN_PATH])
subprocess.call(['mv', 'xab', PERSON_DEV_PATH])
subprocess.call(['split', '-l', str(split_size), DOCTOR_PATH])
subprocess.call(['mv', 'xaa', DOCTOR_TRAIN_PATH])
subprocess.call(['mv', 'xab', DOCTOR_DEV_PATH])
print( subprocess.check_output(['wc', '-l', PERSON_TRAIN_PATH]) )
print( subprocess.check_output(['wc', '-l', PERSON_DEV_PATH]) )
print( subprocess.check_output(['wc', '-l', DOCTOR_TRAIN_PATH]) )
print( subprocess.check_output(['wc', '-l', DOCTOR_DEV_PATH]) )
if __name__ == '__main__':
split_parallel_set()
build_vocab()
build_ids() | [
1,
396,
14137,
29922,
9420,
29899,
29947,
13,
15945,
29908,
13,
8893,
7931,
370,
411,
263,
731,
4236,
7931,
370,
2159,
29889,
13,
8893,
5993,
18999,
2183,
278,
7931,
370,
29889,
13,
6132,
679,
29918,
1272,
29889,
2272,
937,
29889,
13,
15945,
29908,
13,
29937,
515,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
29892,
1596,
29918,
2220,
29892,
8542,
13,
13,
5215,
2897,
13,
5215,
1014,
5014,
13,
5215,
337,
13,
3166,
443,
680,
401,
1053,
443,
680,
401,
13,
3166,
302,
1896,
29895,
1053,
1734,
29918,
6979,
675,
13,
13,
3166,
21784,
29931,
799,
1076,
29889,
12177,
1053,
315,
2477,
9606,
29918,
9464,
13,
3166,
21784,
29931,
799,
1076,
29889,
12177,
29889,
1272,
29918,
13239,
1053,
1653,
29918,
29894,
542,
370,
352,
653,
29892,
848,
29918,
517,
29918,
6979,
29918,
4841,
13,
3166,
21784,
29931,
799,
1076,
29889,
12177,
29889,
1885,
5323,
2827,
1469,
1053,
349,
1001,
3094,
29918,
7724,
5813,
29892,
11662,
1783,
1955,
29918,
7724,
5813,
29892,
323,
4717,
1177,
29918,
14605,
29943,
25634,
29892,
5012,
29963,
29918,
14605,
29943,
25634,
13,
3166,
21784,
29931,
799,
1076,
29889,
12177,
29889,
1885,
5323,
2827,
1469,
1053,
349,
1001,
3094,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
10145,
29892,
349,
1001,
3094,
29918,
29911,
4717,
1177,
29918,
10145,
29892,
349,
1001,
3094,
29918,
2287,
29963,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
29911,
4717,
1177,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
2287,
29963,
29918,
10145,
13,
13,
29937,
14402,
29901,
22782,
599,
445,
297,
319,
8979,
327,
29889,
2272,
13,
13171,
3094,
29918,
29963,
20166,
2882,
29918,
7724,
5813,
353,
376,
10532,
29889,
29894,
542,
370,
29908,
13,
3970,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
7724,
5813,
353,
376,
1867,
2801,
29889,
29894,
542,
370,
29908,
13,
13,
13171,
3094,
29918,
29963,
20166,
2882,
29918,
12648,
353,
29871,
29906,
29900,
29900,
29900,
29900,
13,
3970,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
12648,
353,
29871,
29906,
29900,
29900,
29900,
29900,
13,
13,
1367,
29903,
29918,
14605,
29943,
25634,
353,
11393,
4841,
29908,
13,
13,
13171,
3094,
29918,
29963,
20166,
2882,
29918,
10145,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29907,
2477,
9606,
29918,
9464,
29892,
349,
1001,
3094,
29918,
29963,
20166,
2882,
29918,
7724,
5813,
29897,
13,
3970,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
10145,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29907,
2477,
9606,
29918,
9464,
29892,
11662,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
7724,
5813,
29897,
13,
13,
13171,
3094,
29918,
29911,
4717,
1177,
29918,
1367,
29903,
29918,
10145,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29907,
2477,
9606,
29918,
9464,
29892,
376,
10532,
29908,
718,
323,
4717,
1177,
29918,
14605,
29943,
25634,
718,
3553,
29903,
29918,
14605,
29943,
25634,
29897,
13,
13171,
3094,
29918,
2287,
29963,
29918,
1367,
29903,
29918,
10145,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29907,
2477,
9606,
29918,
9464,
29892,
376,
10532,
29908,
718,
5012,
29963,
29918,
14605,
29943,
25634,
718,
3553,
29903,
29918,
14605,
29943,
25634,
29897,
13,
3970,
1783,
1955,
29918,
29911,
4717,
1177,
29918,
1367,
29903,
29918,
10145,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29907,
2477,
9606,
29918,
9464,
29892,
376,
1867,
2801,
29908,
718,
323,
4717,
1177,
29918,
14605,
29943,
25634,
718,
3553,
29903,
29918,
14605,
29943,
25634,
29897,
13,
3970,
1783,
1955,
29918,
2287,
29963,
29918,
1367,
29903,
29918,
10145,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29907,
2477,
9606,
29918,
9464,
29892,
376,
1867,
2801,
29908,
718,
5012,
29963,
29918,
14605,
29943,
25634,
718,
3553,
29903,
29918,
14605,
29943,
25634,
29897,
13,
13,
29918,
17013,
29918,
5550,
29931,
1806,
353,
337,
29889,
12198,
703,
4197,
1696,
29991,
29973,
5931,
2396,
29936,
5033,
2314,
1159,
13,
13,
13,
1753,
903,
6979,
3950,
29898,
18616,
663,
1125,
13,
1678,
9995,
29963,
708,
6996,
5993,
3950,
29901,
6219,
278,
10541,
964,
263,
1051,
310,
18897,
718,
5224,
2141,
15945,
29908,
13,
1678,
3838,
353,
5159,
13,
1678,
363,
2913,
29918,
25048,
630,
29918,
20777,
297,
10541,
29889,
13609,
2141,
17010,
2141,
5451,
7295,
13,
4706,
3838,
29889,
21843,
29898,
276,
29889,
5451,
7373,
17013,
29918,
5550,
29931,
1806,
29892,
2913,
29918,
25048,
630,
29918,
20777,
876,
13,
1678,
736,
518,
29893,
363,
281,
297,
3838,
565,
281,
29962,
13,
13,
13,
1753,
5993,
3950,
29898,
18616,
663,
1125,
396,
14402,
29901,
451,
1985,
363,
18115,
19783,
267,
13,
1678,
10541,
353,
10541,
29889,
17010,
2141,
13609,
580,
13,
1678,
565,
1134,
29898,
18616,
663,
29897,
2804,
29104,
29901,
13,
4706,
10541,
353,
29104,
29898,
18616,
663,
29892,
8025,
2433,
9420,
29899,
29947,
742,
4436,
2433,
6506,
1495,
13,
1678,
10541,
353,
443,
680,
401,
29898,
18616,
663,
29897,
13,
1678,
10541,
353,
10541,
29889,
6506,
703,
29915,
9162,
13577,
1159,
13,
1678,
736,
1734,
29918,
6979,
675,
29898,
18616,
663,
29897,
13,
13,
13,
1753,
2048,
29918,
29894,
542,
370,
7295,
13,
1678,
1653,
29918,
29894,
542,
370,
352,
653,
29898,
13171,
3094,
29918,
29963,
20166,
2882,
29918,
10145,
29892,
349,
1001,
3094,
29918,
10145,
29892,
349,
1001,
3094,
29918,
29963,
20166,
2882,
29918,
12648,
29892,
5993,
3950,
29922,
6979,
3950,
29897,
13,
1678,
1653,
29918,
29894,
542,
370,
352,
653,
29898,
3970,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
12648,
29892,
5993,
3950,
29922,
6979,
3950,
29897,
13,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
349,
1001,
3094,
29918,
29963,
20166,
2882,
29918,
10145,
2314,
1723,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
11662,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
10145,
2314,
1723,
13,
13,
13,
1753,
2048,
29918,
4841,
7295,
13,
1678,
848,
29918,
517,
29918,
6979,
29918,
4841,
29898,
13171,
3094,
29918,
29911,
4717,
1177,
29918,
10145,
29892,
349,
1001,
3094,
29918,
29911,
4717,
1177,
29918,
1367,
29903,
29918,
10145,
29892,
349,
1001,
3094,
29918,
29963,
20166,
2882,
29918,
10145,
29892,
5993,
3950,
29922,
6979,
3950,
29897,
13,
1678,
848,
29918,
517,
29918,
6979,
29918,
4841,
29898,
13171,
3094,
29918,
2287,
29963,
29918,
10145,
29892,
349,
1001,
3094,
29918,
2287,
29963,
29918,
1367,
29903,
29918,
10145,
29892,
349,
1001,
3094,
29918,
29963,
20166,
2882,
29918,
10145,
29892,
5993,
3950,
29922,
6979,
3950,
29897,
13,
1678,
848,
29918,
517,
29918,
6979,
29918,
4841,
29898,
3970,
1783,
1955,
29918,
29911,
4717,
1177,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
29911,
4717,
1177,
29918,
1367,
29903,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
10145,
29892,
5993,
3950,
29922,
6979,
3950,
29897,
13,
1678,
848,
29918,
517,
29918,
6979,
29918,
4841,
29898,
3970,
1783,
1955,
29918,
2287,
29963,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
2287,
29963,
29918,
1367,
29903,
29918,
10145,
29892,
11662,
1783,
1955,
29918,
29963,
20166,
2882,
29918,
10145,
29892,
5993,
3950,
29922,
6979,
3950,
29897,
13,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
349,
1001,
3094,
29918,
29911,
4717,
1177,
29918,
1367,
29903,
29918,
10145,
2314,
1723,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
349,
1001,
3094,
29918,
2287,
29963,
29918,
1367,
29903,
29918,
10145,
2314,
1723,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
11662,
1783,
1955,
29918,
29911,
4717,
1177,
29918,
1367,
29903,
29918,
10145,
2314,
1723,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
11662,
1783,
1955,
29918,
2287,
29963,
29918,
1367,
29903,
29918,
10145,
2314,
1723,
13,
13,
1753,
6219,
29918,
23482,
29918,
842,
29898,
5451,
29918,
2311,
29922,
29941,
29900,
29900,
29900,
29900,
1125,
13,
1678,
396,
6219,
278,
8783,
964,
7945,
322,
2906,
6166,
313,
29875,
29915,
29885,
773,
6473,
12078,
29897,
13,
13,
1678,
1014,
5014,
29889,
4804,
18959,
5451,
742,
17411,
29880,
742,
851,
29898,
5451,
29918,
2311,
511,
349,
1001,
3094,
29918,
10145,
2314,
13,
1678,
1014,
5014,
29889,
4804,
18959,
29324,
742,
525,
29916,
7340,
742,
349,
1001,
3094,
29918,
29911,
4717,
1177,
29918,
10145,
2314,
13,
1678,
1014,
5014,
29889,
4804,
18959,
29324,
742,
525,
29916,
370,
742,
349,
1001,
3094,
29918,
2287,
29963,
29918,
10145,
2314,
13,
13,
1678,
1014,
5014,
29889,
4804,
18959,
5451,
742,
17411,
29880,
742,
851,
29898,
5451,
29918,
2311,
511,
11662,
1783,
1955,
29918,
10145,
2314,
13,
1678,
1014,
5014,
29889,
4804,
18959,
29324,
742,
525,
29916,
7340,
742,
11662,
1783,
1955,
29918,
29911,
4717,
1177,
29918,
10145,
2314,
13,
1678,
1014,
5014,
29889,
4804,
18959,
29324,
742,
525,
29916,
370,
742,
11662,
1783,
1955,
29918,
2287,
29963,
29918,
10145,
2314,
13,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
349,
1001,
3094,
29918,
29911,
4717,
1177,
29918,
10145,
2314,
1723,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
349,
1001,
3094,
29918,
2287,
29963,
29918,
10145,
2314,
1723,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
11662,
1783,
1955,
29918,
29911,
4717,
1177,
29918,
10145,
2314,
1723,
13,
1678,
1596,
29898,
1014,
5014,
29889,
3198,
29918,
4905,
18959,
29893,
29883,
742,
17411,
29880,
742,
11662,
1783,
1955,
29918,
2287,
29963,
29918,
10145,
2314,
1723,
13,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
6219,
29918,
23482,
29918,
842,
580,
13,
1678,
2048,
29918,
29894,
542,
370,
580,
13,
1678,
2048,
29918,
4841,
580,
2
] |
python_code/I_K_ATP_RMP_mg.py | mmaleck/chondrocyte | 1 | 26259 | import numpy as np
from scipy.integrate.odepack import odeint
import matplotlib.pyplot as plt
import functions
from chondrocyte import Voltage_clamp
from params import params_dict
import matplotlib as mpl
"""
The code is used to create Figure 4B for submitted paper
"Probing the putative role of KATP channels and biological variability in a mathematical model of chondrocyte electrophysiology”
"""
mpl.rcParams['font.family'] = 'Avenir'
plt.rcParams['font.size'] = 18
plt.rcParams['axes.linewidth'] = 2
# define time span
params_dict.update(t_final=180)
t_final = params_dict["t_final"]
dt = params_dict["dt"]
t = np.linspace(0, t_final, int(t_final/dt))
params_dict.update(Mg_i=1)
# Define initial condition vector
y0 = (params_dict["V_0"], params_dict["Na_i_0"], params_dict["K_i_0"], params_dict["Ca_i_0"], params_dict["H_i_0"],
params_dict["Cl_i_0"], params_dict["a_ur_0"], params_dict["i_ur_0"], params_dict["vol_i_0"],
params_dict["cal_0"])
fig, ax = plt.subplots()
params_dict.update(K_o_0=7, Mg_i=0.1)
solution1 = odeint(functions.rhs, y0, t, args=(params_dict,))
ax.plot(t, solution1[:,0], label="$\mathrm{[Mg^{2+}]_i}$=0.1 mM", color="k")
params_dict.update(Mg_i=1.0)
solution2 = odeint(functions.rhs, y0, t, args=(params_dict,))
ax.plot(t, solution2[:,0], label="$\mathrm{[Mg^{2+}]_i}$=1.0 mM", color="b")
params_dict.update(Mg_i=10)
solution3 = odeint(functions.rhs, y0, t, args=(params_dict,))
ax.plot(t, solution3[:,0], label="$\mathrm{[Mg^{2+}]_i}$=10 mM", color="r")
ax.set_xlabel("Time [s]", fontsize=16)
ax.set_ylabel("Membrane Potential [mV]", fontsize=16)
ax.xaxis.set_tick_params(which='major', size=14, width=2, direction='out')
ax.yaxis.set_tick_params(which='major', size=14, width=2, direction='out')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.legend(loc='upper right')
# plt.savefig("Fig4_B.png", bbox_inches='tight')
plt.show()
| [
1,
1053,
12655,
408,
7442,
13,
3166,
4560,
2272,
29889,
14146,
403,
29889,
356,
4058,
1053,
288,
311,
524,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
3168,
13,
3166,
521,
898,
307,
1270,
371,
1053,
3684,
29873,
482,
29918,
695,
1160,
13,
3166,
8636,
1053,
8636,
29918,
8977,
13,
5215,
22889,
408,
286,
572,
13,
13,
15945,
29908,
13,
1576,
775,
338,
1304,
304,
1653,
11479,
29871,
29946,
29933,
363,
18397,
5650,
29871,
13,
29908,
1184,
10549,
278,
1925,
1230,
6297,
310,
476,
1299,
29925,
18196,
322,
4768,
5996,
1197,
3097,
297,
263,
19475,
1904,
310,
521,
898,
307,
1270,
371,
28118,
14017,
29875,
3002,
30024,
13,
15945,
29908,
13,
13,
13,
29885,
572,
29889,
2214,
9629,
1839,
5657,
29889,
11922,
2033,
353,
525,
29909,
15470,
29915,
13,
572,
29873,
29889,
2214,
9629,
1839,
5657,
29889,
2311,
2033,
353,
29871,
29896,
29947,
13,
572,
29873,
29889,
2214,
9629,
1839,
1165,
267,
29889,
16292,
2033,
353,
29871,
29906,
13,
13,
13,
29937,
4529,
931,
10638,
13,
7529,
29918,
8977,
29889,
5504,
29898,
29873,
29918,
8394,
29922,
29896,
29947,
29900,
29897,
13,
29873,
29918,
8394,
353,
8636,
29918,
8977,
3366,
29873,
29918,
8394,
3108,
13,
6008,
353,
8636,
29918,
8977,
3366,
6008,
3108,
13,
29873,
353,
7442,
29889,
1915,
3493,
29898,
29900,
29892,
260,
29918,
8394,
29892,
938,
29898,
29873,
29918,
8394,
29914,
6008,
876,
13,
13,
7529,
29918,
8977,
29889,
5504,
29898,
29924,
29887,
29918,
29875,
29922,
29896,
29897,
13,
13,
29937,
22402,
2847,
4195,
4608,
13,
29891,
29900,
353,
313,
7529,
29918,
8977,
3366,
29963,
29918,
29900,
12436,
8636,
29918,
8977,
3366,
13695,
29918,
29875,
29918,
29900,
12436,
8636,
29918,
8977,
3366,
29968,
29918,
29875,
29918,
29900,
12436,
8636,
29918,
8977,
3366,
26270,
29918,
29875,
29918,
29900,
12436,
8636,
29918,
8977,
3366,
29950,
29918,
29875,
29918,
29900,
12436,
29871,
13,
418,
8636,
29918,
8977,
3366,
6821,
29918,
29875,
29918,
29900,
12436,
8636,
29918,
8977,
3366,
29874,
29918,
332,
29918,
29900,
12436,
8636,
29918,
8977,
3366,
29875,
29918,
332,
29918,
29900,
12436,
8636,
29918,
8977,
3366,
1555,
29918,
29875,
29918,
29900,
12436,
29871,
13,
418,
8636,
29918,
8977,
3366,
1052,
29918,
29900,
20068,
13,
13,
1003,
29892,
4853,
353,
14770,
29889,
1491,
26762,
580,
13,
13,
7529,
29918,
8977,
29889,
5504,
29898,
29968,
29918,
29877,
29918,
29900,
29922,
29955,
29892,
341,
29887,
29918,
29875,
29922,
29900,
29889,
29896,
29897,
13,
13,
2929,
918,
29896,
353,
288,
311,
524,
29898,
12171,
29889,
29878,
9499,
29892,
343,
29900,
29892,
260,
29892,
6389,
7607,
7529,
29918,
8977,
29892,
876,
13,
1165,
29889,
5317,
29898,
29873,
29892,
1650,
29896,
7503,
29892,
29900,
1402,
3858,
543,
4535,
3141,
13970,
29924,
29887,
998,
29906,
29974,
6525,
29918,
29875,
1042,
29922,
29900,
29889,
29896,
286,
29924,
613,
2927,
543,
29895,
1159,
13,
13,
7529,
29918,
8977,
29889,
5504,
29898,
29924,
29887,
29918,
29875,
29922,
29896,
29889,
29900,
29897,
13,
2929,
918,
29906,
353,
288,
311,
524,
29898,
12171,
29889,
29878,
9499,
29892,
343,
29900,
29892,
260,
29892,
6389,
7607,
7529,
29918,
8977,
29892,
876,
13,
1165,
29889,
5317,
29898,
29873,
29892,
1650,
29906,
7503,
29892,
29900,
1402,
3858,
543,
4535,
3141,
13970,
29924,
29887,
998,
29906,
29974,
6525,
29918,
29875,
1042,
29922,
29896,
29889,
29900,
286,
29924,
613,
2927,
543,
29890,
1159,
13,
13,
7529,
29918,
8977,
29889,
5504,
29898,
29924,
29887,
29918,
29875,
29922,
29896,
29900,
29897,
13,
2929,
918,
29941,
353,
288,
311,
524,
29898,
12171,
29889,
29878,
9499,
29892,
343,
29900,
29892,
260,
29892,
6389,
7607,
7529,
29918,
8977,
29892,
876,
13,
1165,
29889,
5317,
29898,
29873,
29892,
1650,
29941,
7503,
29892,
29900,
1402,
3858,
543,
4535,
3141,
13970,
29924,
29887,
998,
29906,
29974,
6525,
29918,
29875,
1042,
29922,
29896,
29900,
286,
29924,
613,
2927,
543,
29878,
1159,
13,
1165,
29889,
842,
29918,
29916,
1643,
703,
2481,
518,
29879,
29962,
613,
4079,
2311,
29922,
29896,
29953,
29897,
29871,
13,
1165,
29889,
842,
29918,
29891,
1643,
703,
29924,
1590,
10800,
10173,
2556,
518,
29885,
29963,
29962,
613,
4079,
2311,
29922,
29896,
29953,
29897,
13,
1165,
29889,
29916,
8990,
29889,
842,
29918,
24667,
29918,
7529,
29898,
4716,
2433,
21355,
742,
2159,
29922,
29896,
29946,
29892,
2920,
29922,
29906,
29892,
5305,
2433,
449,
1495,
13,
1165,
29889,
29891,
8990,
29889,
842,
29918,
24667,
29918,
7529,
29898,
4716,
2433,
21355,
742,
2159,
29922,
29896,
29946,
29892,
2920,
29922,
29906,
29892,
5305,
2433,
449,
1495,
13,
1165,
29889,
1028,
1475,
1839,
1266,
13359,
842,
29918,
12872,
29898,
8824,
29897,
13,
1165,
29889,
1028,
1475,
1839,
3332,
13359,
842,
29918,
12872,
29898,
8824,
29897,
13,
572,
29873,
29889,
26172,
29898,
2029,
2433,
21064,
1492,
1495,
13,
29937,
14770,
29889,
7620,
1003,
703,
13080,
29946,
29918,
29933,
29889,
2732,
613,
289,
1884,
29918,
262,
6609,
2433,
29873,
523,
1495,
13,
572,
29873,
29889,
4294,
580,
13,
13,
13,
2
] |
src/icupy/number.py | miute/icupy | 0 | 181091 | <filename>src/icupy/number.py<gh_stars>0
"""
Module for icu::number namespace
"""
from .icu.number import * # noqa
| [
1,
529,
9507,
29958,
4351,
29914,
293,
786,
29891,
29914,
4537,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
15945,
29908,
13,
7355,
363,
16077,
29884,
1057,
4537,
7397,
13,
15945,
29908,
13,
13,
3166,
869,
293,
29884,
29889,
4537,
1053,
334,
29871,
396,
694,
25621,
13,
2
] |
code/src/scripts/pause.py | nuvla/job-engine | 3 | 25578 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import docker
import socket
docker_client = docker.from_env()
myself = docker_client.containers.get(socket.gethostname())
myself.pause() | [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
5215,
10346,
13,
5215,
9909,
13,
13,
14695,
29918,
4645,
353,
10346,
29889,
3166,
29918,
6272,
580,
13,
13,
5781,
761,
353,
10346,
29918,
4645,
29889,
1285,
475,
414,
29889,
657,
29898,
11514,
29889,
29887,
621,
520,
978,
3101,
13,
13,
5781,
761,
29889,
29886,
1071,
580,
2
] |
scvelo/tools/pymc/pymc3_model.py | AlexanderAivazidis/scvelo | 0 | 90635 | <reponame>AlexanderAivazidis/scvelo<filename>scvelo/tools/pymc/pymc3_model.py
# -*- coding: utf-8 -*-
r"""Base Pymc3 model class for all models in pymc3"""
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pymc3 as pm
import theano
from pymc3.variational.callbacks import CheckParametersConvergence
from tqdm.auto import tqdm
from scvelo.tools.pymc.base_model import BaseModel
# base model class - defining shared methods but not the model itself
class Pymc3Model(BaseModel):
r"""This class provides functions to train PyMC3 models and sample their parameters.
A model must have a main X_data input and can have arbitrary self.extra_data inputs.
Parameters
----------
X_data :
Numpy array of gene expression (cols) in spatial locations (rows)
all other:
the rest are arguments for parent class BaseModel
"""
def __init__(
self,
X_data: np.ndarray,
data_type: str = 'float32',
n_iter: int = 200000,
learning_rate=0.001,
total_grad_norm_constraint=200,
verbose=True,
var_names=None, var_names_read=None,
obs_names=None, sample_id=None
):
############# Initialise parameters ################
super().__init__(X_data,
data_type, n_iter,
learning_rate, total_grad_norm_constraint,
verbose, var_names, var_names_read,
obs_names, sample_id)
# Create dictionaries storing results
self.advi = {}
self.mean_field = {}
self.samples = {}
self.node_samples = {}
self.n_type = 'restart' # default
# Pass data to theano
self.x_data = theano.shared(X_data.astype(self.data_type))
def sample_prior(self, samples=10):
r"""Take samples from the prior, see `pymc3.sample_prior_predictive` for details
Parameters
----------
samples :
(Default value = 10)
Returns
-------
dict
self.prior_trace dictionary with an element for each parameter of the mode
"""
# Take samples from the prior
with self.model:
self.prior_trace = pm.sample_prior_predictive(samples=samples)
def fit_advi_iterative(self, n=3, method='advi', n_type='restart',
n_iter=None,
learning_rate=None, reducing_lr=False,
progressbar=True,
scale_cost_to_minibatch=True):
"""Find posterior using pm.ADVI() method directly (allows continuing training through `refine` method.
(maximising likelihood of the data and minimising KL-divergence of posterior to prior - ELBO loss)
Parameters
----------
n :
number of independent initialisations (Default value = 3)
method :
advi', to allow for potential use of SVGD, MCMC, custom (currently only ADVI implemented). (Default value = 'advi')
n_type :
type of repeated initialisation:
* **'restart'** to pick different initial value,
* **'cv'** for molecular cross-validation - splits counts into n datasets, for now, only n=2 is implemented
* **'bootstrap'** for fitting the model to multiple downsampled datasets.
Run `mod.bootstrap_data()` to generate variants of data (Default value = 'restart')
n_iter :
number of iterations, supersedes self.n_iter specified when creating model instance. (Default value = None)
learning_rate :
learning rate, supersedes self.learning_rate specified when creating model instance. (Default value = None)
reducing_lr :
boolean, use decaying learning rate? (Default value = False)
progressbar :
boolean, show progress bar? (Default value = True)
scale_cost_to_minibatch :
when using training in minibatches, scale cost function appropriately?
See discussion https://discourse.pymc.io/t/effects-of-scale-cost-to-minibatch/1429 to understand the effects. (Default value = True)
Returns
-------
None
self.mean_field dictionary with MeanField pymc3 objects,
and self.advi dictionary with ADVI objects for each initialisation.
"""
self.n_type = n_type
self.scale_cost_to_minibatch = scale_cost_to_minibatch
if n_iter is None:
n_iter = self.n_iter
if learning_rate is None:
learning_rate = self.learning_rate
### Initialise optimiser ###
if reducing_lr:
# initialise the function for adaptive learning rate
s = theano.shared(np.array(learning_rate).astype(self.data_type))
def reduce_rate(a, h, i):
s.set_value(np.array(learning_rate / ((i / self.n_cells) + 1) ** .7).astype(self.data_type))
optimiser = pm.adam(learning_rate=s)
callbacks = [reduce_rate, CheckParametersConvergence()]
else:
optimiser = pm.adam(learning_rate=learning_rate)
callbacks = [CheckParametersConvergence()]
if np.isin(n_type, ['bootstrap']):
if self.X_data_sample is None:
self.bootstrap_data(n=n)
elif np.isin(n_type, ['cv']):
self.generate_cv_data() # cv data added to self.X_data_sample
init_names = ['init_' + str(i + 1) for i in np.arange(n)]
for i, name in enumerate(init_names):
with self.model:
self.advi[name] = pm.ADVI(random_seed = 99)
# when type is molecular cross-validation or bootstrap,
# replace self.x_data tensor with new data
if np.isin(n_type, ['cv', 'bootstrap']):
# defining minibatch
if self.minibatch_size is not None:
# minibatch main data - expression matrix
self.x_data_minibatch = pm.Minibatch(self.X_data_sample[i].astype(self.data_type),
batch_size=[self.minibatch_size, None],
random_seed=self.minibatch_seed[i])
more_replacements = {self.x_data: self.x_data_minibatch}
# if any other data inputs should be minibatched add them too
if self.extra_data is not None:
# for each parameter in the dictionary add it to more_replacements
for k in self.extra_data.keys():
more_replacements[self.extra_data_tt[k]] = \
pm.Minibatch(self.extra_data[k].astype(self.data_type),
batch_size=[self.minibatch_size, None],
random_seed=self.minibatch_seed[i])
# or using all data
else:
more_replacements = {self.x_data: self.X_data_sample[i].astype(self.data_type)}
# if any other data inputs should be added
if self.extra_data is not None:
# for each parameter in the dictionary add it to more_replacements
for k in self.extra_data.keys():
more_replacements[self.extra_data_tt[k]] = \
self.extra_data[k].astype(self.data_type)
else:
# defining minibatch
if self.minibatch_size is not None:
# minibatch main data - expression matrix
self.x_data_minibatch = pm.Minibatch(self.X_data.astype(self.data_type),
batch_size=[self.minibatch_size, None],
random_seed=self.minibatch_seed[i])
more_replacements = {self.x_data: self.x_data_minibatch}
# if any other data inputs should be minibatched add them too
if self.extra_data is not None:
# for each parameter in the dictionary add it to more_replacements
for k in self.extra_data.keys():
more_replacements[self.extra_data_tt[k]] = \
pm.Minibatch(self.extra_data[k].astype(self.data_type),
batch_size=[self.minibatch_size, None],
random_seed=self.minibatch_seed[i])
else:
more_replacements = {}
self.advi[name].scale_cost_to_minibatch = scale_cost_to_minibatch
# train the model
self.mean_field[name] = self.advi[name].fit(n_iter, callbacks=callbacks,
obj_optimizer=optimiser,
total_grad_norm_constraint=self.total_grad_norm_constraint,
progressbar=progressbar, more_replacements=more_replacements,
)
# plot training history
if self.verbose:
print(plt.plot(np.log10(self.mean_field[name].hist[15000:])));
def plot_history(self, iter_start=0, iter_end=-1):
"""Plot loss function (ELBO) across training history
Parameters
----------
iter_start :
omit initial iterations from the plot (Default value = 0)
iter_end :
omit last iterations from the plot (Default value = -1)
"""
for i in self.mean_field.keys():
print(plt.plot(np.log10(self.mean_field[i].hist[iter_start:iter_end])))
def sample_posterior(self, node='all', n_samples=1000,
save_samples=False, return_samples=True,
mean_field_slot='init_1'):
"""Sample posterior distribution of all parameters or single parameter
Parameters
----------
node :
pymc3 node to sample (e.g. default "all", self.spot_factors)
n_samples :
number of posterior samples to generate (1000 is recommended, reduce if you get GPU memory error) (Default value = 1000)
save_samples :
save all samples, not just the mean, 5% and 95% quantile, SD. (Default value = False)
return_samples :
return summarised samples (mean, etc) in addition to saving them in `self.samples`? (Default value = True)
mean_field_slot :
string, which training initialisation (mean_field slot) to sample? 'init_1' by default
Returns
-------
dict
dictionary `self.samples` (mean, 5% quantile, SD, optionally all samples) with dictionaries
with numpy arrays for each parameter.
Plus an optional dictionary in `self.samples` with all samples of parameters
as numpy arrays of shape ``(n_samples, ...)``
"""
theano.config.compute_test_value = 'ignore'
if node == 'all':
# Sample all parameters - might use a lot of GPU memory
post_samples = self.mean_field[mean_field_slot].sample(n_samples)
self.samples['post_sample_means'] = {v: post_samples[v].mean(axis=0) for v in post_samples.varnames}
self.samples['post_sample_q05'] = {v: np.quantile(post_samples[v], 0.05, axis=0) for v in
post_samples.varnames}
self.samples['post_sample_q95'] = {v: np.quantile(post_samples[v], 0.95, axis=0) for v in
post_samples.varnames}
self.samples['post_sample_q01'] = {v: np.quantile(post_samples[v], 0.01, axis=0) for v in
post_samples.varnames}
self.samples['post_sample_q99'] = {v: np.quantile(post_samples[v], 0.99, axis=0) for v in
post_samples.varnames}
self.samples['post_sample_sds'] = {v: post_samples[v].std(axis=0) for v in post_samples.varnames}
if (save_samples):
# convert multitrace object to a dictionary
post_samples = {v: post_samples[v] for v in post_samples.varnames}
self.samples['post_samples'] = post_samples
else:
# Sample a singe node
post_node = self.mean_field[mean_field_slot].sample_node(node, size=n_samples).eval()
post_node_mean = post_node.mean(0)
post_node_q05 = np.quantile(post_node, 0.05, axis=0)
post_node_q95 = np.quantile(post_node, 0.95, axis=0)
post_node_q01 = np.quantile(post_node, 0.01, axis=0)
post_node_q99 = np.quantile(post_node, 0.99, axis=0)
post_node_sds = post_node.std(0)
# extract the name of the node and save to samples dictionary
node_name = node.name
self.node_samples[str(node_name) + '_mean'] = post_node_mean
self.node_samples[str(node_name) + '_q05'] = post_node_q05
self.node_samples[str(node_name) + '_q95'] = post_node_q95
self.node_samples[str(node_name) + '_q01'] = post_node_q01
self.node_samples[str(node_name) + '_q99'] = post_node_q99
self.node_samples[str(node_name) + '_sds'] = post_node_sds
if save_samples:
self.node_samples[str(node_name) + '_post_samples'] = post_node
if return_samples:
return self.samples
| [
1,
529,
276,
1112,
420,
29958,
17406,
3825,
29909,
440,
834,
333,
275,
29914,
1557,
955,
29877,
29966,
9507,
29958,
1557,
955,
29877,
29914,
8504,
29914,
29886,
962,
29883,
29914,
29886,
962,
29883,
29941,
29918,
4299,
29889,
2272,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
29878,
15945,
29908,
5160,
349,
962,
29883,
29941,
1904,
770,
363,
599,
4733,
297,
282,
962,
29883,
29941,
15945,
29908,
13,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
12655,
408,
7442,
13,
5215,
11701,
408,
10518,
13,
5215,
282,
962,
29883,
29941,
408,
26354,
13,
5215,
278,
1562,
13,
3166,
282,
962,
29883,
29941,
29889,
5927,
1288,
29889,
14035,
29879,
1053,
5399,
11507,
1168,
369,
10238,
13,
3166,
260,
29939,
18933,
29889,
6921,
1053,
260,
29939,
18933,
13,
13,
3166,
885,
955,
29877,
29889,
8504,
29889,
29886,
962,
29883,
29889,
3188,
29918,
4299,
1053,
7399,
3195,
13,
13,
29937,
2967,
1904,
770,
448,
16184,
7258,
3519,
541,
451,
278,
1904,
3528,
13,
1990,
349,
962,
29883,
29941,
3195,
29898,
5160,
3195,
1125,
13,
1678,
364,
15945,
29908,
4013,
770,
8128,
3168,
304,
7945,
10772,
12513,
29941,
4733,
322,
4559,
1009,
4128,
29889,
13,
1678,
319,
1904,
1818,
505,
263,
1667,
1060,
29918,
1272,
1881,
322,
508,
505,
11472,
1583,
29889,
17833,
29918,
1272,
10970,
29889,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
1060,
29918,
1272,
584,
13,
4706,
11848,
2272,
1409,
310,
18530,
4603,
313,
22724,
29897,
297,
18652,
14354,
313,
5727,
29897,
13,
1678,
599,
916,
29901,
13,
4706,
278,
1791,
526,
6273,
363,
3847,
770,
7399,
3195,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
13,
9651,
1583,
29892,
13,
9651,
1060,
29918,
1272,
29901,
7442,
29889,
299,
2378,
29892,
13,
9651,
848,
29918,
1853,
29901,
851,
353,
525,
7411,
29941,
29906,
742,
13,
9651,
302,
29918,
1524,
29901,
938,
353,
29871,
29906,
29900,
29900,
29900,
29900,
29900,
29892,
13,
9651,
6509,
29918,
10492,
29922,
29900,
29889,
29900,
29900,
29896,
29892,
13,
9651,
3001,
29918,
5105,
29918,
12324,
29918,
13646,
29922,
29906,
29900,
29900,
29892,
13,
9651,
26952,
29922,
5574,
29892,
13,
9651,
722,
29918,
7039,
29922,
8516,
29892,
722,
29918,
7039,
29918,
949,
29922,
8516,
29892,
13,
9651,
20881,
29918,
7039,
29922,
8516,
29892,
4559,
29918,
333,
29922,
8516,
13,
268,
1125,
13,
13,
4706,
835,
7346,
2277,
17250,
895,
4128,
835,
7346,
4136,
29937,
13,
4706,
2428,
2141,
1649,
2344,
12035,
29990,
29918,
1272,
29892,
13,
462,
308,
848,
29918,
1853,
29892,
302,
29918,
1524,
29892,
13,
462,
308,
6509,
29918,
10492,
29892,
3001,
29918,
5105,
29918,
12324,
29918,
13646,
29892,
13,
462,
308,
26952,
29892,
722,
29918,
7039,
29892,
722,
29918,
7039,
29918,
949,
29892,
13,
462,
308,
20881,
29918,
7039,
29892,
4559,
29918,
333,
29897,
13,
13,
4706,
396,
6204,
21503,
4314,
15446,
2582,
13,
4706,
1583,
29889,
328,
1403,
353,
6571,
13,
4706,
1583,
29889,
12676,
29918,
2671,
353,
6571,
13,
4706,
1583,
29889,
27736,
353,
6571,
13,
4706,
1583,
29889,
3177,
29918,
27736,
353,
6571,
13,
4706,
1583,
29889,
29876,
29918,
1853,
353,
525,
5060,
442,
29915,
396,
2322,
13,
13,
4706,
396,
6978,
848,
304,
278,
1562,
13,
4706,
1583,
29889,
29916,
29918,
1272,
353,
278,
1562,
29889,
12366,
29898,
29990,
29918,
1272,
29889,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
876,
13,
13,
1678,
822,
4559,
29918,
29886,
13479,
29898,
1311,
29892,
11916,
29922,
29896,
29900,
1125,
13,
4706,
364,
15945,
29908,
26772,
11916,
515,
278,
7536,
29892,
1074,
421,
29886,
962,
29883,
29941,
29889,
11249,
29918,
29886,
13479,
29918,
27711,
573,
29952,
363,
4902,
13,
13,
4706,
12662,
2699,
13,
4706,
448,
1378,
29899,
13,
4706,
11916,
584,
13,
632,
313,
4592,
995,
353,
29871,
29896,
29900,
29897,
13,
13,
4706,
16969,
13,
4706,
448,
22158,
13,
4706,
9657,
13,
9651,
1583,
29889,
29886,
13479,
29918,
15003,
8600,
411,
385,
1543,
363,
1269,
3443,
310,
278,
4464,
13,
4706,
9995,
13,
4706,
396,
11190,
11916,
515,
278,
7536,
13,
4706,
411,
1583,
29889,
4299,
29901,
13,
9651,
1583,
29889,
29886,
13479,
29918,
15003,
353,
26354,
29889,
11249,
29918,
29886,
13479,
29918,
27711,
573,
29898,
27736,
29922,
27736,
29897,
13,
13,
1678,
822,
6216,
29918,
328,
1403,
29918,
1524,
1230,
29898,
1311,
29892,
302,
29922,
29941,
29892,
1158,
2433,
328,
1403,
742,
302,
29918,
1853,
2433,
5060,
442,
742,
13,
462,
965,
302,
29918,
1524,
29922,
8516,
29892,
13,
462,
965,
6509,
29918,
10492,
29922,
8516,
29892,
27668,
29918,
29212,
29922,
8824,
29892,
13,
462,
965,
6728,
1646,
29922,
5574,
29892,
13,
462,
965,
6287,
29918,
18253,
29918,
517,
29918,
1195,
747,
905,
29922,
5574,
1125,
13,
4706,
9995,
12542,
13446,
773,
26354,
29889,
3035,
18118,
580,
1158,
4153,
313,
497,
1242,
3133,
292,
6694,
1549,
421,
999,
457,
29952,
1158,
29889,
13,
4706,
313,
27525,
5921,
4188,
22342,
310,
278,
848,
322,
6260,
5921,
476,
29931,
29899,
29881,
2147,
10238,
310,
13446,
304,
7536,
448,
14845,
8456,
6410,
29897,
13,
13,
4706,
12662,
2699,
13,
4706,
448,
1378,
29899,
13,
4706,
302,
584,
13,
9651,
1353,
310,
7417,
2847,
275,
800,
313,
4592,
995,
353,
29871,
29941,
29897,
13,
4706,
1158,
584,
13,
9651,
594,
1403,
742,
304,
2758,
363,
7037,
671,
310,
13955,
29954,
29928,
29892,
21271,
12513,
29892,
2888,
313,
3784,
368,
871,
11033,
18118,
8762,
467,
313,
4592,
995,
353,
525,
328,
1403,
1495,
13,
4706,
302,
29918,
1853,
584,
13,
9651,
1134,
310,
10324,
2847,
4371,
29901,
13,
632,
13,
9651,
334,
3579,
29915,
5060,
442,
29915,
1068,
304,
5839,
1422,
2847,
995,
29892,
13,
9651,
334,
3579,
29915,
11023,
29915,
1068,
363,
13206,
16637,
4891,
29899,
18157,
448,
8536,
1169,
18139,
964,
302,
20035,
29892,
363,
1286,
29892,
871,
302,
29922,
29906,
338,
8762,
13,
9651,
334,
3579,
29915,
8704,
29915,
1068,
363,
28221,
278,
1904,
304,
2999,
1623,
11249,
29881,
20035,
29889,
13,
795,
7525,
421,
1545,
29889,
8704,
29918,
1272,
2555,
304,
5706,
29161,
310,
848,
313,
4592,
995,
353,
525,
5060,
442,
1495,
13,
13,
4706,
302,
29918,
1524,
584,
13,
9651,
1353,
310,
24372,
29892,
480,
6774,
11696,
1583,
29889,
29876,
29918,
1524,
6790,
746,
4969,
1904,
2777,
29889,
313,
4592,
995,
353,
6213,
29897,
13,
4706,
6509,
29918,
10492,
584,
13,
9651,
6509,
6554,
29892,
480,
6774,
11696,
1583,
29889,
21891,
29918,
10492,
6790,
746,
4969,
1904,
2777,
29889,
313,
4592,
995,
353,
6213,
29897,
13,
4706,
27668,
29918,
29212,
584,
13,
9651,
7223,
29892,
671,
20228,
292,
6509,
6554,
29973,
313,
4592,
995,
353,
7700,
29897,
13,
4706,
6728,
1646,
584,
13,
9651,
7223,
29892,
1510,
6728,
2594,
29973,
313,
4592,
995,
353,
5852,
29897,
13,
4706,
6287,
29918,
18253,
29918,
517,
29918,
1195,
747,
905,
584,
13,
9651,
746,
773,
6694,
297,
1375,
747,
905,
267,
29892,
6287,
3438,
740,
7128,
2486,
29973,
13,
9651,
2823,
10679,
2045,
597,
2218,
15775,
29889,
29886,
962,
29883,
29889,
601,
29914,
29873,
29914,
15987,
29879,
29899,
974,
29899,
7052,
29899,
18253,
29899,
517,
29899,
1195,
747,
905,
29914,
29896,
29946,
29906,
29929,
304,
2274,
278,
9545,
29889,
313,
4592,
995,
353,
5852,
29897,
13,
13,
4706,
16969,
13,
4706,
448,
22158,
13,
4706,
6213,
13,
9651,
1583,
29889,
12676,
29918,
2671,
8600,
411,
16316,
3073,
282,
962,
29883,
29941,
3618,
29892,
13,
9651,
322,
1583,
29889,
328,
1403,
8600,
411,
11033,
18118,
3618,
363,
1269,
2847,
4371,
29889,
13,
13,
4706,
9995,
13,
13,
4706,
1583,
29889,
29876,
29918,
1853,
353,
302,
29918,
1853,
13,
4706,
1583,
29889,
7052,
29918,
18253,
29918,
517,
29918,
1195,
747,
905,
353,
6287,
29918,
18253,
29918,
517,
29918,
1195,
747,
905,
13,
13,
4706,
565,
302,
29918,
1524,
338,
6213,
29901,
13,
9651,
302,
29918,
1524,
353,
1583,
29889,
29876,
29918,
1524,
13,
13,
4706,
565,
6509,
29918,
10492,
338,
6213,
29901,
13,
9651,
6509,
29918,
10492,
353,
1583,
29889,
21891,
29918,
10492,
13,
13,
4706,
835,
17250,
895,
5994,
7608,
835,
13,
4706,
565,
27668,
29918,
29212,
29901,
13,
9651,
396,
2847,
895,
278,
740,
363,
7744,
573,
6509,
6554,
13,
9651,
269,
353,
278,
1562,
29889,
12366,
29898,
9302,
29889,
2378,
29898,
21891,
29918,
10492,
467,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
876,
13,
13,
9651,
822,
10032,
29918,
10492,
29898,
29874,
29892,
298,
29892,
474,
1125,
13,
18884,
269,
29889,
842,
29918,
1767,
29898,
9302,
29889,
2378,
29898,
21891,
29918,
10492,
847,
5135,
29875,
847,
1583,
29889,
29876,
29918,
3729,
29879,
29897,
718,
29871,
29896,
29897,
3579,
869,
29955,
467,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
876,
13,
13,
9651,
5994,
7608,
353,
26354,
29889,
328,
314,
29898,
21891,
29918,
10492,
29922,
29879,
29897,
13,
9651,
6939,
29879,
353,
518,
17469,
29918,
10492,
29892,
5399,
11507,
1168,
369,
10238,
580,
29962,
13,
4706,
1683,
29901,
13,
9651,
5994,
7608,
353,
26354,
29889,
328,
314,
29898,
21891,
29918,
10492,
29922,
21891,
29918,
10492,
29897,
13,
9651,
6939,
29879,
353,
518,
5596,
11507,
1168,
369,
10238,
580,
29962,
13,
13,
4706,
565,
7442,
29889,
275,
262,
29898,
29876,
29918,
1853,
29892,
6024,
8704,
2033,
1125,
13,
9651,
565,
1583,
29889,
29990,
29918,
1272,
29918,
11249,
338,
6213,
29901,
13,
18884,
1583,
29889,
8704,
29918,
1272,
29898,
29876,
29922,
29876,
29897,
13,
4706,
25342,
7442,
29889,
275,
262,
29898,
29876,
29918,
1853,
29892,
6024,
11023,
2033,
1125,
13,
9651,
1583,
29889,
17158,
29918,
11023,
29918,
1272,
580,
29871,
396,
13850,
848,
2715,
304,
1583,
29889,
29990,
29918,
1272,
29918,
11249,
13,
13,
4706,
2069,
29918,
7039,
353,
6024,
2344,
29918,
29915,
718,
851,
29898,
29875,
718,
29871,
29896,
29897,
363,
474,
297,
7442,
29889,
279,
927,
29898,
29876,
4638,
13,
13,
4706,
363,
474,
29892,
1024,
297,
26985,
29898,
2344,
29918,
7039,
1125,
13,
13,
9651,
411,
1583,
29889,
4299,
29901,
13,
13,
18884,
1583,
29889,
328,
1403,
29961,
978,
29962,
353,
26354,
29889,
3035,
18118,
29898,
8172,
29918,
26776,
353,
29871,
29929,
29929,
29897,
13,
13,
9651,
396,
746,
1134,
338,
13206,
16637,
4891,
29899,
18157,
470,
16087,
29892,
29871,
13,
9651,
396,
5191,
1583,
29889,
29916,
29918,
1272,
12489,
411,
716,
848,
13,
9651,
565,
7442,
29889,
275,
262,
29898,
29876,
29918,
1853,
29892,
6024,
11023,
742,
525,
8704,
2033,
1125,
13,
13,
18884,
396,
16184,
1375,
747,
905,
13,
18884,
565,
1583,
29889,
1195,
747,
905,
29918,
2311,
338,
451,
6213,
29901,
13,
462,
1678,
396,
1375,
747,
905,
1667,
848,
448,
4603,
4636,
13,
462,
1678,
1583,
29889,
29916,
29918,
1272,
29918,
1195,
747,
905,
353,
26354,
29889,
8140,
747,
905,
29898,
1311,
29889,
29990,
29918,
1272,
29918,
11249,
29961,
29875,
1822,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
511,
13,
462,
462,
462,
308,
9853,
29918,
2311,
11759,
1311,
29889,
1195,
747,
905,
29918,
2311,
29892,
6213,
1402,
13,
462,
462,
462,
308,
4036,
29918,
26776,
29922,
1311,
29889,
1195,
747,
905,
29918,
26776,
29961,
29875,
2314,
13,
462,
1678,
901,
29918,
3445,
4620,
4110,
353,
426,
1311,
29889,
29916,
29918,
1272,
29901,
1583,
29889,
29916,
29918,
1272,
29918,
1195,
747,
905,
29913,
13,
13,
462,
1678,
396,
565,
738,
916,
848,
10970,
881,
367,
1375,
747,
905,
287,
788,
963,
2086,
13,
462,
1678,
565,
1583,
29889,
17833,
29918,
1272,
338,
451,
6213,
29901,
13,
462,
4706,
396,
363,
1269,
3443,
297,
278,
8600,
788,
372,
304,
901,
29918,
3445,
4620,
4110,
13,
462,
4706,
363,
413,
297,
1583,
29889,
17833,
29918,
1272,
29889,
8149,
7295,
13,
462,
9651,
901,
29918,
3445,
4620,
4110,
29961,
1311,
29889,
17833,
29918,
1272,
29918,
698,
29961,
29895,
5262,
353,
320,
13,
462,
18884,
26354,
29889,
8140,
747,
905,
29898,
1311,
29889,
17833,
29918,
1272,
29961,
29895,
1822,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
511,
13,
462,
462,
632,
9853,
29918,
2311,
11759,
1311,
29889,
1195,
747,
905,
29918,
2311,
29892,
6213,
1402,
13,
462,
462,
632,
4036,
29918,
26776,
29922,
1311,
29889,
1195,
747,
905,
29918,
26776,
29961,
29875,
2314,
13,
13,
18884,
396,
470,
773,
599,
848,
13,
18884,
1683,
29901,
13,
462,
1678,
901,
29918,
3445,
4620,
4110,
353,
426,
1311,
29889,
29916,
29918,
1272,
29901,
1583,
29889,
29990,
29918,
1272,
29918,
11249,
29961,
29875,
1822,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
2915,
13,
462,
1678,
396,
565,
738,
916,
848,
10970,
881,
367,
2715,
13,
462,
1678,
565,
1583,
29889,
17833,
29918,
1272,
338,
451,
6213,
29901,
13,
462,
4706,
396,
363,
1269,
3443,
297,
278,
8600,
788,
372,
304,
901,
29918,
3445,
4620,
4110,
13,
462,
4706,
363,
413,
297,
1583,
29889,
17833,
29918,
1272,
29889,
8149,
7295,
13,
462,
9651,
901,
29918,
3445,
4620,
4110,
29961,
1311,
29889,
17833,
29918,
1272,
29918,
698,
29961,
29895,
5262,
353,
320,
13,
462,
18884,
1583,
29889,
17833,
29918,
1272,
29961,
29895,
1822,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
29897,
13,
13,
9651,
1683,
29901,
13,
13,
18884,
396,
16184,
1375,
747,
905,
13,
18884,
565,
1583,
29889,
1195,
747,
905,
29918,
2311,
338,
451,
6213,
29901,
13,
462,
1678,
396,
1375,
747,
905,
1667,
848,
448,
4603,
4636,
13,
462,
1678,
1583,
29889,
29916,
29918,
1272,
29918,
1195,
747,
905,
353,
26354,
29889,
8140,
747,
905,
29898,
1311,
29889,
29990,
29918,
1272,
29889,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
511,
13,
462,
462,
462,
308,
9853,
29918,
2311,
11759,
1311,
29889,
1195,
747,
905,
29918,
2311,
29892,
6213,
1402,
13,
462,
462,
462,
308,
4036,
29918,
26776,
29922,
1311,
29889,
1195,
747,
905,
29918,
26776,
29961,
29875,
2314,
13,
462,
1678,
901,
29918,
3445,
4620,
4110,
353,
426,
1311,
29889,
29916,
29918,
1272,
29901,
1583,
29889,
29916,
29918,
1272,
29918,
1195,
747,
905,
29913,
13,
13,
462,
1678,
396,
565,
738,
916,
848,
10970,
881,
367,
1375,
747,
905,
287,
788,
963,
2086,
13,
462,
1678,
565,
1583,
29889,
17833,
29918,
1272,
338,
451,
6213,
29901,
13,
462,
4706,
396,
363,
1269,
3443,
297,
278,
8600,
788,
372,
304,
901,
29918,
3445,
4620,
4110,
13,
462,
4706,
363,
413,
297,
1583,
29889,
17833,
29918,
1272,
29889,
8149,
7295,
13,
462,
9651,
901,
29918,
3445,
4620,
4110,
29961,
1311,
29889,
17833,
29918,
1272,
29918,
698,
29961,
29895,
5262,
353,
320,
13,
462,
18884,
26354,
29889,
8140,
747,
905,
29898,
1311,
29889,
17833,
29918,
1272,
29961,
29895,
1822,
579,
668,
29898,
1311,
29889,
1272,
29918,
1853,
511,
13,
462,
462,
632,
9853,
29918,
2311,
11759,
1311,
29889,
1195,
747,
905,
29918,
2311,
29892,
6213,
1402,
13,
462,
462,
632,
4036,
29918,
26776,
29922,
1311,
29889,
1195,
747,
905,
29918,
26776,
29961,
29875,
2314,
13,
13,
18884,
1683,
29901,
13,
462,
1678,
901,
29918,
3445,
4620,
4110,
353,
6571,
13,
13,
9651,
1583,
29889,
328,
1403,
29961,
978,
1822,
7052,
29918,
18253,
29918,
517,
29918,
1195,
747,
905,
353,
6287,
29918,
18253,
29918,
517,
29918,
1195,
747,
905,
13,
13,
9651,
396,
7945,
278,
1904,
259,
13,
9651,
1583,
29889,
12676,
29918,
2671,
29961,
978,
29962,
353,
1583,
29889,
328,
1403,
29961,
978,
1822,
9202,
29898,
29876,
29918,
1524,
29892,
6939,
29879,
29922,
14035,
29879,
29892,
13,
462,
462,
462,
4706,
5446,
29918,
20640,
3950,
29922,
20640,
7608,
29892,
13,
462,
462,
462,
4706,
3001,
29918,
5105,
29918,
12324,
29918,
13646,
29922,
1311,
29889,
7827,
29918,
5105,
29918,
12324,
29918,
13646,
29892,
13,
462,
462,
462,
4706,
6728,
1646,
29922,
18035,
1646,
29892,
901,
29918,
3445,
4620,
4110,
29922,
5514,
29918,
3445,
4620,
4110,
29892,
13,
462,
462,
462,
4706,
1723,
13,
13,
9651,
396,
6492,
6694,
4955,
13,
9651,
565,
1583,
29889,
369,
15828,
29901,
13,
18884,
1596,
29898,
572,
29873,
29889,
5317,
29898,
9302,
29889,
1188,
29896,
29900,
29898,
1311,
29889,
12676,
29918,
2671,
29961,
978,
1822,
29882,
391,
29961,
29896,
29945,
29900,
29900,
29900,
29901,
12622,
416,
13,
13,
1678,
822,
6492,
29918,
18434,
29898,
1311,
29892,
4256,
29918,
2962,
29922,
29900,
29892,
4256,
29918,
355,
10457,
29896,
1125,
13,
4706,
9995,
20867,
6410,
740,
313,
6670,
8456,
29897,
4822,
6694,
4955,
13,
13,
4706,
12662,
2699,
13,
4706,
448,
1378,
29899,
13,
4706,
4256,
29918,
2962,
584,
13,
9651,
288,
2415,
2847,
24372,
515,
278,
6492,
313,
4592,
995,
353,
29871,
29900,
29897,
13,
4706,
4256,
29918,
355,
584,
13,
9651,
288,
2415,
1833,
24372,
515,
278,
6492,
313,
4592,
995,
353,
448,
29896,
29897,
13,
13,
4706,
9995,
13,
4706,
363,
474,
297,
1583,
29889,
12676,
29918,
2671,
29889,
8149,
7295,
13,
9651,
1596,
29898,
572,
29873,
29889,
5317,
29898,
9302,
29889,
1188,
29896,
29900,
29898,
1311,
29889,
12676,
29918,
2671,
29961,
29875,
1822,
29882,
391,
29961,
1524,
29918,
2962,
29901,
1524,
29918,
355,
29962,
4961,
13,
13,
1678,
822,
4559,
29918,
2490,
261,
1611,
29898,
1311,
29892,
2943,
2433,
497,
742,
302,
29918,
27736,
29922,
29896,
29900,
29900,
29900,
29892,
13,
462,
308,
4078,
29918,
27736,
29922,
8824,
29892,
736,
29918,
27736,
29922,
5574,
29892,
13,
462,
308,
2099,
29918,
2671,
29918,
2536,
327,
2433,
2344,
29918,
29896,
29374,
13,
4706,
9995,
17708,
13446,
4978,
310,
599,
4128,
470,
2323,
3443,
13,
13,
4706,
12662,
2699,
13,
4706,
448,
1378,
29899,
13,
4706,
2943,
584,
13,
9651,
282,
962,
29883,
29941,
2943,
304,
4559,
313,
29872,
29889,
29887,
29889,
2322,
376,
497,
613,
1583,
29889,
17500,
29918,
17028,
943,
29897,
13,
4706,
302,
29918,
27736,
584,
13,
9651,
1353,
310,
13446,
11916,
304,
5706,
313,
29896,
29900,
29900,
29900,
338,
13622,
29892,
10032,
565,
366,
679,
22796,
3370,
1059,
29897,
313,
4592,
995,
353,
29871,
29896,
29900,
29900,
29900,
29897,
13,
4706,
4078,
29918,
27736,
584,
13,
9651,
4078,
599,
11916,
29892,
451,
925,
278,
2099,
29892,
29871,
29945,
29995,
322,
29871,
29929,
29945,
29995,
4323,
488,
29892,
8073,
29889,
313,
4592,
995,
353,
7700,
29897,
13,
4706,
736,
29918,
27736,
584,
13,
9651,
736,
19138,
3368,
11916,
313,
12676,
29892,
2992,
29897,
297,
6124,
304,
14238,
963,
297,
421,
1311,
29889,
27736,
6522,
313,
4592,
995,
353,
5852,
29897,
13,
4706,
2099,
29918,
2671,
29918,
2536,
327,
584,
13,
9651,
1347,
29892,
607,
6694,
2847,
4371,
313,
12676,
29918,
2671,
21497,
29897,
304,
4559,
29973,
525,
2344,
29918,
29896,
29915,
491,
2322,
13,
13,
4706,
16969,
13,
4706,
448,
22158,
13,
4706,
9657,
13,
9651,
8600,
421,
1311,
29889,
27736,
29952,
313,
12676,
29892,
29871,
29945,
29995,
4323,
488,
29892,
8073,
29892,
2984,
635,
599,
11916,
29897,
411,
21503,
4314,
13,
9651,
411,
12655,
7049,
363,
1269,
3443,
29889,
13,
9651,
15113,
385,
13136,
8600,
297,
421,
1311,
29889,
27736,
29952,
411,
599,
11916,
310,
4128,
13,
9651,
408,
12655,
7049,
310,
8267,
4954,
29898,
29876,
29918,
27736,
29892,
2023,
3569,
29952,
13,
13,
4706,
9995,
13,
13,
4706,
278,
1562,
29889,
2917,
29889,
26017,
29918,
1688,
29918,
1767,
353,
525,
17281,
29915,
13,
13,
4706,
565,
2943,
1275,
525,
497,
2396,
13,
9651,
396,
21029,
599,
4128,
448,
1795,
671,
263,
3287,
310,
22796,
3370,
13,
9651,
1400,
29918,
27736,
353,
1583,
29889,
12676,
29918,
2671,
29961,
12676,
29918,
2671,
29918,
2536,
327,
1822,
11249,
29898,
29876,
29918,
27736,
29897,
13,
9651,
1583,
29889,
27736,
1839,
2490,
29918,
11249,
29918,
1004,
550,
2033,
353,
426,
29894,
29901,
1400,
29918,
27736,
29961,
29894,
1822,
12676,
29898,
8990,
29922,
29900,
29897,
363,
325,
297,
1400,
29918,
27736,
29889,
1707,
7039,
29913,
13,
9651,
1583,
29889,
27736,
1839,
2490,
29918,
11249,
29918,
29939,
29900,
29945,
2033,
353,
426,
29894,
29901,
7442,
29889,
12150,
488,
29898,
2490,
29918,
27736,
29961,
29894,
1402,
29871,
29900,
29889,
29900,
29945,
29892,
9685,
29922,
29900,
29897,
363,
325,
297,
13,
462,
462,
1669,
1400,
29918,
27736,
29889,
1707,
7039,
29913,
13,
9651,
1583,
29889,
27736,
1839,
2490,
29918,
11249,
29918,
29939,
29929,
29945,
2033,
353,
426,
29894,
29901,
7442,
29889,
12150,
488,
29898,
2490,
29918,
27736,
29961,
29894,
1402,
29871,
29900,
29889,
29929,
29945,
29892,
9685,
29922,
29900,
29897,
363,
325,
297,
13,
462,
462,
1669,
1400,
29918,
27736,
29889,
1707,
7039,
29913,
632,
13,
9651,
1583,
29889,
27736,
1839,
2490,
29918,
11249,
29918,
29939,
29900,
29896,
2033,
353,
426,
29894,
29901,
7442,
29889,
12150,
488,
29898,
2490,
29918,
27736,
29961,
29894,
1402,
29871,
29900,
29889,
29900,
29896,
29892,
9685,
29922,
29900,
29897,
363,
325,
297,
13,
462,
462,
1669,
1400,
29918,
27736,
29889,
1707,
7039,
29913,
13,
9651,
1583,
29889,
27736,
1839,
2490,
29918,
11249,
29918,
29939,
29929,
29929,
2033,
353,
426,
29894,
29901,
7442,
29889,
12150,
488,
29898,
2490,
29918,
27736,
29961,
29894,
1402,
29871,
29900,
29889,
29929,
29929,
29892,
9685,
29922,
29900,
29897,
363,
325,
297,
13,
462,
462,
1669,
1400,
29918,
27736,
29889,
1707,
7039,
29913,
13,
9651,
1583,
29889,
27736,
1839,
2490,
29918,
11249,
29918,
4928,
29879,
2033,
353,
426,
29894,
29901,
1400,
29918,
27736,
29961,
29894,
1822,
4172,
29898,
8990,
29922,
29900,
29897,
363,
325,
297,
1400,
29918,
27736,
29889,
1707,
7039,
29913,
13,
13,
9651,
565,
313,
7620,
29918,
27736,
1125,
13,
18884,
396,
3588,
1773,
277,
25525,
1203,
304,
263,
8600,
13,
18884,
1400,
29918,
27736,
353,
426,
29894,
29901,
1400,
29918,
27736,
29961,
29894,
29962,
363,
325,
297,
1400,
29918,
27736,
29889,
1707,
7039,
29913,
13,
18884,
1583,
29889,
27736,
1839,
2490,
29918,
27736,
2033,
353,
1400,
29918,
27736,
13,
13,
4706,
1683,
29901,
13,
9651,
396,
21029,
263,
1809,
29872,
2943,
13,
9651,
1400,
29918,
3177,
353,
1583,
29889,
12676,
29918,
2671,
29961,
12676,
29918,
2671,
29918,
2536,
327,
1822,
11249,
29918,
3177,
29898,
3177,
29892,
2159,
29922,
29876,
29918,
27736,
467,
14513,
580,
13,
9651,
1400,
29918,
3177,
29918,
12676,
353,
1400,
29918,
3177,
29889,
12676,
29898,
29900,
29897,
13,
9651,
1400,
29918,
3177,
29918,
29939,
29900,
29945,
353,
7442,
29889,
12150,
488,
29898,
2490,
29918,
3177,
29892,
29871,
29900,
29889,
29900,
29945,
29892,
9685,
29922,
29900,
29897,
13,
9651,
1400,
29918,
3177,
29918,
29939,
29929,
29945,
353,
7442,
29889,
12150,
488,
29898,
2490,
29918,
3177,
29892,
29871,
29900,
29889,
29929,
29945,
29892,
9685,
29922,
29900,
29897,
13,
9651,
1400,
29918,
3177,
29918,
29939,
29900,
29896,
353,
7442,
29889,
12150,
488,
29898,
2490,
29918,
3177,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
9685,
29922,
29900,
29897,
13,
9651,
1400,
29918,
3177,
29918,
29939,
29929,
29929,
353,
7442,
29889,
12150,
488,
29898,
2490,
29918,
3177,
29892,
29871,
29900,
29889,
29929,
29929,
29892,
9685,
29922,
29900,
29897,
13,
9651,
1400,
29918,
3177,
29918,
4928,
29879,
353,
1400,
29918,
3177,
29889,
4172,
29898,
29900,
29897,
13,
13,
9651,
396,
6597,
278,
1024,
310,
278,
2943,
322,
4078,
304,
11916,
8600,
13,
9651,
2943,
29918,
978,
353,
2943,
29889,
978,
13,
9651,
1583,
29889,
3177,
29918,
27736,
29961,
710,
29898,
3177,
29918,
978,
29897,
718,
22868,
12676,
2033,
353,
1400,
29918,
3177,
29918,
12676,
13,
9651,
1583,
29889,
3177,
29918,
27736,
29961,
710,
29898,
3177,
29918,
978,
29897,
718,
22868,
29939,
29900,
29945,
2033,
353,
1400,
29918,
3177,
29918,
29939,
29900,
29945,
13,
9651,
1583,
29889,
3177,
29918,
27736,
29961,
710,
29898,
3177,
29918,
978,
29897,
718,
22868,
29939,
29929,
29945,
2033,
353,
1400,
29918,
3177,
29918,
29939,
29929,
29945,
13,
9651,
1583,
29889,
3177,
29918,
27736,
29961,
710,
29898,
3177,
29918,
978,
29897,
718,
22868,
29939,
29900,
29896,
2033,
353,
1400,
29918,
3177,
29918,
29939,
29900,
29896,
13,
9651,
1583,
29889,
3177,
29918,
27736,
29961,
710,
29898,
3177,
29918,
978,
29897,
718,
22868,
29939,
29929,
29929,
2033,
353,
1400,
29918,
3177,
29918,
29939,
29929,
29929,
13,
9651,
1583,
29889,
3177,
29918,
27736,
29961,
710,
29898,
3177,
29918,
978,
29897,
718,
22868,
4928,
29879,
2033,
353,
1400,
29918,
3177,
29918,
4928,
29879,
13,
13,
9651,
565,
4078,
29918,
27736,
29901,
13,
18884,
1583,
29889,
3177,
29918,
27736,
29961,
710,
29898,
3177,
29918,
978,
29897,
718,
22868,
2490,
29918,
27736,
2033,
353,
1400,
29918,
3177,
13,
13,
4706,
565,
736,
29918,
27736,
29901,
13,
9651,
736,
1583,
29889,
27736,
13,
2
] |
ml/sandbox/00-data.py | robk-dev/algo-trading | 1 | 2172 | from alpha_vantage.timeseries import TimeSeries
from pprint import pprint
import json
import argparse
def save_dataset(symbol='MSFT', time_window='daily_adj'):
credentials = json.load(open('creds.json', 'r'))
api_key = credentials['av_api_key']
print(symbol, time_window)
ts = TimeSeries(key=api_key, output_format='pandas')
if time_window == 'intraday':
data, meta_data = ts.get_intraday(
symbol=symbol, interval='1min', outputsize='full')
elif time_window == 'daily':
data, meta_data = ts.get_daily(symbol, outputsize='full')
elif time_window == 'daily_adj':
data, meta_data = ts.get_daily_adjusted(symbol, outputsize='full')
pprint(data.head(10))
data.to_csv(f'./{symbol}_{time_window}.csv')
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('symbol', type=str, help="the stock symbol you want to download")
parser.add_argument('time_window', type=str, choices=[
'intraday', 'daily', 'daily_adj'], help="the time period you want to download the stock history for")
namespace = parser.parse_args()
save_dataset(**vars(namespace))
| [
1,
515,
15595,
29918,
29894,
8501,
29889,
3706,
6358,
1053,
5974,
19204,
13,
3166,
282,
2158,
1053,
282,
2158,
13,
5215,
4390,
13,
5215,
1852,
5510,
13,
13,
13,
1753,
4078,
29918,
24713,
29898,
18098,
2433,
4345,
7818,
742,
931,
29918,
7165,
2433,
29881,
8683,
29918,
26859,
29374,
13,
1678,
16140,
353,
4390,
29889,
1359,
29898,
3150,
877,
1037,
6289,
29889,
3126,
742,
525,
29878,
8785,
13,
1678,
7882,
29918,
1989,
353,
16140,
1839,
485,
29918,
2754,
29918,
1989,
2033,
13,
1678,
1596,
29898,
18098,
29892,
931,
29918,
7165,
29897,
13,
1678,
18696,
353,
5974,
19204,
29898,
1989,
29922,
2754,
29918,
1989,
29892,
1962,
29918,
4830,
2433,
15112,
1495,
13,
1678,
565,
931,
29918,
7165,
1275,
525,
262,
29576,
388,
2396,
13,
4706,
848,
29892,
12700,
29918,
1272,
353,
18696,
29889,
657,
29918,
262,
29576,
388,
29898,
13,
9651,
5829,
29922,
18098,
29892,
7292,
2433,
29896,
1195,
742,
1962,
2311,
2433,
8159,
1495,
13,
1678,
25342,
931,
29918,
7165,
1275,
525,
29881,
8683,
2396,
13,
4706,
848,
29892,
12700,
29918,
1272,
353,
18696,
29889,
657,
29918,
29881,
8683,
29898,
18098,
29892,
1962,
2311,
2433,
8159,
1495,
13,
1678,
25342,
931,
29918,
7165,
1275,
525,
29881,
8683,
29918,
26859,
2396,
13,
4706,
848,
29892,
12700,
29918,
1272,
353,
18696,
29889,
657,
29918,
29881,
8683,
29918,
328,
5143,
287,
29898,
18098,
29892,
1962,
2311,
2433,
8159,
1495,
13,
13,
1678,
282,
2158,
29898,
1272,
29889,
2813,
29898,
29896,
29900,
876,
13,
13,
1678,
848,
29889,
517,
29918,
7638,
29898,
29888,
4286,
19248,
18098,
3227,
2230,
29918,
7165,
1836,
7638,
1495,
13,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
13812,
353,
1852,
5510,
29889,
15730,
11726,
580,
13,
13,
1678,
13812,
29889,
1202,
29918,
23516,
877,
18098,
742,
1134,
29922,
710,
29892,
1371,
543,
1552,
10961,
5829,
366,
864,
304,
5142,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
877,
2230,
29918,
7165,
742,
1134,
29922,
710,
29892,
19995,
11759,
13,
462,
4706,
525,
262,
29576,
388,
742,
525,
29881,
8683,
742,
525,
29881,
8683,
29918,
26859,
7464,
1371,
543,
1552,
931,
3785,
366,
864,
304,
5142,
278,
10961,
4955,
363,
1159,
13,
13,
1678,
7397,
353,
13812,
29889,
5510,
29918,
5085,
580,
13,
1678,
4078,
29918,
24713,
29898,
1068,
16908,
29898,
22377,
876,
13,
2
] |
demo_bgl/time_based_mining_invariants.py | elieser1101/loglizer | 0 | 156893 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
__author__ = '<NAME>'
from utils import data_loader as data_loader
from models import mining_invariants as mi
para = {
'path':'../../Data/BGL_data/', # directory for input data
'log_file_name':'BGL_MERGED.log', # filename for log data file
'log_event_mapping':'logTemplateMap.csv', # filename for log-event mapping. A list of event index, where each row represents a log
'save_path': '../time_windows/', # dir for saving sliding window data files to avoid splitting
'select_column':[0,4], # select the corresponding columns (label and time) in the raw log file
'window_size':3, # time window (unit: hour)
'step_size': 1, # step size (unit: hour)
'epsilon':2.0, # threshold for the step of estimating invariant space
'threshold':0.98, # percentage of vector Xj in matrix satisfies the condition that |Xj*Vi|<epsilon
'scale_list':[1,2,3], # list used to sacle the theta of float into integer
'stop_invar_num':3 # stop if the invariant length is larger than stop_invar_num. None if not given
}
if __name__ == '__main__':
raw_data, event_mapping_data = data_loader.deepia_data_loader(para)
event_count_matrix = data_loader.deepia_preprocess_data(para, raw_data, event_mapping_data)
r = mi.estimate_invar_spce(para, event_count_matrix)
invar_dict = mi.invariant_search(para, event_count_matrix, r)
predictions = mi.deepia_evaluate(event_count_matrix, invar_dict) | [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
29937,
448,
29930,
29899,
14137,
29901,
18351,
29899,
29947,
448,
29930,
29899,
13,
1649,
8921,
1649,
353,
12801,
5813,
16299,
13,
13,
3166,
3667,
29879,
1053,
848,
29918,
12657,
408,
848,
29918,
12657,
13,
3166,
4733,
1053,
1375,
292,
29918,
262,
5927,
1934,
408,
3737,
13,
13,
22752,
353,
426,
13,
29915,
2084,
22099,
21546,
1469,
29914,
29933,
7239,
29918,
1272,
29914,
742,
462,
396,
3884,
363,
1881,
848,
13,
29915,
1188,
29918,
1445,
29918,
978,
22099,
29933,
7239,
29918,
29924,
1001,
1692,
29928,
29889,
1188,
742,
965,
396,
10422,
363,
1480,
848,
934,
13,
29915,
1188,
29918,
3696,
29918,
20698,
22099,
1188,
6733,
3388,
29889,
7638,
742,
259,
396,
10422,
363,
1480,
29899,
3696,
10417,
29889,
319,
1051,
310,
1741,
2380,
29892,
988,
1269,
1948,
11524,
263,
1480,
13,
29915,
7620,
29918,
2084,
2396,
525,
6995,
2230,
29918,
10499,
29914,
742,
632,
396,
4516,
363,
14238,
2243,
4821,
3474,
848,
2066,
304,
4772,
24368,
13,
29915,
2622,
29918,
4914,
2396,
29961,
29900,
29892,
29946,
1402,
462,
418,
396,
1831,
278,
6590,
4341,
313,
1643,
322,
931,
29897,
297,
278,
10650,
1480,
934,
13,
29915,
7165,
29918,
2311,
2396,
29941,
29892,
462,
9651,
396,
931,
3474,
313,
5441,
29901,
7234,
29897,
13,
29915,
10568,
29918,
2311,
2396,
29871,
29896,
29892,
462,
632,
396,
4331,
2159,
313,
5441,
29901,
7234,
29897,
13,
29915,
5463,
2396,
29906,
29889,
29900,
29892,
462,
795,
396,
16897,
363,
278,
4331,
310,
4844,
1218,
22619,
2913,
13,
29915,
386,
12268,
2396,
29900,
29889,
29929,
29947,
29892,
462,
965,
396,
19649,
310,
4608,
1060,
29926,
297,
4636,
17150,
278,
4195,
393,
891,
29990,
29926,
29930,
29963,
29875,
29989,
29966,
5463,
13,
29915,
7052,
29918,
1761,
2396,
29961,
29896,
29892,
29906,
29892,
29941,
1402,
12,
12,
12,
12,
12,
1678,
396,
1051,
1304,
304,
269,
6436,
278,
278,
941,
310,
5785,
964,
6043,
13,
29915,
9847,
29918,
262,
1707,
29918,
1949,
2396,
29941,
462,
3986,
396,
5040,
565,
278,
22619,
3309,
338,
7200,
1135,
5040,
29918,
262,
1707,
29918,
1949,
29889,
6213,
565,
451,
2183,
13,
29913,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
12,
1610,
29918,
1272,
29892,
1741,
29918,
20698,
29918,
1272,
353,
848,
29918,
12657,
29889,
24535,
423,
29918,
1272,
29918,
12657,
29898,
22752,
29897,
13,
12,
3696,
29918,
2798,
29918,
5344,
353,
848,
29918,
12657,
29889,
24535,
423,
29918,
1457,
5014,
29918,
1272,
29898,
22752,
29892,
10650,
29918,
1272,
29892,
1741,
29918,
20698,
29918,
1272,
29897,
13,
12,
29878,
353,
3737,
29889,
342,
6490,
29918,
262,
1707,
29918,
1028,
346,
29898,
22752,
29892,
1741,
29918,
2798,
29918,
5344,
29897,
13,
12,
262,
1707,
29918,
8977,
353,
3737,
29889,
262,
19365,
29918,
4478,
29898,
22752,
29892,
1741,
29918,
2798,
29918,
5344,
29892,
364,
29897,
13,
12,
27711,
1080,
353,
3737,
29889,
24535,
423,
29918,
24219,
403,
29898,
3696,
29918,
2798,
29918,
5344,
29892,
297,
1707,
29918,
8977,
29897,
2
] |
project1/budget/admin.py | sujeethiremath/Project-1 | 0 | 1609350 | from django.contrib import admin
from budget.models import Budget,BudgetCategory
# Register your models here.
admin.site.register(Budget)
admin.site.register(BudgetCategory)
| [
1,
515,
9557,
29889,
21570,
1053,
4113,
13,
3166,
23562,
29889,
9794,
1053,
7038,
657,
29892,
29933,
566,
657,
10900,
13,
13,
29937,
12577,
596,
4733,
1244,
29889,
13,
6406,
29889,
2746,
29889,
9573,
29898,
29933,
566,
657,
29897,
13,
6406,
29889,
2746,
29889,
9573,
29898,
29933,
566,
657,
10900,
29897,
13,
13,
2
] |
lang/python/pptv_strip.py | liuyang1/test | 8 | 24786 | import sys
fn = sys.argv[1]
fp = open(fn)
fo = open(fn+".flv","wb")
data = fp.read()
offset = int(sys.argv[2])
if len(sys.argv)==3:
fo.write(data[offset:])
else:
l = int(sys.argsv[3])
fo.write(data[offset:offset+l])
fo.close()
fp.close()
| [
1,
1053,
10876,
13,
9144,
353,
10876,
29889,
19218,
29961,
29896,
29962,
13,
18091,
353,
1722,
29898,
9144,
29897,
13,
1181,
353,
1722,
29898,
9144,
29974,
1642,
1579,
29894,
3284,
29893,
29890,
1159,
13,
1272,
353,
285,
29886,
29889,
949,
580,
13,
10289,
353,
938,
29898,
9675,
29889,
19218,
29961,
29906,
2314,
13,
361,
7431,
29898,
9675,
29889,
19218,
29897,
1360,
29941,
29901,
13,
1678,
1701,
29889,
3539,
29898,
1272,
29961,
10289,
29901,
2314,
13,
2870,
29901,
13,
1678,
301,
353,
938,
29898,
9675,
29889,
1191,
4501,
29961,
29941,
2314,
13,
1678,
1701,
29889,
3539,
29898,
1272,
29961,
10289,
29901,
10289,
29974,
29880,
2314,
13,
1181,
29889,
5358,
580,
13,
18091,
29889,
5358,
580,
13,
2
] |
setup.py | sibyjackgrove/gym-SolarPVDER-environment | 7 | 169503 | from setuptools import setup
setup(name='gym_PVDER',
version='0.0.1',
install_requires=['gym','scipy','numpy','matplotlib']#And any other dependencies required
)
| [
1,
515,
731,
21245,
8789,
1053,
6230,
13,
13,
14669,
29898,
978,
2433,
29887,
962,
29918,
29925,
29963,
8032,
742,
13,
418,
1873,
2433,
29900,
29889,
29900,
29889,
29896,
742,
13,
418,
2601,
29918,
276,
339,
2658,
29922,
1839,
29887,
962,
3788,
26167,
2272,
3788,
23749,
3788,
2922,
17357,
2033,
29937,
2855,
738,
916,
9962,
3734,
13,
29897,
13,
2
] |
projects/jist/jist/datasets/generate2Ddataset.py | Cryptum169/gpmp2 | 0 | 148086 | <reponame>Cryptum169/gpmp2<filename>projects/jist/jist/datasets/generate2Ddataset.py
import numpy as np
from gtsam import *
from gpmp2 import *
import math
from random import Random
dataset_random = Random()
class Obstacle:
"""docstring for Dataset"""
def __init__(self):
self.x = None
self.y = None
self.v_x = None
self.v_y = None
self.a_x = None
self.a_y = None
self.size = None
class Dataset:
"""docstring for Dataset"""
def __init__(self):
self.cols = None
self.rows = None
self.origin_x = None
self.origin_y = None
self.cell_size = None
self.map = None
def random_number(min_val, max_val):
return min_val + (max_val - min_val) * dataset_random.random()
def get_center(x, y, dataset):
center = (
np.asarray([y - dataset.origin_y, x - dataset.origin_x]) / dataset.cell_size
)
return center.astype(int)
def get_dim(w, h, dataset):
return np.asarray([h, w]) / dataset.cell_size
def add_obstacle(
position, size, map, landmarks=None, origin_x=None, origin_y=None, cell_size=None
):
half_size_row = int(math.floor((size[0] - 1) / 2))
half_size_col = int(math.floor((size[1] - 1) / 2))
# occupency grid. here map is assumed to be numpy array
temp = map[
max(0, position[0] - half_size_row - 1) : min(map.shape[0],position[0] + half_size_row),
max(0, position[1] - half_size_col - 1) : min(map.shape[1],position[1] + half_size_col),
]
map[
max(0, position[0] - half_size_row - 1) :min(map.shape[0], position[0] + half_size_row),
max(0, position[1] - half_size_col - 1) :min(map.shape[1], position[1] + half_size_col),
] = np.ones(temp.shape)
# landmarks
if landmarks is not None and origin_x is not None and origin_y is not None:
raise NotImplementedError
return map
def generate2Ddataset(dataset_str):
# GENERATE2DDATASET Generate 2D dataset evidence grid
#
# Usage: dataset = GENERATE2DDATASET(dataset_str)
# @dataset_str dataset string, existing datasets:
# 'OneObstacleDataset', 'TwoObstaclesDataset'
#
# Output Format:
# dataset.map ground truth evidence grid
# dataset.rows number of rows (y)
# dataset.cols number of cols (x)
# dataset.origin_x origin of map x
# dataset.origin_y origin of map y
# dataset.cell_size cell size
dataset = Dataset()
# dataset 5: 1 obs dataset for 2D Arm obs avoid
if dataset_str is "OneObstacleDataset":
# params
dataset.cols = 300
dataset.rows = 300
dataset.origin_x = -1
dataset.origin_y = -1
dataset.cell_size = 0.01
# map
dataset.map = np.zeros((dataset.rows, dataset.cols))
# obstacles
dataset.map = add_obstacle([190, 160], [60, 80], dataset.map)
# dataset 6: obs dataset for 3D Arm obs avoid
elif dataset_str is "Empty":
# params
dataset.cols = 300
dataset.rows = 300
dataset.origin_x = -1
dataset.origin_y = -1
dataset.cell_size = 0.01
# map
dataset.map = np.zeros((dataset.rows, dataset.cols))
# obstacles
# dataset.map = add_obstacle([200, 200], [80, 100], dataset.map)
# dataset.map = add_obstacle([160, 80], [30, 80], dataset.map)
elif dataset_str is "TwoObstaclesDataset":
# params
dataset.cols = 300
dataset.rows = 300
dataset.origin_x = -1
dataset.origin_y = -1
dataset.cell_size = 0.01
# map
dataset.map = np.zeros((dataset.rows, dataset.cols))
# obstacles
dataset.map = add_obstacle([200, 200], [80, 100], dataset.map)
dataset.map = add_obstacle([160, 80], [30, 80], dataset.map)
# dataset 7: multiple obs dataset for 2D Arm obs avoid
elif dataset_str is "MultiObstacleDataset":
# params
dataset.cols = 400 # x
dataset.rows = 300 # y
dataset.origin_x = -20
dataset.origin_y = -10
dataset.cell_size = 0.1
# map
dataset.map = np.zeros((dataset.rows, dataset.cols))
# obstacles
dataset.map = add_obstacle(
get_center(12, 10, dataset), get_dim(5, 7, dataset), dataset.map
)
dataset.map = add_obstacle(
get_center(-7, 10, dataset), get_dim(10, 7, dataset), dataset.map
)
dataset.map = add_obstacle(
get_center(0, -5, dataset), get_dim(10, 5, dataset), dataset.map
)
# mobile 2d map
elif dataset_str is "MobileMap1":
# params
dataset.cols = 500 # x
dataset.rows = 500 # y
dataset.origin_x = -10
dataset.origin_y = -10
dataset.cell_size = 0.01
# map
dataset.map = np.zeros((dataset.rows, dataset.cols))
# obstacles
dataset.map = add_obstacle(
get_center(0, 0, dataset), get_dim(1, 5, dataset), dataset.map
)
# dataset.map = add_obstacle(get_center(-2.5,-2,dataset), get_dim(5,1,dataset), dataset.map);
# wall
dataset.map = add_obstacle(
get_center(0, 4.5, dataset), get_dim(10, 1, dataset), dataset.map
)
dataset.map = add_obstacle(
get_center(0, -4.5, dataset), get_dim(10, 1, dataset), dataset.map
)
dataset.map = add_obstacle(
get_center(4.5, 0, dataset), get_dim(1, 10, dataset), dataset.map
)
dataset.map = add_obstacle(
get_center(-4.5, 0, dataset), get_dim(1, 10, dataset), dataset.map
)
# no such dataset
else:
raise NameError("No such dataset exist")
return dataset
class Patrol2Ddataset(object):
# keep track of objets, and their velocity.
# add big boundary stationary walls on all 4 sides.
# randomly intialize objets of same size at different x, y
# set random velocity magnitudes and directions for each objects
# simulate / move by dt time.
# if y is less than bottow or y is > top vy *= -1
# if x is less than left or x is > right vx *= -1
def __init__(
self,
rows=400,
cols=200, # rows corresponds to y
origin_x=0.0,
origin_y=0.0,
cell_size=0.1,
):
self.dataset = Dataset()
self.dataset.cols = cols
self.dataset.rows = rows
self.dataset.origin_x = origin_x
self.dataset.origin_y = origin_y
self.dataset.cell_size = cell_size
# map
self.static_obstacles = []
self.dynamic_obstacles = []
# left, right, bottom, up
self.bounds = [
origin_x,
origin_x + cell_size * cols,
origin_y,
origin_y + cell_size * rows,
]
def init_obstacles(self, seed_val=None, obstacle_num=100, vel_limit=0.8, acc_limit=None,):
if seed_val is None:
seed_val = 0
dataset_random.seed(seed_val)
# make static obstacles
self.static_obstacles.append(
self.make_obstacle(10.0, 15.0, np.asarray([1.0, 3.0]))
)
self.static_obstacles.append(self.make_obstacle(3.0, 20.0, np.asarray([4, 40])))
self.static_obstacles.append(
self.make_obstacle(17.0, 20.0, np.asarray([4, 40]))
)
# make dynamic obstacles
self.dynamic_bounds = np.asarray(self.bounds)
self.dynamic_bounds[0] = 8.0
self.dynamic_bounds[1] = 12.0
self.dynamic_obstacles.append(
self.make_obstacle(
random_number(self.dynamic_bounds[0], self.dynamic_bounds[1]),
10,
np.asarray([5.0, 3.0]),
)
)
self.dynamic_obstacles[0].v_y = 0.0
self.dynamic_obstacles[0].v_x = vel_limit# * (2.0/3.0)
if obstacle_num == 2:
self.dynamic_obstacles.append(
self.make_obstacle(
random_number(self.dynamic_bounds[0], self.dynamic_bounds[1]),
25,
np.asarray([5.0, 3.0]),
)
)
self.dynamic_obstacles[1].v_y = 0.0
self.dynamic_obstacles[1].v_x = vel_limit
self.static_obstacles.append(
self.make_obstacle(10.0, 30.0, np.asarray([1.0, 3.0]))
)
self.obstacles = self.static_obstacles + self.dynamic_obstacles
def make_obstacle(self, x, y, size):
obs = Obstacle()
obs.x = x
obs.y = y
obs.size = size
return obs
def simulate(self, dt):
for obs in self.dynamic_obstacles:
obs.x += dt * obs.v_x
obs.y += dt * obs.v_y
# change velocities
if obs.x <= self.dynamic_bounds[0] or obs.x >= self.dynamic_bounds[1]:
obs.v_x *= -1
if obs.y <= self.dynamic_bounds[2] or obs.y >= self.dynamic_bounds[3]:
obs.v_y *= -1
def get_dataset(self, pose=None, map_size=None): # size in meters
self.dataset.map = np.zeros((self.dataset.rows, self.dataset.cols))
for obs in self.static_obstacles:
self.dataset.map = add_obstacle(
get_center(obs.x, obs.y, self.dataset),
get_dim(obs.size[0], obs.size[1], self.dataset),
self.dataset.map,
)
for obs in self.dynamic_obstacles:
self.dataset.map = add_obstacle(
get_center(obs.x, obs.y, self.dataset),
get_dim(obs.size[0], obs.size[1], self.dataset),
self.dataset.map,
)
if pose is None or map_size is None:
return self.dataset
temp_dataset = Dataset()
temp_dataset.origin_x = pose[0] - float(map_size[0]) / 2.0
temp_dataset.origin_y = pose[1] - float(map_size[1]) / 2.0
temp_dataset.cell_size = self.dataset.cell_size
lower_left = get_center(
temp_dataset.origin_x, temp_dataset.origin_y, self.dataset
)
if lower_left[0] < 0:
lower_left[0] = 0
temp_dataset.origin_y = self.dataset.origin_y
if lower_left[1] < 0:
lower_left[1] = 0
temp_dataset.origin_x = self.dataset.origin_x
upper_right = get_center(
pose[0] + float(map_size[0]) / 2.0,
pose[1] + float(map_size[1]) / 2.0,
self.dataset,
)
if upper_right[0] >= self.dataset.map.shape[0]:
upper_right[0] = self.dataset.map.shape[0] - 1
if upper_right[1] >= self.dataset.map.shape[1]:
upper_right[1] = self.dataset.map.shape[1] - 1
if (
upper_right[0] < 0
or upper_right[1] < 0
or lower_left[0] >= self.dataset.map.shape[0]
or lower_left[1] >= self.dataset.map.shape[1]
):
temp_dataset.map = np.zeros((5, 5)) # some map of zeros
else:
temp_dataset.map = self.dataset.map[
lower_left[0] : upper_right[0] + 1, lower_left[1] : upper_right[1] + 1
]
temp_dataset.rows = temp_dataset.map.shape[0]
temp_dataset.cols = temp_dataset.map.shape[1]
return temp_dataset
class Dynamic2Ddataset(object):
# keep track of objets, and their velocity.
# add big boundary stationary walls on all 4 sides.
# randomly intialize objets of same size at different x, y
# set random velocity magnitudes and directions for each objects
# simulate / move by dt time.
# if y is less than bottow or y is > top vy *= -1
# if x is less than left or x is > right vx *= -1
def __init__(
self,
rows=900,
cols=1200,
origin_x=0.0,
origin_y=0.0,
cell_size=0.1,
):
self.dataset = Dataset()
self.dataset.cols = cols
self.dataset.rows = rows
self.dataset.origin_x = origin_x
self.dataset.origin_y = origin_y
self.dataset.cell_size = cell_size
# map
self.obstacles = []
# left, right, bottom, up
self.bounds = [
origin_x,
origin_x + cell_size * cols,
origin_y,
origin_y + cell_size * rows,
]
self.obs_size = (self.bounds[1] - self.bounds[0]) / 20.0
self.obs_dist = 10.0
self.goal = None
self.start = None
self.uniform_grid = False
def init_obstacles(self, seed_val=None, obstacle_num=100, vel_limit=None, acc_limit=None,
start=None, goal=None):
if obstacle_num == -1:
self.uniform_grid = True
x = self.bounds[0]
while x < self. bounds[1]:
y = self.bounds[2]
while y < self.bounds[3]:
obs = Obstacle()
obs.x = x
obs.y = y
obs.size = np.asarray([self.obs_size, self.obs_size])
y += 15.0
if goal is not None:
if np.linalg.norm(np.array([obs.x-goal[0], obs.y-goal[1]])) < self.obs_dist:
continue
if start is not None:
if np.linalg.norm(np.array([obs.x-start[0], obs.y-start[1]])) < self.obs_dist:
continue
self.obstacles.append(obs)
x += 15.0
return
if start is not None:
self.start = start
if goal is not None:
self.goal = goal
if seed_val is None:
seed_val = 0
dataset_random.seed(seed_val)
if vel_limit is None:
vel_limit = self.obs_size / 6
self.obs_velocity = vel_limit
if acc_limit is None:
acc_limit = self.obs_size / 10
self.obs_acc = acc_limit
# change in acceleration with time
self.acc_dt = self.obs_acc / 10
while len(self.obstacles) < obstacle_num:
# choose random x,y for obstacles.
obs = Obstacle()
obs.x = random_number(self.bounds[0], self.bounds[1])
obs.y = random_number(self.bounds[2], self.bounds[3])
if goal is not None:
if np.linalg.norm(np.array([obs.x-goal[0], obs.y-goal[1]])) < self.obs_dist:
continue
if start is not None:
if np.linalg.norm(np.array([obs.x-start[0], obs.y-start[1]])) < self.obs_dist:
continue
obs.v_x = random_number(-1 * self.obs_velocity, self.obs_velocity)
obs.v_y = random_number(-1 * self.obs_velocity, self.obs_velocity)
obs.a_x = random_number(-1 * self.obs_acc, self.obs_acc)
obs.a_y = random_number(-1 * self.obs_acc, self.obs_acc)
obs.size = np.asarray([self.obs_size, self.obs_size])
self.obstacles.append(obs)
# print('bounds', self.bounds, self.obs_size)
def simulate(self, dt):
if self.uniform_grid:
return
for obs in self.obstacles:
# Set accelerations
if random_number(0.0, 1.0) > 0.5:
obs.a_x += self.acc_dt
else:
obs.a_x -= self.acc_dt
obs.a_x = min(obs.a_x, self.obs_acc)
obs.a_x = max(obs.a_x, -1 * self.obs_acc)
if random_number(0.0, 1.0) > 0.5:
obs.a_y += self.acc_dt
else:
obs.a_y -= self.acc_dt
obs.a_y = min(obs.a_y, self.obs_acc)
obs.a_y = max(obs.a_y, -1 * self.obs_acc)
obs.v_x += dt * obs.a_x
obs.v_y += dt * obs.a_y
obs.v_x = min(obs.v_x, self.obs_velocity)
obs.v_x = max(obs.v_x, -1 * self.obs_velocity)
obs.v_y = min(obs.v_y, self.obs_velocity)
obs.v_y = max(obs.v_y, -1 * self.obs_velocity)
obs.x += dt * obs.v_x
obs.y += dt * obs.v_y
if self.goal is not None:
if np.linalg.norm(np.array([obs.x-self.goal[0], obs.y-self.goal[1]])) < self.obs_dist:
# bounce off the circle around goal
v1 = np.array([obs.x-self.goal[0], obs.y-self.goal[1]])
v1 = v1/np.linalg.norm(v1)
v2 = -1 * np.array([obs.v_x, obs.v_y])
v2 = v2/np.linalg.norm(v2)
theta = math.acos(np.linalg.norm( np.dot(v1, v2)))
alpha = math.atan2(obs.v_y, obs.v_x)
beta = math.atan2(obs.y - self.goal[1], obs.x - self.goal[0])
vel_vect = np.array([obs.v_x, obs.v_y])
angle = beta - alpha - theta
rot_mat = np.array([[math.cos(angle), -1* math.sin(angle)], [ math.sin(angle), math.cos(angle)]])
new_vels = np.matmul(np.asarray([obs.v_x, obs.v_y]) , rot_mat.T)
obs.v_x = new_vels[0]
obs.v_y = new_vels[1]
if self.start is not None:
if np.linalg.norm(np.array([obs.x-self.start[0], obs.y-self.start[1]])) < self.obs_dist:
# bounce off the circle around start
v1 = np.array([obs.x-self.start[0], obs.y-self.start[1]])
v1 = v1/np.linalg.norm(v1)
v2 = -1 * np.array([obs.v_x, obs.v_y])
v2 = v2/np.linalg.norm(v2)
theta = math.acos(np.linalg.norm( np.dot(v1, v2)))
alpha = math.atan2(obs.v_y, obs.v_x)
beta = math.atan2(obs.y - self.start[1], obs.x - self.start[0])
vel_vect = np.array([obs.v_x, obs.v_y])
angle = beta - alpha - theta
rot_mat = np.array([[math.cos(angle), -1* math.sin(angle)], [ math.sin(angle), math.cos(angle)]])
new_vels = np.matmul(np.asarray([obs.v_x, obs.v_y]) , rot_mat.T)
obs.v_x = new_vels[0]
obs.v_y = new_vels[1]
# change velocities
if obs.x <= self.bounds[0] or obs.x >= self.bounds[1]:
obs.v_x *= -1
if obs.y <= self.bounds[2] or obs.y >= self.bounds[3]:
obs.v_y *= -1
def get_dataset(self, pose=None, map_size=None): # size in meters
self.dataset.map = np.zeros((self.dataset.rows, self.dataset.cols))
for obs in self.obstacles:
self.dataset.map = add_obstacle(
get_center(obs.x, obs.y, self.dataset),
get_dim(obs.size[0], obs.size[1], self.dataset),
self.dataset.map,
)
if pose is None or map_size is None:
return self.dataset
temp_dataset = Dataset()
temp_dataset.origin_x = pose[0] - float(map_size[0]) / 2.0
temp_dataset.origin_y = pose[1] - float(map_size[1]) / 2.0
temp_dataset.cell_size = self.dataset.cell_size
lower_left = get_center(
temp_dataset.origin_x, temp_dataset.origin_y, self.dataset
)
if lower_left[0] < 0:
lower_left[0] = 0
temp_dataset.origin_y = self.dataset.origin_y
if lower_left[1] < 0:
lower_left[1] = 0
temp_dataset.origin_x = self.dataset.origin_x
upper_right = get_center(
pose[0] + float(map_size[0]) / 2.0,
pose[1] + float(map_size[1]) / 2.0,
self.dataset,
)
if upper_right[0] >= self.dataset.map.shape[0]:
upper_right[0] = self.dataset.map.shape[0] - 1
if upper_right[1] >= self.dataset.map.shape[1]:
upper_right[1] = self.dataset.map.shape[1] - 1
if (
upper_right[0] < 0
or upper_right[1] < 0
or lower_left[0] >= self.dataset.map.shape[0]
or lower_left[1] >= self.dataset.map.shape[1]
):
temp_dataset.map = np.zeros((5, 5)) # some map of zeros
else:
temp_dataset.map = self.dataset.map[
lower_left[0] : upper_right[0] + 1, lower_left[1] : upper_right[1] + 1
]
temp_dataset.rows = temp_dataset.map.shape[0]
temp_dataset.cols = temp_dataset.map.shape[1]
return temp_dataset
| [
1,
529,
276,
1112,
420,
29958,
29907,
4641,
398,
29896,
29953,
29929,
29914,
29887,
29886,
1526,
29906,
29966,
9507,
29958,
16418,
29914,
29926,
391,
29914,
29926,
391,
29914,
14538,
1691,
29914,
17158,
29906,
29928,
24713,
29889,
2272,
13,
5215,
12655,
408,
7442,
13,
3166,
330,
1372,
314,
1053,
334,
13,
3166,
330,
29886,
1526,
29906,
1053,
334,
13,
5215,
5844,
13,
3166,
4036,
1053,
16968,
13,
13,
13,
24713,
29918,
8172,
353,
16968,
580,
13,
13,
13,
1990,
4250,
303,
6436,
29901,
13,
1678,
9995,
1514,
1807,
363,
13373,
24541,
15945,
29908,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
29916,
353,
6213,
13,
4706,
1583,
29889,
29891,
353,
6213,
13,
4706,
1583,
29889,
29894,
29918,
29916,
353,
6213,
13,
4706,
1583,
29889,
29894,
29918,
29891,
353,
6213,
13,
4706,
1583,
29889,
29874,
29918,
29916,
353,
6213,
13,
4706,
1583,
29889,
29874,
29918,
29891,
353,
6213,
13,
4706,
1583,
29889,
2311,
353,
6213,
13,
13,
13,
1990,
13373,
24541,
29901,
13,
1678,
9995,
1514,
1807,
363,
13373,
24541,
15945,
29908,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
22724,
353,
6213,
13,
4706,
1583,
29889,
5727,
353,
6213,
13,
4706,
1583,
29889,
12574,
29918,
29916,
353,
6213,
13,
4706,
1583,
29889,
12574,
29918,
29891,
353,
6213,
13,
4706,
1583,
29889,
3729,
29918,
2311,
353,
6213,
13,
4706,
1583,
29889,
1958,
353,
6213,
13,
13,
13,
1753,
4036,
29918,
4537,
29898,
1195,
29918,
791,
29892,
4236,
29918,
791,
1125,
13,
1678,
736,
1375,
29918,
791,
718,
313,
3317,
29918,
791,
448,
1375,
29918,
791,
29897,
334,
8783,
29918,
8172,
29889,
8172,
580,
13,
13,
13,
1753,
679,
29918,
5064,
29898,
29916,
29892,
343,
29892,
8783,
1125,
13,
13,
1678,
4818,
353,
313,
13,
4706,
7442,
29889,
294,
2378,
4197,
29891,
448,
8783,
29889,
12574,
29918,
29891,
29892,
921,
448,
8783,
29889,
12574,
29918,
29916,
2314,
847,
8783,
29889,
3729,
29918,
2311,
13,
1678,
1723,
13,
1678,
736,
4818,
29889,
579,
668,
29898,
524,
29897,
13,
13,
13,
1753,
679,
29918,
6229,
29898,
29893,
29892,
298,
29892,
8783,
1125,
13,
13,
1678,
736,
7442,
29889,
294,
2378,
4197,
29882,
29892,
281,
2314,
847,
8783,
29889,
3729,
29918,
2311,
13,
13,
13,
1753,
788,
29918,
711,
303,
6436,
29898,
13,
1678,
2602,
29892,
2159,
29892,
2910,
29892,
2982,
22848,
29922,
8516,
29892,
3978,
29918,
29916,
29922,
8516,
29892,
3978,
29918,
29891,
29922,
8516,
29892,
3038,
29918,
2311,
29922,
8516,
13,
1125,
13,
13,
1678,
4203,
29918,
2311,
29918,
798,
353,
938,
29898,
755,
29889,
14939,
3552,
2311,
29961,
29900,
29962,
448,
29871,
29896,
29897,
847,
29871,
29906,
876,
13,
1678,
4203,
29918,
2311,
29918,
1054,
353,
938,
29898,
755,
29889,
14939,
3552,
2311,
29961,
29896,
29962,
448,
29871,
29896,
29897,
847,
29871,
29906,
876,
13,
13,
1678,
396,
6919,
3819,
6856,
29889,
1244,
2910,
338,
12023,
304,
367,
12655,
1409,
13,
13,
1678,
5694,
353,
2910,
29961,
13,
4706,
4236,
29898,
29900,
29892,
2602,
29961,
29900,
29962,
448,
4203,
29918,
2311,
29918,
798,
448,
29871,
29896,
29897,
584,
1375,
29898,
1958,
29889,
12181,
29961,
29900,
1402,
3283,
29961,
29900,
29962,
718,
4203,
29918,
2311,
29918,
798,
511,
13,
4706,
4236,
29898,
29900,
29892,
2602,
29961,
29896,
29962,
448,
4203,
29918,
2311,
29918,
1054,
448,
29871,
29896,
29897,
584,
1375,
29898,
1958,
29889,
12181,
29961,
29896,
1402,
3283,
29961,
29896,
29962,
718,
4203,
29918,
2311,
29918,
1054,
511,
13,
1678,
4514,
13,
13,
1678,
2910,
29961,
13,
4706,
4236,
29898,
29900,
29892,
2602,
29961,
29900,
29962,
448,
4203,
29918,
2311,
29918,
798,
448,
29871,
29896,
29897,
584,
1195,
29898,
1958,
29889,
12181,
29961,
29900,
1402,
2602,
29961,
29900,
29962,
718,
4203,
29918,
2311,
29918,
798,
511,
13,
4706,
4236,
29898,
29900,
29892,
2602,
29961,
29896,
29962,
448,
4203,
29918,
2311,
29918,
1054,
448,
29871,
29896,
29897,
584,
1195,
29898,
1958,
29889,
12181,
29961,
29896,
1402,
2602,
29961,
29896,
29962,
718,
4203,
29918,
2311,
29918,
1054,
511,
13,
1678,
4514,
353,
7442,
29889,
2873,
29898,
7382,
29889,
12181,
29897,
13,
13,
1678,
396,
2982,
22848,
13,
1678,
565,
2982,
22848,
338,
451,
6213,
322,
3978,
29918,
29916,
338,
451,
6213,
322,
3978,
29918,
29891,
338,
451,
6213,
29901,
13,
13,
4706,
12020,
2216,
1888,
2037,
287,
2392,
13,
13,
1678,
736,
2910,
13,
13,
13,
1753,
5706,
29906,
29928,
24713,
29898,
24713,
29918,
710,
1125,
13,
1678,
396,
402,
1430,
1001,
3040,
29906,
7858,
1299,
8127,
29911,
3251,
403,
29871,
29906,
29928,
8783,
10757,
6856,
13,
1678,
396,
13,
1678,
396,
1678,
10783,
482,
29901,
8783,
353,
402,
1430,
1001,
3040,
29906,
7858,
1299,
8127,
29911,
29898,
24713,
29918,
710,
29897,
13,
1678,
396,
1678,
732,
24713,
29918,
710,
539,
8783,
1347,
29892,
5923,
20035,
29901,
13,
1678,
396,
462,
539,
525,
6716,
6039,
303,
6436,
16390,
24541,
742,
525,
13985,
6039,
303,
23435,
16390,
24541,
29915,
13,
1678,
396,
13,
1678,
396,
1678,
10604,
19191,
29901,
13,
1678,
396,
1678,
8783,
29889,
1958,
4706,
5962,
8760,
10757,
6856,
13,
1678,
396,
1678,
8783,
29889,
5727,
539,
1353,
310,
4206,
313,
29891,
29897,
13,
1678,
396,
1678,
8783,
29889,
22724,
539,
1353,
310,
28730,
313,
29916,
29897,
13,
1678,
396,
1678,
8783,
29889,
12574,
29918,
29916,
259,
3978,
310,
2910,
921,
13,
1678,
396,
1678,
8783,
29889,
12574,
29918,
29891,
259,
3978,
310,
2910,
343,
13,
1678,
396,
1678,
8783,
29889,
3729,
29918,
2311,
29871,
3038,
2159,
13,
13,
1678,
8783,
353,
13373,
24541,
580,
13,
1678,
396,
8783,
29871,
29945,
29901,
29871,
29896,
20881,
8783,
363,
29871,
29906,
29928,
8481,
20881,
4772,
13,
1678,
565,
8783,
29918,
710,
338,
376,
6716,
6039,
303,
6436,
16390,
24541,
1115,
13,
4706,
396,
8636,
13,
4706,
8783,
29889,
22724,
353,
29871,
29941,
29900,
29900,
13,
4706,
8783,
29889,
5727,
353,
29871,
29941,
29900,
29900,
13,
4706,
8783,
29889,
12574,
29918,
29916,
353,
448,
29896,
13,
4706,
8783,
29889,
12574,
29918,
29891,
353,
448,
29896,
13,
4706,
8783,
29889,
3729,
29918,
2311,
353,
29871,
29900,
29889,
29900,
29896,
13,
4706,
396,
2910,
13,
4706,
8783,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
24713,
29889,
5727,
29892,
8783,
29889,
22724,
876,
13,
4706,
396,
14979,
23435,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
4197,
29896,
29929,
29900,
29892,
29871,
29896,
29953,
29900,
1402,
518,
29953,
29900,
29892,
29871,
29947,
29900,
1402,
8783,
29889,
1958,
29897,
13,
13,
1678,
396,
8783,
29871,
29953,
29901,
20881,
8783,
363,
29871,
29941,
29928,
8481,
20881,
4772,
13,
13,
1678,
25342,
8783,
29918,
710,
338,
376,
8915,
1115,
13,
4706,
396,
8636,
13,
4706,
8783,
29889,
22724,
353,
29871,
29941,
29900,
29900,
13,
4706,
8783,
29889,
5727,
353,
29871,
29941,
29900,
29900,
13,
4706,
8783,
29889,
12574,
29918,
29916,
353,
448,
29896,
13,
4706,
8783,
29889,
12574,
29918,
29891,
353,
448,
29896,
13,
4706,
8783,
29889,
3729,
29918,
2311,
353,
29871,
29900,
29889,
29900,
29896,
13,
4706,
396,
2910,
13,
4706,
8783,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
24713,
29889,
5727,
29892,
8783,
29889,
22724,
876,
13,
4706,
396,
14979,
23435,
13,
4706,
396,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
4197,
29906,
29900,
29900,
29892,
29871,
29906,
29900,
29900,
1402,
518,
29947,
29900,
29892,
29871,
29896,
29900,
29900,
1402,
8783,
29889,
1958,
29897,
13,
4706,
396,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
4197,
29896,
29953,
29900,
29892,
29871,
29947,
29900,
1402,
518,
29941,
29900,
29892,
29871,
29947,
29900,
1402,
8783,
29889,
1958,
29897,
13,
13,
1678,
25342,
8783,
29918,
710,
338,
376,
13985,
6039,
303,
23435,
16390,
24541,
1115,
13,
4706,
396,
8636,
13,
4706,
8783,
29889,
22724,
353,
29871,
29941,
29900,
29900,
13,
4706,
8783,
29889,
5727,
353,
29871,
29941,
29900,
29900,
13,
4706,
8783,
29889,
12574,
29918,
29916,
353,
448,
29896,
13,
4706,
8783,
29889,
12574,
29918,
29891,
353,
448,
29896,
13,
4706,
8783,
29889,
3729,
29918,
2311,
353,
29871,
29900,
29889,
29900,
29896,
13,
4706,
396,
2910,
13,
4706,
8783,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
24713,
29889,
5727,
29892,
8783,
29889,
22724,
876,
13,
4706,
396,
14979,
23435,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
4197,
29906,
29900,
29900,
29892,
29871,
29906,
29900,
29900,
1402,
518,
29947,
29900,
29892,
29871,
29896,
29900,
29900,
1402,
8783,
29889,
1958,
29897,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
4197,
29896,
29953,
29900,
29892,
29871,
29947,
29900,
1402,
518,
29941,
29900,
29892,
29871,
29947,
29900,
1402,
8783,
29889,
1958,
29897,
13,
13,
1678,
396,
8783,
29871,
29955,
29901,
2999,
20881,
8783,
363,
29871,
29906,
29928,
8481,
20881,
4772,
13,
1678,
25342,
8783,
29918,
710,
338,
376,
15329,
6039,
303,
6436,
16390,
24541,
1115,
13,
4706,
396,
8636,
13,
4706,
8783,
29889,
22724,
353,
29871,
29946,
29900,
29900,
29871,
396,
921,
13,
4706,
8783,
29889,
5727,
353,
29871,
29941,
29900,
29900,
29871,
396,
343,
13,
4706,
8783,
29889,
12574,
29918,
29916,
353,
448,
29906,
29900,
13,
4706,
8783,
29889,
12574,
29918,
29891,
353,
448,
29896,
29900,
13,
4706,
8783,
29889,
3729,
29918,
2311,
353,
29871,
29900,
29889,
29896,
13,
4706,
396,
2910,
13,
4706,
8783,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
24713,
29889,
5727,
29892,
8783,
29889,
22724,
876,
13,
4706,
396,
14979,
23435,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
9651,
679,
29918,
5064,
29898,
29896,
29906,
29892,
29871,
29896,
29900,
29892,
8783,
511,
679,
29918,
6229,
29898,
29945,
29892,
29871,
29955,
29892,
8783,
511,
8783,
29889,
1958,
13,
4706,
1723,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
9651,
679,
29918,
5064,
6278,
29955,
29892,
29871,
29896,
29900,
29892,
8783,
511,
679,
29918,
6229,
29898,
29896,
29900,
29892,
29871,
29955,
29892,
8783,
511,
8783,
29889,
1958,
13,
4706,
1723,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
9651,
679,
29918,
5064,
29898,
29900,
29892,
448,
29945,
29892,
8783,
511,
679,
29918,
6229,
29898,
29896,
29900,
29892,
29871,
29945,
29892,
8783,
511,
8783,
29889,
1958,
13,
4706,
1723,
13,
13,
1678,
396,
10426,
29871,
29906,
29881,
2910,
13,
1678,
25342,
8783,
29918,
710,
338,
376,
29295,
3388,
29896,
1115,
13,
4706,
396,
8636,
13,
4706,
8783,
29889,
22724,
353,
29871,
29945,
29900,
29900,
29871,
396,
921,
13,
4706,
8783,
29889,
5727,
353,
29871,
29945,
29900,
29900,
29871,
396,
343,
13,
4706,
8783,
29889,
12574,
29918,
29916,
353,
448,
29896,
29900,
13,
4706,
8783,
29889,
12574,
29918,
29891,
353,
448,
29896,
29900,
13,
4706,
8783,
29889,
3729,
29918,
2311,
353,
29871,
29900,
29889,
29900,
29896,
13,
4706,
396,
2910,
13,
4706,
8783,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
24713,
29889,
5727,
29892,
8783,
29889,
22724,
876,
13,
4706,
396,
14979,
23435,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
9651,
679,
29918,
5064,
29898,
29900,
29892,
29871,
29900,
29892,
8783,
511,
679,
29918,
6229,
29898,
29896,
29892,
29871,
29945,
29892,
8783,
511,
8783,
29889,
1958,
13,
4706,
1723,
13,
4706,
396,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
657,
29918,
5064,
6278,
29906,
29889,
29945,
6653,
29906,
29892,
24713,
511,
679,
29918,
6229,
29898,
29945,
29892,
29896,
29892,
24713,
511,
8783,
29889,
1958,
416,
13,
4706,
396,
10090,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
9651,
679,
29918,
5064,
29898,
29900,
29892,
29871,
29946,
29889,
29945,
29892,
8783,
511,
679,
29918,
6229,
29898,
29896,
29900,
29892,
29871,
29896,
29892,
8783,
511,
8783,
29889,
1958,
13,
4706,
1723,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
9651,
679,
29918,
5064,
29898,
29900,
29892,
448,
29946,
29889,
29945,
29892,
8783,
511,
679,
29918,
6229,
29898,
29896,
29900,
29892,
29871,
29896,
29892,
8783,
511,
8783,
29889,
1958,
13,
4706,
1723,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
9651,
679,
29918,
5064,
29898,
29946,
29889,
29945,
29892,
29871,
29900,
29892,
8783,
511,
679,
29918,
6229,
29898,
29896,
29892,
29871,
29896,
29900,
29892,
8783,
511,
8783,
29889,
1958,
13,
4706,
1723,
13,
4706,
8783,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
9651,
679,
29918,
5064,
6278,
29946,
29889,
29945,
29892,
29871,
29900,
29892,
8783,
511,
679,
29918,
6229,
29898,
29896,
29892,
29871,
29896,
29900,
29892,
8783,
511,
8783,
29889,
1958,
13,
4706,
1723,
13,
13,
1678,
396,
694,
1316,
8783,
13,
1678,
1683,
29901,
13,
4706,
12020,
4408,
2392,
703,
3782,
1316,
8783,
1863,
1159,
13,
13,
1678,
736,
8783,
13,
13,
13,
1990,
4121,
1467,
29906,
29928,
24713,
29898,
3318,
1125,
13,
1678,
396,
3013,
5702,
310,
5446,
1691,
29892,
322,
1009,
12885,
29889,
13,
1678,
396,
788,
4802,
10452,
5073,
653,
14603,
373,
599,
29871,
29946,
11192,
29889,
13,
1678,
396,
20459,
938,
6646,
5446,
1691,
310,
1021,
2159,
472,
1422,
921,
29892,
343,
13,
1678,
396,
731,
4036,
12885,
9119,
20816,
322,
18112,
363,
1269,
3618,
13,
1678,
396,
29611,
847,
4337,
491,
11636,
931,
29889,
13,
1678,
396,
565,
343,
338,
3109,
1135,
18046,
340,
470,
343,
338,
1405,
2246,
10195,
334,
29922,
448,
29896,
13,
1678,
396,
565,
921,
338,
3109,
1135,
2175,
470,
921,
338,
1405,
1492,
325,
29916,
334,
29922,
448,
29896,
13,
1678,
822,
4770,
2344,
12035,
13,
4706,
1583,
29892,
13,
4706,
4206,
29922,
29946,
29900,
29900,
29892,
13,
4706,
28730,
29922,
29906,
29900,
29900,
29892,
29871,
396,
4206,
16161,
304,
343,
13,
4706,
3978,
29918,
29916,
29922,
29900,
29889,
29900,
29892,
13,
4706,
3978,
29918,
29891,
29922,
29900,
29889,
29900,
29892,
13,
4706,
3038,
29918,
2311,
29922,
29900,
29889,
29896,
29892,
13,
268,
1125,
13,
13,
4706,
1583,
29889,
24713,
353,
13373,
24541,
580,
13,
4706,
1583,
29889,
24713,
29889,
22724,
353,
28730,
13,
4706,
1583,
29889,
24713,
29889,
5727,
353,
4206,
13,
4706,
1583,
29889,
24713,
29889,
12574,
29918,
29916,
353,
3978,
29918,
29916,
13,
4706,
1583,
29889,
24713,
29889,
12574,
29918,
29891,
353,
3978,
29918,
29891,
13,
4706,
1583,
29889,
24713,
29889,
3729,
29918,
2311,
353,
3038,
29918,
2311,
13,
4706,
396,
2910,
13,
4706,
1583,
29889,
7959,
29918,
711,
303,
23435,
353,
5159,
13,
4706,
1583,
29889,
16626,
29918,
711,
303,
23435,
353,
5159,
13,
13,
4706,
396,
2175,
29892,
1492,
29892,
5970,
29892,
701,
13,
4706,
1583,
29889,
23687,
353,
518,
13,
9651,
3978,
29918,
29916,
29892,
13,
9651,
3978,
29918,
29916,
718,
3038,
29918,
2311,
334,
28730,
29892,
13,
9651,
3978,
29918,
29891,
29892,
13,
9651,
3978,
29918,
29891,
718,
3038,
29918,
2311,
334,
4206,
29892,
13,
4706,
4514,
13,
13,
1678,
822,
2069,
29918,
711,
303,
23435,
29898,
1311,
29892,
16717,
29918,
791,
29922,
8516,
29892,
14979,
6436,
29918,
1949,
29922,
29896,
29900,
29900,
29892,
5343,
29918,
13400,
29922,
29900,
29889,
29947,
29892,
29871,
1035,
29918,
13400,
29922,
8516,
29892,
1125,
13,
13,
4706,
565,
16717,
29918,
791,
338,
6213,
29901,
13,
9651,
16717,
29918,
791,
353,
29871,
29900,
13,
4706,
8783,
29918,
8172,
29889,
26776,
29898,
26776,
29918,
791,
29897,
13,
13,
4706,
396,
1207,
2294,
14979,
23435,
13,
4706,
1583,
29889,
7959,
29918,
711,
303,
23435,
29889,
4397,
29898,
13,
9651,
1583,
29889,
5675,
29918,
711,
303,
6436,
29898,
29896,
29900,
29889,
29900,
29892,
29871,
29896,
29945,
29889,
29900,
29892,
7442,
29889,
294,
2378,
4197,
29896,
29889,
29900,
29892,
29871,
29941,
29889,
29900,
12622,
13,
4706,
1723,
13,
13,
4706,
1583,
29889,
7959,
29918,
711,
303,
23435,
29889,
4397,
29898,
1311,
29889,
5675,
29918,
711,
303,
6436,
29898,
29941,
29889,
29900,
29892,
29871,
29906,
29900,
29889,
29900,
29892,
7442,
29889,
294,
2378,
4197,
29946,
29892,
29871,
29946,
29900,
29962,
4961,
13,
13,
4706,
1583,
29889,
7959,
29918,
711,
303,
23435,
29889,
4397,
29898,
13,
9651,
1583,
29889,
5675,
29918,
711,
303,
6436,
29898,
29896,
29955,
29889,
29900,
29892,
29871,
29906,
29900,
29889,
29900,
29892,
7442,
29889,
294,
2378,
4197,
29946,
29892,
29871,
29946,
29900,
12622,
13,
4706,
1723,
13,
13,
4706,
396,
1207,
7343,
14979,
23435,
13,
4706,
1583,
29889,
16626,
29918,
23687,
353,
7442,
29889,
294,
2378,
29898,
1311,
29889,
23687,
29897,
13,
4706,
1583,
29889,
16626,
29918,
23687,
29961,
29900,
29962,
353,
29871,
29947,
29889,
29900,
13,
4706,
1583,
29889,
16626,
29918,
23687,
29961,
29896,
29962,
353,
29871,
29896,
29906,
29889,
29900,
13,
13,
4706,
1583,
29889,
16626,
29918,
711,
303,
23435,
29889,
4397,
29898,
13,
9651,
1583,
29889,
5675,
29918,
711,
303,
6436,
29898,
13,
18884,
4036,
29918,
4537,
29898,
1311,
29889,
16626,
29918,
23687,
29961,
29900,
1402,
1583,
29889,
16626,
29918,
23687,
29961,
29896,
11724,
13,
462,
29896,
29900,
29892,
13,
18884,
7442,
29889,
294,
2378,
4197,
29945,
29889,
29900,
29892,
29871,
29941,
29889,
29900,
11724,
13,
9651,
1723,
13,
4706,
1723,
13,
4706,
1583,
29889,
16626,
29918,
711,
303,
23435,
29961,
29900,
1822,
29894,
29918,
29891,
353,
29871,
29900,
29889,
29900,
13,
4706,
1583,
29889,
16626,
29918,
711,
303,
23435,
29961,
29900,
1822,
29894,
29918,
29916,
353,
5343,
29918,
13400,
29937,
334,
313,
29906,
29889,
29900,
29914,
29941,
29889,
29900,
29897,
13,
13,
4706,
565,
14979,
6436,
29918,
1949,
1275,
29871,
29906,
29901,
13,
9651,
1583,
29889,
16626,
29918,
711,
303,
23435,
29889,
4397,
29898,
13,
18884,
1583,
29889,
5675,
29918,
711,
303,
6436,
29898,
13,
462,
1678,
4036,
29918,
4537,
29898,
1311,
29889,
16626,
29918,
23687,
29961,
29900,
1402,
1583,
29889,
16626,
29918,
23687,
29961,
29896,
11724,
13,
462,
268,
29906,
29945,
29892,
13,
462,
1678,
7442,
29889,
294,
2378,
4197,
29945,
29889,
29900,
29892,
29871,
29941,
29889,
29900,
11724,
13,
18884,
1723,
13,
9651,
1723,
13,
9651,
1583,
29889,
16626,
29918,
711,
303,
23435,
29961,
29896,
1822,
29894,
29918,
29891,
353,
29871,
29900,
29889,
29900,
13,
9651,
1583,
29889,
16626,
29918,
711,
303,
23435,
29961,
29896,
1822,
29894,
29918,
29916,
353,
5343,
29918,
13400,
13,
13,
9651,
1583,
29889,
7959,
29918,
711,
303,
23435,
29889,
4397,
29898,
13,
18884,
1583,
29889,
5675,
29918,
711,
303,
6436,
29898,
29896,
29900,
29889,
29900,
29892,
29871,
29941,
29900,
29889,
29900,
29892,
7442,
29889,
294,
2378,
4197,
29896,
29889,
29900,
29892,
29871,
29941,
29889,
29900,
12622,
13,
9651,
1723,
13,
13,
4706,
1583,
29889,
711,
303,
23435,
353,
1583,
29889,
7959,
29918,
711,
303,
23435,
718,
1583,
29889,
16626,
29918,
711,
303,
23435,
13,
13,
1678,
822,
1207,
29918,
711,
303,
6436,
29898,
1311,
29892,
921,
29892,
343,
29892,
2159,
1125,
13,
4706,
20881,
353,
4250,
303,
6436,
580,
13,
4706,
20881,
29889,
29916,
353,
921,
13,
4706,
20881,
29889,
29891,
353,
343,
13,
4706,
20881,
29889,
2311,
353,
2159,
13,
13,
4706,
736,
20881,
13,
13,
1678,
822,
29611,
29898,
1311,
29892,
11636,
1125,
13,
13,
4706,
363,
20881,
297,
1583,
29889,
16626,
29918,
711,
303,
23435,
29901,
13,
9651,
20881,
29889,
29916,
4619,
11636,
334,
20881,
29889,
29894,
29918,
29916,
13,
9651,
20881,
29889,
29891,
4619,
11636,
334,
20881,
29889,
29894,
29918,
29891,
13,
13,
9651,
396,
1735,
9110,
1907,
13,
9651,
565,
20881,
29889,
29916,
5277,
1583,
29889,
16626,
29918,
23687,
29961,
29900,
29962,
470,
20881,
29889,
29916,
6736,
1583,
29889,
16626,
29918,
23687,
29961,
29896,
5387,
13,
18884,
20881,
29889,
29894,
29918,
29916,
334,
29922,
448,
29896,
13,
9651,
565,
20881,
29889,
29891,
5277,
1583,
29889,
16626,
29918,
23687,
29961,
29906,
29962,
470,
20881,
29889,
29891,
6736,
1583,
29889,
16626,
29918,
23687,
29961,
29941,
5387,
13,
18884,
20881,
29889,
29894,
29918,
29891,
334,
29922,
448,
29896,
13,
13,
1678,
822,
679,
29918,
24713,
29898,
1311,
29892,
18593,
29922,
8516,
29892,
2910,
29918,
2311,
29922,
8516,
1125,
29871,
396,
2159,
297,
27881,
13,
13,
4706,
1583,
29889,
24713,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
1311,
29889,
24713,
29889,
5727,
29892,
1583,
29889,
24713,
29889,
22724,
876,
13,
13,
4706,
363,
20881,
297,
1583,
29889,
7959,
29918,
711,
303,
23435,
29901,
13,
9651,
1583,
29889,
24713,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
18884,
679,
29918,
5064,
29898,
26290,
29889,
29916,
29892,
20881,
29889,
29891,
29892,
1583,
29889,
24713,
511,
13,
18884,
679,
29918,
6229,
29898,
26290,
29889,
2311,
29961,
29900,
1402,
20881,
29889,
2311,
29961,
29896,
1402,
1583,
29889,
24713,
511,
13,
18884,
1583,
29889,
24713,
29889,
1958,
29892,
13,
9651,
1723,
13,
13,
4706,
363,
20881,
297,
1583,
29889,
16626,
29918,
711,
303,
23435,
29901,
13,
9651,
1583,
29889,
24713,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
18884,
679,
29918,
5064,
29898,
26290,
29889,
29916,
29892,
20881,
29889,
29891,
29892,
1583,
29889,
24713,
511,
13,
18884,
679,
29918,
6229,
29898,
26290,
29889,
2311,
29961,
29900,
1402,
20881,
29889,
2311,
29961,
29896,
1402,
1583,
29889,
24713,
511,
13,
18884,
1583,
29889,
24713,
29889,
1958,
29892,
13,
9651,
1723,
13,
13,
4706,
565,
18593,
338,
6213,
470,
2910,
29918,
2311,
338,
6213,
29901,
13,
9651,
736,
1583,
29889,
24713,
13,
13,
4706,
5694,
29918,
24713,
353,
13373,
24541,
580,
13,
4706,
5694,
29918,
24713,
29889,
12574,
29918,
29916,
353,
18593,
29961,
29900,
29962,
448,
5785,
29898,
1958,
29918,
2311,
29961,
29900,
2314,
847,
29871,
29906,
29889,
29900,
13,
4706,
5694,
29918,
24713,
29889,
12574,
29918,
29891,
353,
18593,
29961,
29896,
29962,
448,
5785,
29898,
1958,
29918,
2311,
29961,
29896,
2314,
847,
29871,
29906,
29889,
29900,
13,
4706,
5694,
29918,
24713,
29889,
3729,
29918,
2311,
353,
1583,
29889,
24713,
29889,
3729,
29918,
2311,
13,
13,
4706,
5224,
29918,
1563,
353,
679,
29918,
5064,
29898,
13,
9651,
5694,
29918,
24713,
29889,
12574,
29918,
29916,
29892,
5694,
29918,
24713,
29889,
12574,
29918,
29891,
29892,
1583,
29889,
24713,
13,
4706,
1723,
13,
13,
4706,
565,
5224,
29918,
1563,
29961,
29900,
29962,
529,
29871,
29900,
29901,
13,
9651,
5224,
29918,
1563,
29961,
29900,
29962,
353,
29871,
29900,
13,
9651,
5694,
29918,
24713,
29889,
12574,
29918,
29891,
353,
1583,
29889,
24713,
29889,
12574,
29918,
29891,
13,
13,
4706,
565,
5224,
29918,
1563,
29961,
29896,
29962,
529,
29871,
29900,
29901,
13,
9651,
5224,
29918,
1563,
29961,
29896,
29962,
353,
29871,
29900,
13,
9651,
5694,
29918,
24713,
29889,
12574,
29918,
29916,
353,
1583,
29889,
24713,
29889,
12574,
29918,
29916,
13,
13,
4706,
7568,
29918,
1266,
353,
679,
29918,
5064,
29898,
13,
9651,
18593,
29961,
29900,
29962,
718,
5785,
29898,
1958,
29918,
2311,
29961,
29900,
2314,
847,
29871,
29906,
29889,
29900,
29892,
13,
9651,
18593,
29961,
29896,
29962,
718,
5785,
29898,
1958,
29918,
2311,
29961,
29896,
2314,
847,
29871,
29906,
29889,
29900,
29892,
13,
9651,
1583,
29889,
24713,
29892,
13,
4706,
1723,
13,
13,
4706,
565,
7568,
29918,
1266,
29961,
29900,
29962,
6736,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29900,
5387,
13,
9651,
7568,
29918,
1266,
29961,
29900,
29962,
353,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29900,
29962,
448,
29871,
29896,
13,
13,
4706,
565,
7568,
29918,
1266,
29961,
29896,
29962,
6736,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29896,
5387,
13,
9651,
7568,
29918,
1266,
29961,
29896,
29962,
353,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29896,
29962,
448,
29871,
29896,
13,
13,
4706,
565,
313,
13,
9651,
7568,
29918,
1266,
29961,
29900,
29962,
529,
29871,
29900,
13,
9651,
470,
7568,
29918,
1266,
29961,
29896,
29962,
529,
29871,
29900,
13,
9651,
470,
5224,
29918,
1563,
29961,
29900,
29962,
6736,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29900,
29962,
13,
9651,
470,
5224,
29918,
1563,
29961,
29896,
29962,
6736,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29896,
29962,
13,
308,
1125,
13,
9651,
5694,
29918,
24713,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
29945,
29892,
29871,
29945,
876,
29871,
396,
777,
2910,
310,
24786,
13,
4706,
1683,
29901,
13,
9651,
5694,
29918,
24713,
29889,
1958,
353,
1583,
29889,
24713,
29889,
1958,
29961,
13,
18884,
5224,
29918,
1563,
29961,
29900,
29962,
584,
7568,
29918,
1266,
29961,
29900,
29962,
718,
29871,
29896,
29892,
5224,
29918,
1563,
29961,
29896,
29962,
584,
7568,
29918,
1266,
29961,
29896,
29962,
718,
29871,
29896,
13,
9651,
4514,
13,
13,
4706,
5694,
29918,
24713,
29889,
5727,
353,
5694,
29918,
24713,
29889,
1958,
29889,
12181,
29961,
29900,
29962,
13,
4706,
5694,
29918,
24713,
29889,
22724,
353,
5694,
29918,
24713,
29889,
1958,
29889,
12181,
29961,
29896,
29962,
13,
4706,
736,
5694,
29918,
24713,
13,
13,
268,
13,
13,
13,
1990,
27747,
29906,
29928,
24713,
29898,
3318,
1125,
13,
1678,
396,
3013,
5702,
310,
5446,
1691,
29892,
322,
1009,
12885,
29889,
13,
1678,
396,
788,
4802,
10452,
5073,
653,
14603,
373,
599,
29871,
29946,
11192,
29889,
13,
1678,
396,
20459,
938,
6646,
5446,
1691,
310,
1021,
2159,
472,
1422,
921,
29892,
343,
13,
1678,
396,
731,
4036,
12885,
9119,
20816,
322,
18112,
363,
1269,
3618,
13,
1678,
396,
29611,
847,
4337,
491,
11636,
931,
29889,
13,
1678,
396,
565,
343,
338,
3109,
1135,
18046,
340,
470,
343,
338,
1405,
2246,
10195,
334,
29922,
448,
29896,
13,
1678,
396,
565,
921,
338,
3109,
1135,
2175,
470,
921,
338,
1405,
1492,
325,
29916,
334,
29922,
448,
29896,
13,
13,
1678,
822,
4770,
2344,
12035,
13,
4706,
1583,
29892,
13,
4706,
4206,
29922,
29929,
29900,
29900,
29892,
13,
4706,
28730,
29922,
29896,
29906,
29900,
29900,
29892,
13,
4706,
3978,
29918,
29916,
29922,
29900,
29889,
29900,
29892,
13,
4706,
3978,
29918,
29891,
29922,
29900,
29889,
29900,
29892,
13,
4706,
3038,
29918,
2311,
29922,
29900,
29889,
29896,
29892,
13,
268,
1125,
13,
13,
4706,
1583,
29889,
24713,
353,
13373,
24541,
580,
13,
4706,
1583,
29889,
24713,
29889,
22724,
353,
28730,
13,
4706,
1583,
29889,
24713,
29889,
5727,
353,
4206,
13,
4706,
1583,
29889,
24713,
29889,
12574,
29918,
29916,
353,
3978,
29918,
29916,
13,
4706,
1583,
29889,
24713,
29889,
12574,
29918,
29891,
353,
3978,
29918,
29891,
13,
4706,
1583,
29889,
24713,
29889,
3729,
29918,
2311,
353,
3038,
29918,
2311,
13,
4706,
396,
2910,
13,
4706,
1583,
29889,
711,
303,
23435,
353,
5159,
13,
13,
4706,
396,
2175,
29892,
1492,
29892,
5970,
29892,
701,
13,
13,
4706,
1583,
29889,
23687,
353,
518,
13,
9651,
3978,
29918,
29916,
29892,
13,
9651,
3978,
29918,
29916,
718,
3038,
29918,
2311,
334,
28730,
29892,
13,
9651,
3978,
29918,
29891,
29892,
13,
9651,
3978,
29918,
29891,
718,
3038,
29918,
2311,
334,
4206,
29892,
13,
4706,
4514,
13,
13,
4706,
1583,
29889,
26290,
29918,
2311,
353,
313,
1311,
29889,
23687,
29961,
29896,
29962,
448,
1583,
29889,
23687,
29961,
29900,
2314,
847,
29871,
29906,
29900,
29889,
29900,
13,
13,
4706,
1583,
29889,
26290,
29918,
5721,
353,
29871,
29896,
29900,
29889,
29900,
13,
4706,
1583,
29889,
28111,
353,
6213,
13,
4706,
1583,
29889,
2962,
353,
6213,
13,
13,
4706,
1583,
29889,
29590,
29918,
7720,
353,
7700,
13,
13,
1678,
822,
2069,
29918,
711,
303,
23435,
29898,
1311,
29892,
16717,
29918,
791,
29922,
8516,
29892,
14979,
6436,
29918,
1949,
29922,
29896,
29900,
29900,
29892,
5343,
29918,
13400,
29922,
8516,
29892,
29871,
1035,
29918,
13400,
29922,
8516,
29892,
29871,
13,
462,
4706,
1369,
29922,
8516,
29892,
7306,
29922,
8516,
1125,
13,
13,
13,
4706,
565,
14979,
6436,
29918,
1949,
1275,
448,
29896,
29901,
13,
9651,
1583,
29889,
29590,
29918,
7720,
353,
5852,
13,
13,
9651,
921,
353,
1583,
29889,
23687,
29961,
29900,
29962,
13,
9651,
1550,
921,
529,
1583,
29889,
13451,
29961,
29896,
5387,
13,
18884,
343,
353,
1583,
29889,
23687,
29961,
29906,
29962,
13,
18884,
1550,
29871,
343,
529,
1583,
29889,
23687,
29961,
29941,
5387,
13,
462,
1678,
20881,
353,
4250,
303,
6436,
580,
13,
462,
1678,
20881,
29889,
29916,
353,
921,
13,
462,
1678,
20881,
29889,
29891,
353,
343,
13,
462,
1678,
20881,
29889,
2311,
353,
7442,
29889,
294,
2378,
4197,
1311,
29889,
26290,
29918,
2311,
29892,
1583,
29889,
26290,
29918,
2311,
2314,
13,
13,
462,
1678,
343,
4619,
29871,
29896,
29945,
29889,
29900,
13,
13,
462,
1678,
565,
7306,
338,
451,
6213,
29901,
13,
462,
4706,
565,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
9302,
29889,
2378,
4197,
26290,
29889,
29916,
29899,
28111,
29961,
29900,
1402,
20881,
29889,
29891,
29899,
28111,
29961,
29896,
5262,
876,
529,
1583,
29889,
26290,
29918,
5721,
29901,
13,
462,
9651,
6773,
13,
462,
1678,
565,
1369,
338,
451,
6213,
29901,
13,
462,
4706,
565,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
9302,
29889,
2378,
4197,
26290,
29889,
29916,
29899,
2962,
29961,
29900,
1402,
20881,
29889,
29891,
29899,
2962,
29961,
29896,
5262,
876,
529,
1583,
29889,
26290,
29918,
5721,
29901,
13,
462,
9651,
6773,
13,
462,
1678,
1583,
29889,
711,
303,
23435,
29889,
4397,
29898,
26290,
29897,
13,
18884,
921,
4619,
29871,
29896,
29945,
29889,
29900,
13,
9651,
736,
13,
13,
13,
13,
13,
13,
4706,
565,
1369,
338,
451,
6213,
29901,
13,
9651,
1583,
29889,
2962,
353,
1369,
13,
13,
4706,
565,
7306,
338,
451,
6213,
29901,
13,
9651,
1583,
29889,
28111,
353,
7306,
13,
13,
4706,
565,
16717,
29918,
791,
338,
6213,
29901,
13,
9651,
16717,
29918,
791,
353,
29871,
29900,
13,
4706,
8783,
29918,
8172,
29889,
26776,
29898,
26776,
29918,
791,
29897,
13,
13,
4706,
565,
5343,
29918,
13400,
338,
6213,
29901,
13,
9651,
5343,
29918,
13400,
353,
1583,
29889,
26290,
29918,
2311,
847,
29871,
29953,
13,
4706,
1583,
29889,
26290,
29918,
955,
25245,
353,
5343,
29918,
13400,
13,
13,
4706,
565,
1035,
29918,
13400,
338,
6213,
29901,
13,
9651,
1035,
29918,
13400,
353,
1583,
29889,
26290,
29918,
2311,
847,
29871,
29896,
29900,
13,
4706,
1583,
29889,
26290,
29918,
5753,
353,
1035,
29918,
13400,
13,
4706,
396,
1735,
297,
28178,
411,
931,
13,
4706,
1583,
29889,
5753,
29918,
6008,
353,
1583,
29889,
26290,
29918,
5753,
847,
29871,
29896,
29900,
13,
13,
4706,
1550,
7431,
29898,
1311,
29889,
711,
303,
23435,
29897,
529,
14979,
6436,
29918,
1949,
29901,
13,
9651,
396,
6755,
4036,
921,
29892,
29891,
363,
14979,
23435,
29889,
13,
13,
9651,
20881,
353,
4250,
303,
6436,
580,
13,
9651,
20881,
29889,
29916,
353,
4036,
29918,
4537,
29898,
1311,
29889,
23687,
29961,
29900,
1402,
1583,
29889,
23687,
29961,
29896,
2314,
13,
9651,
20881,
29889,
29891,
353,
4036,
29918,
4537,
29898,
1311,
29889,
23687,
29961,
29906,
1402,
1583,
29889,
23687,
29961,
29941,
2314,
13,
632,
13,
9651,
565,
7306,
338,
451,
6213,
29901,
13,
18884,
565,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
9302,
29889,
2378,
4197,
26290,
29889,
29916,
29899,
28111,
29961,
29900,
1402,
20881,
29889,
29891,
29899,
28111,
29961,
29896,
5262,
876,
529,
1583,
29889,
26290,
29918,
5721,
29901,
13,
462,
1678,
6773,
13,
9651,
565,
1369,
338,
451,
6213,
29901,
13,
18884,
565,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
9302,
29889,
2378,
4197,
26290,
29889,
29916,
29899,
2962,
29961,
29900,
1402,
20881,
29889,
29891,
29899,
2962,
29961,
29896,
5262,
876,
529,
1583,
29889,
26290,
29918,
5721,
29901,
13,
462,
1678,
6773,
13,
13,
9651,
20881,
29889,
29894,
29918,
29916,
353,
4036,
29918,
4537,
6278,
29896,
334,
1583,
29889,
26290,
29918,
955,
25245,
29892,
1583,
29889,
26290,
29918,
955,
25245,
29897,
13,
9651,
20881,
29889,
29894,
29918,
29891,
353,
4036,
29918,
4537,
6278,
29896,
334,
1583,
29889,
26290,
29918,
955,
25245,
29892,
1583,
29889,
26290,
29918,
955,
25245,
29897,
13,
9651,
20881,
29889,
29874,
29918,
29916,
353,
4036,
29918,
4537,
6278,
29896,
334,
1583,
29889,
26290,
29918,
5753,
29892,
1583,
29889,
26290,
29918,
5753,
29897,
13,
9651,
20881,
29889,
29874,
29918,
29891,
353,
4036,
29918,
4537,
6278,
29896,
334,
1583,
29889,
26290,
29918,
5753,
29892,
1583,
29889,
26290,
29918,
5753,
29897,
13,
9651,
20881,
29889,
2311,
353,
7442,
29889,
294,
2378,
4197,
1311,
29889,
26290,
29918,
2311,
29892,
1583,
29889,
26290,
29918,
2311,
2314,
13,
9651,
1583,
29889,
711,
303,
23435,
29889,
4397,
29898,
26290,
29897,
13,
13,
9651,
396,
1596,
877,
23687,
742,
1583,
29889,
23687,
29892,
1583,
29889,
26290,
29918,
2311,
29897,
13,
13,
1678,
822,
29611,
29898,
1311,
29892,
11636,
1125,
13,
13,
4706,
565,
1583,
29889,
29590,
29918,
7720,
29901,
13,
9651,
736,
13,
13,
4706,
363,
20881,
297,
1583,
29889,
711,
303,
23435,
29901,
13,
13,
9651,
396,
3789,
15592,
800,
13,
9651,
565,
4036,
29918,
4537,
29898,
29900,
29889,
29900,
29892,
29871,
29896,
29889,
29900,
29897,
1405,
29871,
29900,
29889,
29945,
29901,
13,
18884,
20881,
29889,
29874,
29918,
29916,
4619,
1583,
29889,
5753,
29918,
6008,
13,
9651,
1683,
29901,
13,
18884,
20881,
29889,
29874,
29918,
29916,
22361,
1583,
29889,
5753,
29918,
6008,
13,
13,
9651,
20881,
29889,
29874,
29918,
29916,
353,
1375,
29898,
26290,
29889,
29874,
29918,
29916,
29892,
1583,
29889,
26290,
29918,
5753,
29897,
13,
9651,
20881,
29889,
29874,
29918,
29916,
353,
4236,
29898,
26290,
29889,
29874,
29918,
29916,
29892,
448,
29896,
334,
1583,
29889,
26290,
29918,
5753,
29897,
13,
13,
9651,
565,
4036,
29918,
4537,
29898,
29900,
29889,
29900,
29892,
29871,
29896,
29889,
29900,
29897,
1405,
29871,
29900,
29889,
29945,
29901,
13,
18884,
20881,
29889,
29874,
29918,
29891,
4619,
1583,
29889,
5753,
29918,
6008,
13,
9651,
1683,
29901,
13,
18884,
20881,
29889,
29874,
29918,
29891,
22361,
1583,
29889,
5753,
29918,
6008,
13,
13,
9651,
20881,
29889,
29874,
29918,
29891,
353,
1375,
29898,
26290,
29889,
29874,
29918,
29891,
29892,
1583,
29889,
26290,
29918,
5753,
29897,
13,
9651,
20881,
29889,
29874,
29918,
29891,
353,
4236,
29898,
26290,
29889,
29874,
29918,
29891,
29892,
448,
29896,
334,
1583,
29889,
26290,
29918,
5753,
29897,
13,
13,
9651,
20881,
29889,
29894,
29918,
29916,
4619,
11636,
334,
20881,
29889,
29874,
29918,
29916,
13,
9651,
20881,
29889,
29894,
29918,
29891,
4619,
11636,
334,
20881,
29889,
29874,
29918,
29891,
13,
13,
13,
9651,
20881,
29889,
29894,
29918,
29916,
353,
1375,
29898,
26290,
29889,
29894,
29918,
29916,
29892,
1583,
29889,
26290,
29918,
955,
25245,
29897,
13,
9651,
20881,
29889,
29894,
29918,
29916,
353,
4236,
29898,
26290,
29889,
29894,
29918,
29916,
29892,
448,
29896,
334,
1583,
29889,
26290,
29918,
955,
25245,
29897,
13,
13,
13,
9651,
20881,
29889,
29894,
29918,
29891,
353,
1375,
29898,
26290,
29889,
29894,
29918,
29891,
29892,
1583,
29889,
26290,
29918,
955,
25245,
29897,
13,
9651,
20881,
29889,
29894,
29918,
29891,
353,
4236,
29898,
26290,
29889,
29894,
29918,
29891,
29892,
448,
29896,
334,
1583,
29889,
26290,
29918,
955,
25245,
29897,
13,
13,
9651,
20881,
29889,
29916,
4619,
11636,
334,
20881,
29889,
29894,
29918,
29916,
13,
9651,
20881,
29889,
29891,
4619,
11636,
334,
20881,
29889,
29894,
29918,
29891,
13,
13,
9651,
565,
1583,
29889,
28111,
338,
451,
6213,
29901,
13,
18884,
565,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
9302,
29889,
2378,
4197,
26290,
29889,
29916,
29899,
1311,
29889,
28111,
29961,
29900,
1402,
20881,
29889,
29891,
29899,
1311,
29889,
28111,
29961,
29896,
5262,
876,
529,
1583,
29889,
26290,
29918,
5721,
29901,
13,
462,
1678,
396,
289,
21543,
1283,
278,
8607,
2820,
7306,
13,
462,
1678,
325,
29896,
353,
7442,
29889,
2378,
4197,
26290,
29889,
29916,
29899,
1311,
29889,
28111,
29961,
29900,
1402,
20881,
29889,
29891,
29899,
1311,
29889,
28111,
29961,
29896,
24960,
13,
462,
1678,
325,
29896,
353,
325,
29896,
29914,
9302,
29889,
29880,
979,
29887,
29889,
12324,
29898,
29894,
29896,
29897,
13,
13,
462,
1678,
325,
29906,
353,
448,
29896,
334,
7442,
29889,
2378,
4197,
26290,
29889,
29894,
29918,
29916,
29892,
20881,
29889,
29894,
29918,
29891,
2314,
13,
462,
1678,
325,
29906,
353,
325,
29906,
29914,
9302,
29889,
29880,
979,
29887,
29889,
12324,
29898,
29894,
29906,
29897,
13,
13,
462,
1678,
278,
941,
353,
5844,
29889,
562,
359,
29898,
9302,
29889,
29880,
979,
29887,
29889,
12324,
29898,
7442,
29889,
6333,
29898,
29894,
29896,
29892,
325,
29906,
4961,
13,
13,
462,
1678,
15595,
353,
5844,
29889,
23402,
29906,
29898,
26290,
29889,
29894,
29918,
29891,
29892,
20881,
29889,
29894,
29918,
29916,
29897,
13,
462,
1678,
21762,
353,
5844,
29889,
23402,
29906,
29898,
26290,
29889,
29891,
448,
1583,
29889,
28111,
29961,
29896,
1402,
20881,
29889,
29916,
448,
1583,
29889,
28111,
29961,
29900,
2314,
13,
13,
462,
1678,
5343,
29918,
345,
312,
353,
7442,
29889,
2378,
4197,
26290,
29889,
29894,
29918,
29916,
29892,
20881,
29889,
29894,
29918,
29891,
2314,
13,
13,
462,
1678,
10696,
353,
21762,
448,
15595,
448,
278,
941,
13,
13,
462,
1678,
5731,
29918,
2922,
353,
7442,
29889,
2378,
4197,
29961,
755,
29889,
3944,
29898,
2521,
511,
448,
29896,
29930,
5844,
29889,
5223,
29898,
2521,
29897,
1402,
518,
5844,
29889,
5223,
29898,
2521,
511,
5844,
29889,
3944,
29898,
2521,
4638,
2314,
13,
13,
462,
1678,
716,
29918,
955,
29879,
353,
259,
7442,
29889,
2922,
16109,
29898,
9302,
29889,
294,
2378,
4197,
26290,
29889,
29894,
29918,
29916,
29892,
20881,
29889,
29894,
29918,
29891,
2314,
1919,
5731,
29918,
2922,
29889,
29911,
29897,
13,
13,
462,
1678,
20881,
29889,
29894,
29918,
29916,
353,
716,
29918,
955,
29879,
29961,
29900,
29962,
13,
462,
1678,
20881,
29889,
29894,
29918,
29891,
353,
716,
29918,
955,
29879,
29961,
29896,
29962,
13,
13,
9651,
565,
1583,
29889,
2962,
338,
451,
6213,
29901,
13,
18884,
565,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
9302,
29889,
2378,
4197,
26290,
29889,
29916,
29899,
1311,
29889,
2962,
29961,
29900,
1402,
20881,
29889,
29891,
29899,
1311,
29889,
2962,
29961,
29896,
5262,
876,
529,
1583,
29889,
26290,
29918,
5721,
29901,
13,
462,
1678,
396,
289,
21543,
1283,
278,
8607,
2820,
1369,
13,
13,
462,
1678,
325,
29896,
353,
7442,
29889,
2378,
4197,
26290,
29889,
29916,
29899,
1311,
29889,
2962,
29961,
29900,
1402,
20881,
29889,
29891,
29899,
1311,
29889,
2962,
29961,
29896,
24960,
13,
462,
1678,
325,
29896,
353,
325,
29896,
29914,
9302,
29889,
29880,
979,
29887,
29889,
12324,
29898,
29894,
29896,
29897,
13,
13,
462,
1678,
325,
29906,
353,
448,
29896,
334,
7442,
29889,
2378,
4197,
26290,
29889,
29894,
29918,
29916,
29892,
20881,
29889,
29894,
29918,
29891,
2314,
13,
462,
1678,
325,
29906,
353,
325,
29906,
29914,
9302,
29889,
29880,
979,
29887,
29889,
12324,
29898,
29894,
29906,
29897,
13,
13,
462,
1678,
278,
941,
353,
5844,
29889,
562,
359,
29898,
9302,
29889,
29880,
979,
29887,
29889,
12324,
29898,
7442,
29889,
6333,
29898,
29894,
29896,
29892,
325,
29906,
4961,
13,
13,
462,
1678,
15595,
353,
5844,
29889,
23402,
29906,
29898,
26290,
29889,
29894,
29918,
29891,
29892,
20881,
29889,
29894,
29918,
29916,
29897,
13,
462,
1678,
21762,
353,
5844,
29889,
23402,
29906,
29898,
26290,
29889,
29891,
448,
1583,
29889,
2962,
29961,
29896,
1402,
20881,
29889,
29916,
448,
1583,
29889,
2962,
29961,
29900,
2314,
13,
13,
462,
1678,
5343,
29918,
345,
312,
353,
7442,
29889,
2378,
4197,
26290,
29889,
29894,
29918,
29916,
29892,
20881,
29889,
29894,
29918,
29891,
2314,
13,
13,
462,
1678,
10696,
353,
21762,
448,
15595,
448,
278,
941,
13,
13,
462,
1678,
5731,
29918,
2922,
353,
7442,
29889,
2378,
4197,
29961,
755,
29889,
3944,
29898,
2521,
511,
448,
29896,
29930,
5844,
29889,
5223,
29898,
2521,
29897,
1402,
518,
5844,
29889,
5223,
29898,
2521,
511,
5844,
29889,
3944,
29898,
2521,
4638,
2314,
13,
13,
462,
1678,
716,
29918,
955,
29879,
353,
259,
7442,
29889,
2922,
16109,
29898,
9302,
29889,
294,
2378,
4197,
26290,
29889,
29894,
29918,
29916,
29892,
20881,
29889,
29894,
29918,
29891,
2314,
1919,
5731,
29918,
2922,
29889,
29911,
29897,
13,
13,
462,
1678,
20881,
29889,
29894,
29918,
29916,
353,
716,
29918,
955,
29879,
29961,
29900,
29962,
13,
462,
1678,
20881,
29889,
29894,
29918,
29891,
353,
716,
29918,
955,
29879,
29961,
29896,
29962,
13,
13,
13,
9651,
396,
1735,
9110,
1907,
13,
9651,
565,
20881,
29889,
29916,
5277,
1583,
29889,
23687,
29961,
29900,
29962,
470,
20881,
29889,
29916,
6736,
1583,
29889,
23687,
29961,
29896,
5387,
13,
18884,
20881,
29889,
29894,
29918,
29916,
334,
29922,
448,
29896,
13,
9651,
565,
20881,
29889,
29891,
5277,
1583,
29889,
23687,
29961,
29906,
29962,
470,
20881,
29889,
29891,
6736,
1583,
29889,
23687,
29961,
29941,
5387,
13,
18884,
20881,
29889,
29894,
29918,
29891,
334,
29922,
448,
29896,
13,
13,
1678,
822,
679,
29918,
24713,
29898,
1311,
29892,
18593,
29922,
8516,
29892,
2910,
29918,
2311,
29922,
8516,
1125,
29871,
396,
2159,
297,
27881,
13,
13,
4706,
1583,
29889,
24713,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
1311,
29889,
24713,
29889,
5727,
29892,
1583,
29889,
24713,
29889,
22724,
876,
13,
13,
4706,
363,
20881,
297,
1583,
29889,
711,
303,
23435,
29901,
13,
9651,
1583,
29889,
24713,
29889,
1958,
353,
788,
29918,
711,
303,
6436,
29898,
13,
18884,
679,
29918,
5064,
29898,
26290,
29889,
29916,
29892,
20881,
29889,
29891,
29892,
1583,
29889,
24713,
511,
13,
18884,
679,
29918,
6229,
29898,
26290,
29889,
2311,
29961,
29900,
1402,
20881,
29889,
2311,
29961,
29896,
1402,
1583,
29889,
24713,
511,
13,
18884,
1583,
29889,
24713,
29889,
1958,
29892,
13,
9651,
1723,
13,
13,
4706,
565,
18593,
338,
6213,
470,
2910,
29918,
2311,
338,
6213,
29901,
13,
9651,
736,
1583,
29889,
24713,
13,
13,
4706,
5694,
29918,
24713,
353,
13373,
24541,
580,
13,
4706,
5694,
29918,
24713,
29889,
12574,
29918,
29916,
353,
18593,
29961,
29900,
29962,
448,
5785,
29898,
1958,
29918,
2311,
29961,
29900,
2314,
847,
29871,
29906,
29889,
29900,
13,
4706,
5694,
29918,
24713,
29889,
12574,
29918,
29891,
353,
18593,
29961,
29896,
29962,
448,
5785,
29898,
1958,
29918,
2311,
29961,
29896,
2314,
847,
29871,
29906,
29889,
29900,
13,
4706,
5694,
29918,
24713,
29889,
3729,
29918,
2311,
353,
1583,
29889,
24713,
29889,
3729,
29918,
2311,
13,
13,
4706,
5224,
29918,
1563,
353,
679,
29918,
5064,
29898,
13,
9651,
5694,
29918,
24713,
29889,
12574,
29918,
29916,
29892,
5694,
29918,
24713,
29889,
12574,
29918,
29891,
29892,
1583,
29889,
24713,
13,
4706,
1723,
13,
13,
4706,
565,
5224,
29918,
1563,
29961,
29900,
29962,
529,
29871,
29900,
29901,
13,
9651,
5224,
29918,
1563,
29961,
29900,
29962,
353,
29871,
29900,
13,
9651,
5694,
29918,
24713,
29889,
12574,
29918,
29891,
353,
1583,
29889,
24713,
29889,
12574,
29918,
29891,
13,
13,
4706,
565,
5224,
29918,
1563,
29961,
29896,
29962,
529,
29871,
29900,
29901,
13,
9651,
5224,
29918,
1563,
29961,
29896,
29962,
353,
29871,
29900,
13,
9651,
5694,
29918,
24713,
29889,
12574,
29918,
29916,
353,
1583,
29889,
24713,
29889,
12574,
29918,
29916,
13,
13,
4706,
7568,
29918,
1266,
353,
679,
29918,
5064,
29898,
13,
9651,
18593,
29961,
29900,
29962,
718,
5785,
29898,
1958,
29918,
2311,
29961,
29900,
2314,
847,
29871,
29906,
29889,
29900,
29892,
13,
9651,
18593,
29961,
29896,
29962,
718,
5785,
29898,
1958,
29918,
2311,
29961,
29896,
2314,
847,
29871,
29906,
29889,
29900,
29892,
13,
9651,
1583,
29889,
24713,
29892,
13,
4706,
1723,
13,
13,
4706,
565,
7568,
29918,
1266,
29961,
29900,
29962,
6736,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29900,
5387,
13,
9651,
7568,
29918,
1266,
29961,
29900,
29962,
353,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29900,
29962,
448,
29871,
29896,
13,
13,
4706,
565,
7568,
29918,
1266,
29961,
29896,
29962,
6736,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29896,
5387,
13,
9651,
7568,
29918,
1266,
29961,
29896,
29962,
353,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29896,
29962,
448,
29871,
29896,
13,
13,
4706,
565,
313,
13,
9651,
7568,
29918,
1266,
29961,
29900,
29962,
529,
29871,
29900,
13,
9651,
470,
7568,
29918,
1266,
29961,
29896,
29962,
529,
29871,
29900,
13,
9651,
470,
5224,
29918,
1563,
29961,
29900,
29962,
6736,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29900,
29962,
13,
9651,
470,
5224,
29918,
1563,
29961,
29896,
29962,
6736,
1583,
29889,
24713,
29889,
1958,
29889,
12181,
29961,
29896,
29962,
13,
308,
1125,
13,
9651,
5694,
29918,
24713,
29889,
1958,
353,
7442,
29889,
3298,
359,
3552,
29945,
29892,
29871,
29945,
876,
29871,
396,
777,
2910,
310,
24786,
13,
4706,
1683,
29901,
13,
9651,
5694,
29918,
24713,
29889,
1958,
353,
1583,
29889,
24713,
29889,
1958,
29961,
13,
18884,
5224,
29918,
1563,
29961,
29900,
29962,
584,
7568,
29918,
1266,
29961,
29900,
29962,
718,
29871,
29896,
29892,
5224,
29918,
1563,
29961,
29896,
29962,
584,
7568,
29918,
1266,
29961,
29896,
29962,
718,
29871,
29896,
13,
9651,
4514,
13,
13,
4706,
5694,
29918,
24713,
29889,
5727,
353,
5694,
29918,
24713,
29889,
1958,
29889,
12181,
29961,
29900,
29962,
13,
4706,
5694,
29918,
24713,
29889,
22724,
353,
5694,
29918,
24713,
29889,
1958,
29889,
12181,
29961,
29896,
29962,
13,
4706,
736,
5694,
29918,
24713,
13,
13,
2
] |
EvalEmbeddings.py | satyarth934/SpaceForceDataSearch | 1 | 178128 | import scann
from argparse import ArgumentParser
from pl_bolts.models.self_supervised import SimCLR
from pl_bolts.models.self_supervised.resnets import resnet18
from pl_bolts.models.self_supervised.simclr.transforms import SimCLREvalDataTransform, SimCLRTrainDataTransform
from pathlib import Path
import torch
import os
import time
import random
import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix
import seaborn as sn
import h5py
import numpy as np
import pandas as pd
from tqdm import tqdm
from sklearn.metrics import f1_score, accuracy_score
#imports from internal
from CustomDataset import FolderDataset
from SSLTrainer import Projection
def eval_embeddings(model, dataset, save_path, rank_to, filter_hur):
if filter_hur:
rank_to = rank_to*4
model.eval()
embeddings_matrix = torch.empty((0, 512)).cuda()
for batch in tqdm(dataset):
#this mirrors shared_step
(image, im1, _), y = batch
with torch.no_grad():
image = torch.unsqueeze(image, 0)
image = image.cuda()
h1 = model(image)
embedding = h1
embeddings_matrix = torch.cat((embeddings_matrix, embedding))
embeddings_test = embeddings_matrix.cpu().numpy()
if os.path.exists('data.h5'):
os.remove('data.h5')
f = h5py.File('data.h5', 'w')
f.create_dataset("embeddings", data=embeddings_test)
dataset_scann = f['embeddings']
normalized_dataset = dataset_scann / np.linalg.norm(dataset_scann, axis=1)[:, np.newaxis]
searcher = scann.scann_ops_pybind.builder(normalized_dataset, rank_to, "dot_product").tree(num_leaves = int(np.sqrt(len(dataset_scann))), num_leaves_to_search = 10).score_brute_force().build()
neighbors, distances = searcher.search_batched(normalized_dataset)
#gets label for each image by index
def labelLookup(index):
return dataset.labels[index]
lookup = np.vectorize(labelLookup)
result_array = lookup(neighbors)
###
def same_hurricane(reference_idx, neighbor_idx):
hur = dataset.dirs[reference_idx].split('/')[-1].split('_')[0]
hur2 = dataset.dirs[neighbor_idx].split('/')[-1].split('_')[0]
return hur == hur2
if filter_hur:
mask = np.empty((0, neighbors.shape[1]))
same_hur = np.vectorize(same_hurricane)
for row in neighbors:
mask = np.vstack((mask, same_hur(row, row[0])))
mask = mask.astype(bool)
temp_res = np.empty((0, int(rank_to/4)))
#goes through each row
for i in range(result_array.shape[0]):
row = result_array[i]
msk = mask[i]
row_slice = row[~msk]
row_slice = np.insert(row_slice, 0, row[0])
if len(row_slice) < rank_to/4:
row_slice = np.append(row_slice, np.full((int(rank_to/4) - len(row_slice)), -1))
else:
row_slice = row_slice[:int(rank_to/4)]
temp_res = np.vstack((temp_res, row_slice))
result_array = temp_res
neighbor_rank = 1
array = confusion_matrix(result_array[:,0], result_array[:,neighbor_rank], normalize='true')
for i, r in enumerate(array):
acc_row = r[i]/ sum(r)
v = len(array)
df_cm = pd.DataFrame(array, range(v), range(v))
plt.figure(figsize=(10,7))
plt.title('Rank 1 on embeddings using validation transform')
sn.set(font_scale=0.5) # for label size
res = sn.heatmap(df_cm, annot=True, annot_kws={"size": 6}) # font size
figure = res.get_figure()
figure.savefig(f'{save_path}/rank1_NN_heatmap.png', dpi=400)
plt.clf()
plt.cla()
reference_image_classes = result_array[:, 0]
accs_by_rank = []
ncols = result_array.shape[1]
nrows = result_array.shape[0]
for i in range(1, ncols):
accs_by_rank.append(np.sum(reference_image_classes == result_array[:, i])/nrows)
plt.rc('ytick', labelsize=10)
plt.plot(range(1, ncols), accs_by_rank)
plt.xlabel('Nearest Neighbor Rank')
plt.ylabel('Percent in Reference Image Class')
plt.title('SimCLR (All Data) Similarity Searching')
plt.savefig(f'{save_path}/NN_acc_by_rank.png', dpi=400)
plt.clf()
plt.cla()
def accs_list(g):
f1s = []
for col in g.columns[1:]:
f1s.append(accuracy_score(g['neighbor_0'], g[col]))
return f1s
labels_df = pd.DataFrame(result_array, columns = ['neighbor_'+ str(x) for x in range(ncols)])
gp = labels_df.groupby('neighbor_0', group_keys = True)
k = list(gp.groups.keys())
inv_map = {v: k for k, v in dataset.mydict.items()}
for i, arr in enumerate(gp.apply(accs_list)):
plt.plot(range(1,ncols), arr, label = inv_map[k[i]+1])
plt.legend()
plt.xlabel('Nearest Neighbor Rank')
plt.ylabel('Percent in Reference Image Class')
plt.savefig(f'{save_path}/NN_acc_by_class_and_rank.png', dpi=400)
if os.path.exists('data.h5'):
os.remove('data.h5')
def cli_main():
parser = ArgumentParser()
parser.add_argument("--MODEL_PATH", type=str, help="path to .pt file containing SSL-trained SimCLR Resnet18 Model")
parser.add_argument("--DATA_PATH", type = str, help = "path to data. If folder already contains validation data only, set val_split to 0")
parser.add_argument("--val_split", default = 0.2, type = float, help = "amount of data to use for validation as a decimal")
parser.add_argument("--image_type", default="tif", type=str, help="extension of image for PIL to open and parse - i.e. jpeg, gif, tif, etc. Only put the extension name, not the dot (.)")
parser.add_argument("--image_embedding_size", default=128, type=int, help="size of image representation of SIMCLR")
parser.add_argument("--image_size", default = 128, type=int, help="height of square image to pass through model")
parser.add_argument("--gpus", default=1, type=int, help="number of gpus to use for training")
parser.add_argument("--rank", default=50, type=int, help="number of neighbors to search for")
parser.add_argument("--filter_same_group", default= False, type=bool, help="custom arg for hurricane data to filter same hurricanes out")
args = parser.parse_args()
MODEL_PATH = args.MODEL_PATH
DATA_PATH = args.DATA_PATH
image_size = args.image_size
image_type = args.image_type
embedding_size = args.image_embedding_size
val_split = args.val_split
gpus = args.gpus
rank_to = args.rank
filter_hur = args.filter_same_group
#testing
# MODEL_PATH = '/content/models/SSL/SIMCLR_SSL_0.pt'
# DATA_PATH = '/content/UCMerced_LandUse/Images'
# image_size = 128
# image_type = 'tif'
# embedding_size = 128
# val_split = 0.2
# gpus = 1
# #gets dataset. We can't combine since validation data has different transform needed
train_dataset = FolderDataset(DATA_PATH, validation = False,
val_split = val_split,
transform = SimCLRTrainDataTransform(image_size),
image_type = image_type
)
print('Training Data Loaded...')
val_dataset = FolderDataset(DATA_PATH, validation = True,
val_split = val_split,
transform = SimCLREvalDataTransform(image_size),
image_type = image_type
)
print('Validation Data Loaded...')
#load model
num_samples = len(train_dataset)
#init model with batch size, num_samples (len of data), epochs to train, and autofinds learning rate
model = SimCLR(arch = 'resnet18', batch_size = 1, num_samples = num_samples, gpus = gpus, dataset = 'None') #
model.encoder = resnet18(pretrained=False, first_conv=model.first_conv, maxpool1=model.maxpool1, return_all_feature_maps=False)
model.projection = Projection(input_dim = 512, hidden_dim = 256, output_dim = embedding_size) #overrides
model.load_state_dict(torch.load(MODEL_PATH))
model.cuda()
print('Successfully loaded your model for evaluation.')
#running eval on validation data
save_path = f"{MODEL_PATH[:-3]}/Evaluation/validationMetrics"
Path(save_path).mkdir(parents=True, exist_ok=True)
eval_embeddings(model, val_dataset, save_path, rank_to, filter_hur)
print('Validation Data Evaluation Complete.')
#running eval on training data
save_path = f"{MODEL_PATH[:-3]}/Evaluation/trainingMetrics"
Path(save_path).mkdir(parents=True, exist_ok=True)
eval_embeddings(model, train_dataset, save_path, rank_to, filter_hur)
print('Training Data Evaluation Complete.')
print(f'Please check {MODEL_PATH[:-3]}/Evaluation/ for your results')
if __name__ == '__main__':
cli_main()
| [
1,
1053,
885,
812,
13,
3166,
1852,
5510,
1053,
23125,
11726,
13,
3166,
715,
29918,
2095,
1372,
29889,
9794,
29889,
1311,
29918,
9136,
11292,
1053,
3439,
6154,
29934,
13,
3166,
715,
29918,
2095,
1372,
29889,
9794,
29889,
1311,
29918,
9136,
11292,
29889,
690,
1212,
29879,
1053,
620,
1212,
29896,
29947,
13,
3166,
715,
29918,
2095,
1372,
29889,
9794,
29889,
1311,
29918,
9136,
11292,
29889,
3601,
695,
29878,
29889,
9067,
29879,
1053,
3439,
6154,
1525,
791,
1469,
13372,
29892,
3439,
6154,
29934,
5323,
262,
1469,
13372,
13,
3166,
2224,
1982,
1053,
10802,
13,
5215,
4842,
305,
13,
5215,
2897,
13,
13,
5215,
931,
13,
5215,
4036,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
3166,
2071,
19668,
29889,
2527,
10817,
1053,
14679,
29918,
5344,
13,
5215,
409,
370,
1398,
408,
5807,
13,
5215,
298,
29945,
2272,
13,
5215,
12655,
408,
7442,
13,
5215,
11701,
408,
10518,
13,
3166,
260,
29939,
18933,
1053,
260,
29939,
18933,
13,
3166,
2071,
19668,
29889,
2527,
10817,
1053,
285,
29896,
29918,
13628,
29892,
13600,
29918,
13628,
13,
13,
29937,
326,
4011,
515,
7463,
13,
3166,
8701,
16390,
24541,
1053,
383,
3194,
16390,
24541,
13,
3166,
17122,
5323,
4983,
1053,
1019,
6929,
13,
13,
13,
1753,
19745,
29918,
17987,
29881,
886,
29898,
4299,
29892,
8783,
29892,
4078,
29918,
2084,
29892,
7115,
29918,
517,
29892,
4175,
29918,
29882,
332,
1125,
13,
29871,
565,
4175,
29918,
29882,
332,
29901,
13,
1678,
7115,
29918,
517,
353,
7115,
29918,
517,
29930,
29946,
13,
268,
13,
29871,
1904,
29889,
14513,
580,
13,
29871,
8297,
29881,
886,
29918,
5344,
353,
4842,
305,
29889,
6310,
3552,
29900,
29892,
29871,
29945,
29896,
29906,
8106,
29883,
6191,
580,
13,
29871,
363,
9853,
297,
260,
29939,
18933,
29898,
24713,
1125,
13,
418,
396,
1366,
19571,
29879,
7258,
29918,
10568,
13,
418,
313,
3027,
29892,
527,
29896,
29892,
903,
511,
343,
353,
9853,
13,
418,
411,
4842,
305,
29889,
1217,
29918,
5105,
7295,
13,
4706,
1967,
353,
4842,
305,
29889,
6948,
802,
29872,
911,
29898,
3027,
29892,
29871,
29900,
29897,
13,
4706,
1967,
353,
1967,
29889,
29883,
6191,
580,
13,
4706,
298,
29896,
353,
1904,
29898,
3027,
29897,
29871,
13,
4706,
23655,
353,
298,
29896,
13,
4706,
8297,
29881,
886,
29918,
5344,
353,
4842,
305,
29889,
4117,
3552,
17987,
29881,
886,
29918,
5344,
29892,
23655,
876,
13,
13,
29871,
8297,
29881,
886,
29918,
1688,
353,
8297,
29881,
886,
29918,
5344,
29889,
21970,
2141,
23749,
580,
13,
13,
29871,
565,
2897,
29889,
2084,
29889,
9933,
877,
1272,
29889,
29882,
29945,
29374,
13,
1678,
2897,
29889,
5992,
877,
1272,
29889,
29882,
29945,
1495,
13,
13,
29871,
285,
353,
298,
29945,
2272,
29889,
2283,
877,
1272,
29889,
29882,
29945,
742,
525,
29893,
1495,
13,
29871,
285,
29889,
3258,
29918,
24713,
703,
17987,
29881,
886,
613,
848,
29922,
17987,
29881,
886,
29918,
1688,
29897,
13,
29871,
8783,
29918,
1557,
812,
353,
285,
1839,
17987,
29881,
886,
2033,
13,
29871,
4226,
1891,
29918,
24713,
353,
8783,
29918,
1557,
812,
847,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
24713,
29918,
1557,
812,
29892,
9685,
29922,
29896,
29897,
7503,
29892,
7442,
29889,
1482,
8990,
29962,
13,
29871,
2740,
261,
353,
885,
812,
29889,
1557,
812,
29918,
3554,
29918,
2272,
5355,
29889,
16409,
29898,
8945,
1891,
29918,
24713,
29892,
7115,
29918,
517,
29892,
376,
6333,
29918,
4704,
2564,
8336,
29898,
1949,
29918,
280,
5989,
353,
938,
29898,
9302,
29889,
3676,
29898,
2435,
29898,
24713,
29918,
1557,
812,
876,
511,
954,
29918,
280,
5989,
29918,
517,
29918,
4478,
353,
29871,
29896,
29900,
467,
13628,
29918,
1182,
1082,
29918,
10118,
2141,
4282,
580,
29871,
13,
29871,
22092,
943,
29892,
24610,
353,
2740,
261,
29889,
4478,
29918,
16175,
287,
29898,
8945,
1891,
29918,
24713,
29897,
13,
13,
29871,
396,
20078,
3858,
363,
1269,
1967,
491,
2380,
13,
29871,
822,
3858,
14959,
786,
29898,
2248,
1125,
13,
1678,
736,
8783,
29889,
21134,
29961,
2248,
29962,
13,
13,
29871,
16280,
353,
7442,
29889,
8111,
675,
29898,
1643,
14959,
786,
29897,
13,
29871,
1121,
29918,
2378,
353,
16280,
29898,
484,
1141,
29890,
943,
29897,
13,
29871,
835,
13,
259,
13,
29871,
822,
1021,
29918,
29882,
1038,
26655,
29898,
5679,
29918,
13140,
29892,
12307,
29918,
13140,
1125,
13,
1678,
12166,
353,
8783,
29889,
3972,
29879,
29961,
5679,
29918,
13140,
1822,
5451,
11219,
1495,
14352,
29896,
1822,
5451,
877,
29918,
29861,
29900,
29962,
13,
1678,
12166,
29906,
353,
8783,
29889,
3972,
29879,
29961,
484,
1141,
4089,
29918,
13140,
1822,
5451,
11219,
1495,
14352,
29896,
1822,
5451,
877,
29918,
29861,
29900,
29962,
13,
1678,
736,
12166,
1275,
12166,
29906,
29871,
13,
13,
29871,
565,
4175,
29918,
29882,
332,
29901,
13,
1678,
11105,
353,
7442,
29889,
6310,
3552,
29900,
29892,
22092,
943,
29889,
12181,
29961,
29896,
12622,
13,
1678,
1021,
29918,
29882,
332,
353,
7442,
29889,
8111,
675,
29898,
17642,
29918,
29882,
1038,
26655,
29897,
13,
13,
1678,
363,
1948,
297,
22092,
943,
29901,
13,
418,
11105,
353,
7442,
29889,
29894,
1429,
3552,
13168,
29892,
1021,
29918,
29882,
332,
29898,
798,
29892,
1948,
29961,
29900,
29962,
4961,
13,
1678,
11105,
353,
11105,
29889,
579,
668,
29898,
11227,
29897,
13,
13,
1678,
5694,
29918,
690,
353,
7442,
29889,
6310,
3552,
29900,
29892,
938,
29898,
10003,
29918,
517,
29914,
29946,
4961,
13,
1678,
396,
1484,
267,
1549,
1269,
1948,
13,
1678,
363,
474,
297,
3464,
29898,
2914,
29918,
2378,
29889,
12181,
29961,
29900,
29962,
1125,
13,
418,
1948,
353,
1121,
29918,
2378,
29961,
29875,
29962,
13,
418,
286,
808,
353,
11105,
29961,
29875,
29962,
13,
418,
1948,
29918,
18337,
353,
1948,
29961,
30022,
29885,
808,
29962,
13,
418,
1948,
29918,
18337,
353,
7442,
29889,
7851,
29898,
798,
29918,
18337,
29892,
29871,
29900,
29892,
1948,
29961,
29900,
2314,
13,
418,
565,
7431,
29898,
798,
29918,
18337,
29897,
529,
7115,
29918,
517,
29914,
29946,
29901,
13,
4706,
1948,
29918,
18337,
353,
7442,
29889,
4397,
29898,
798,
29918,
18337,
29892,
7442,
29889,
8159,
3552,
524,
29898,
10003,
29918,
517,
29914,
29946,
29897,
448,
7431,
29898,
798,
29918,
18337,
8243,
448,
29896,
876,
13,
418,
1683,
29901,
13,
4706,
1948,
29918,
18337,
353,
1948,
29918,
18337,
7503,
524,
29898,
10003,
29918,
517,
29914,
29946,
4638,
13,
418,
5694,
29918,
690,
353,
7442,
29889,
29894,
1429,
3552,
7382,
29918,
690,
29892,
1948,
29918,
18337,
876,
13,
1678,
1121,
29918,
2378,
353,
5694,
29918,
690,
13,
268,
13,
29871,
12307,
29918,
10003,
353,
29871,
29896,
13,
13,
29871,
1409,
353,
14679,
29918,
5344,
29898,
2914,
29918,
2378,
7503,
29892,
29900,
1402,
1121,
29918,
2378,
7503,
29892,
484,
1141,
4089,
29918,
10003,
1402,
4226,
675,
2433,
3009,
1495,
13,
29871,
363,
474,
29892,
364,
297,
26985,
29898,
2378,
1125,
13,
1678,
1035,
29918,
798,
353,
364,
29961,
29875,
16261,
2533,
29898,
29878,
29897,
13,
13,
29871,
325,
353,
7431,
29898,
2378,
29897,
13,
29871,
4489,
29918,
4912,
353,
10518,
29889,
17271,
29898,
2378,
29892,
3464,
29898,
29894,
511,
3464,
29898,
29894,
876,
13,
29871,
14770,
29889,
4532,
29898,
1003,
2311,
7607,
29896,
29900,
29892,
29955,
876,
13,
29871,
14770,
29889,
3257,
877,
29934,
804,
29871,
29896,
373,
8297,
29881,
886,
773,
8845,
4327,
1495,
13,
29871,
5807,
29889,
842,
29898,
5657,
29918,
7052,
29922,
29900,
29889,
29945,
29897,
396,
363,
3858,
2159,
13,
29871,
620,
353,
5807,
29889,
354,
271,
1958,
29898,
2176,
29918,
4912,
29892,
9732,
29922,
5574,
29892,
9732,
29918,
29895,
5652,
3790,
29908,
2311,
1115,
29871,
29953,
1800,
396,
4079,
2159,
13,
29871,
4377,
353,
620,
29889,
657,
29918,
4532,
580,
268,
13,
29871,
4377,
29889,
7620,
1003,
29898,
29888,
29915,
29912,
7620,
29918,
2084,
6822,
10003,
29896,
29918,
10262,
29918,
354,
271,
1958,
29889,
2732,
742,
270,
1631,
29922,
29946,
29900,
29900,
29897,
13,
29871,
14770,
29889,
695,
29888,
580,
13,
29871,
14770,
29889,
16398,
580,
13,
29871,
3407,
29918,
3027,
29918,
13203,
353,
1121,
29918,
2378,
7503,
29892,
29871,
29900,
29962,
13,
29871,
1035,
29879,
29918,
1609,
29918,
10003,
353,
5159,
13,
29871,
302,
22724,
353,
1121,
29918,
2378,
29889,
12181,
29961,
29896,
29962,
13,
29871,
302,
5727,
353,
1121,
29918,
2378,
29889,
12181,
29961,
29900,
29962,
13,
13,
13,
29871,
363,
474,
297,
3464,
29898,
29896,
29892,
302,
22724,
1125,
13,
1678,
1035,
29879,
29918,
1609,
29918,
10003,
29889,
4397,
29898,
9302,
29889,
2083,
29898,
5679,
29918,
3027,
29918,
13203,
1275,
1121,
29918,
2378,
7503,
29892,
474,
2314,
29914,
29876,
5727,
29897,
13,
13,
29871,
14770,
29889,
2214,
877,
3637,
860,
742,
3858,
2311,
29922,
29896,
29900,
29897,
13,
29871,
14770,
29889,
5317,
29898,
3881,
29898,
29896,
29892,
302,
22724,
511,
1035,
29879,
29918,
1609,
29918,
10003,
29897,
13,
29871,
14770,
29889,
29916,
1643,
877,
29940,
799,
342,
2448,
1141,
4089,
22125,
1495,
13,
29871,
14770,
29889,
29891,
1643,
877,
27933,
297,
12105,
7084,
4134,
1495,
13,
29871,
14770,
29889,
3257,
877,
8942,
6154,
29934,
313,
3596,
3630,
29897,
13999,
537,
11856,
292,
1495,
13,
29871,
14770,
29889,
7620,
1003,
29898,
29888,
29915,
29912,
7620,
29918,
2084,
6822,
10262,
29918,
5753,
29918,
1609,
29918,
10003,
29889,
2732,
742,
270,
1631,
29922,
29946,
29900,
29900,
29897,
13,
259,
13,
29871,
14770,
29889,
695,
29888,
580,
13,
29871,
14770,
29889,
16398,
580,
13,
259,
13,
29871,
822,
1035,
29879,
29918,
1761,
29898,
29887,
1125,
13,
1678,
285,
29896,
29879,
353,
5159,
13,
1678,
363,
784,
297,
330,
29889,
13099,
29961,
29896,
29901,
5387,
13,
418,
285,
29896,
29879,
29889,
4397,
29898,
562,
2764,
4135,
29918,
13628,
29898,
29887,
1839,
484,
1141,
4089,
29918,
29900,
7464,
330,
29961,
1054,
12622,
13,
1678,
736,
285,
29896,
29879,
13,
268,
13,
29871,
11073,
29918,
2176,
353,
10518,
29889,
17271,
29898,
2914,
29918,
2378,
29892,
4341,
353,
6024,
484,
1141,
4089,
29918,
18717,
851,
29898,
29916,
29897,
363,
921,
297,
3464,
29898,
29876,
22724,
29897,
2314,
13,
29871,
330,
29886,
353,
11073,
29918,
2176,
29889,
27789,
877,
484,
1141,
4089,
29918,
29900,
742,
2318,
29918,
8149,
353,
5852,
29897,
259,
13,
29871,
413,
353,
1051,
29898,
29887,
29886,
29889,
13155,
29889,
8149,
3101,
13,
29871,
2437,
29918,
1958,
353,
426,
29894,
29901,
413,
363,
413,
29892,
325,
297,
8783,
29889,
1357,
8977,
29889,
7076,
28296,
13,
259,
13,
29871,
363,
474,
29892,
3948,
297,
26985,
29898,
29887,
29886,
29889,
7302,
29898,
562,
2395,
29918,
1761,
22164,
13,
268,
13,
1678,
14770,
29889,
5317,
29898,
3881,
29898,
29896,
29892,
29876,
22724,
511,
3948,
29892,
3858,
353,
2437,
29918,
1958,
29961,
29895,
29961,
29875,
10062,
29896,
2314,
13,
268,
13,
29871,
14770,
29889,
26172,
580,
13,
29871,
14770,
29889,
29916,
1643,
877,
29940,
799,
342,
2448,
1141,
4089,
22125,
1495,
13,
29871,
14770,
29889,
29891,
1643,
877,
27933,
297,
12105,
7084,
4134,
1495,
13,
29871,
14770,
29889,
7620,
1003,
29898,
29888,
29915,
29912,
7620,
29918,
2084,
6822,
10262,
29918,
5753,
29918,
1609,
29918,
1990,
29918,
392,
29918,
10003,
29889,
2732,
742,
270,
1631,
29922,
29946,
29900,
29900,
29897,
13,
13,
13,
29871,
565,
2897,
29889,
2084,
29889,
9933,
877,
1272,
29889,
29882,
29945,
29374,
13,
418,
2897,
29889,
5992,
877,
1272,
29889,
29882,
29945,
1495,
13,
13,
1753,
9335,
29918,
3396,
7295,
13,
268,
13,
1678,
13812,
353,
23125,
11726,
580,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
20387,
29931,
29918,
10145,
613,
1134,
29922,
710,
29892,
1371,
543,
2084,
304,
869,
415,
934,
6943,
17122,
29899,
3018,
1312,
3439,
6154,
29934,
2538,
1212,
29896,
29947,
8125,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
14573,
29918,
10145,
613,
1134,
353,
851,
29892,
1371,
353,
376,
2084,
304,
848,
29889,
960,
4138,
2307,
3743,
8845,
848,
871,
29892,
731,
659,
29918,
5451,
304,
29871,
29900,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
791,
29918,
5451,
613,
2322,
353,
29871,
29900,
29889,
29906,
29892,
1134,
353,
5785,
29892,
1371,
353,
376,
14506,
310,
848,
304,
671,
363,
8845,
408,
263,
13677,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
3027,
29918,
1853,
613,
2322,
543,
29873,
361,
613,
1134,
29922,
710,
29892,
1371,
543,
17588,
310,
1967,
363,
349,
6227,
304,
1722,
322,
6088,
448,
474,
29889,
29872,
29889,
432,
29886,
387,
29892,
330,
361,
29892,
260,
361,
29892,
2992,
29889,
9333,
1925,
278,
6081,
1024,
29892,
451,
278,
8329,
313,
1846,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
3027,
29918,
17987,
8497,
29918,
2311,
613,
2322,
29922,
29896,
29906,
29947,
29892,
1134,
29922,
524,
29892,
1371,
543,
2311,
310,
1967,
8954,
310,
317,
7833,
6154,
29934,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
3027,
29918,
2311,
613,
2322,
353,
29871,
29896,
29906,
29947,
29892,
1134,
29922,
524,
29892,
1371,
543,
3545,
310,
6862,
1967,
304,
1209,
1549,
1904,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
29887,
13364,
613,
2322,
29922,
29896,
29892,
1134,
29922,
524,
29892,
1371,
543,
4537,
310,
330,
13364,
304,
671,
363,
6694,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
10003,
613,
2322,
29922,
29945,
29900,
29892,
1134,
29922,
524,
29892,
1371,
543,
4537,
310,
22092,
943,
304,
2740,
363,
1159,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
489,
4572,
29918,
17642,
29918,
2972,
613,
2322,
29922,
7700,
29892,
1134,
29922,
11227,
29892,
1371,
543,
6341,
1852,
363,
298,
1038,
26655,
848,
304,
4175,
1021,
298,
1038,
2185,
267,
714,
1159,
13,
268,
13,
1678,
6389,
353,
13812,
29889,
5510,
29918,
5085,
580,
13,
1678,
16999,
2287,
29931,
29918,
10145,
353,
6389,
29889,
20387,
29931,
29918,
10145,
13,
1678,
360,
8254,
29918,
10145,
353,
6389,
29889,
14573,
29918,
10145,
13,
1678,
1967,
29918,
2311,
353,
6389,
29889,
3027,
29918,
2311,
13,
1678,
1967,
29918,
1853,
353,
6389,
29889,
3027,
29918,
1853,
13,
1678,
23655,
29918,
2311,
353,
6389,
29889,
3027,
29918,
17987,
8497,
29918,
2311,
13,
1678,
659,
29918,
5451,
353,
6389,
29889,
791,
29918,
5451,
13,
1678,
330,
13364,
353,
6389,
29889,
29887,
13364,
13,
1678,
7115,
29918,
517,
353,
6389,
29889,
10003,
13,
1678,
4175,
29918,
29882,
332,
353,
6389,
29889,
4572,
29918,
17642,
29918,
2972,
13,
268,
13,
1678,
396,
13424,
13,
1678,
396,
16999,
2287,
29931,
29918,
10145,
353,
8207,
3051,
29914,
9794,
29914,
18641,
29914,
5425,
29924,
6154,
29934,
29918,
18641,
29918,
29900,
29889,
415,
29915,
13,
1678,
396,
360,
8254,
29918,
10145,
353,
8207,
3051,
29914,
23129,
15836,
1133,
29918,
22677,
11403,
29914,
20163,
29915,
13,
1678,
396,
1967,
29918,
2311,
353,
29871,
29896,
29906,
29947,
13,
1678,
396,
1967,
29918,
1853,
353,
525,
29873,
361,
29915,
13,
1678,
396,
23655,
29918,
2311,
353,
29871,
29896,
29906,
29947,
13,
1678,
396,
659,
29918,
5451,
353,
29871,
29900,
29889,
29906,
13,
1678,
396,
330,
13364,
353,
29871,
29896,
13,
13,
268,
13,
13,
4706,
396,
396,
20078,
8783,
29889,
1334,
508,
29915,
29873,
14405,
1951,
8845,
848,
756,
1422,
4327,
4312,
13,
1678,
7945,
29918,
24713,
353,
383,
3194,
16390,
24541,
29898,
14573,
29918,
10145,
29892,
8845,
353,
7700,
29892,
29871,
13,
462,
462,
29871,
659,
29918,
5451,
353,
659,
29918,
5451,
29892,
29871,
13,
462,
462,
29871,
4327,
353,
3439,
6154,
29934,
5323,
262,
1469,
13372,
29898,
3027,
29918,
2311,
511,
29871,
13,
462,
462,
29871,
1967,
29918,
1853,
353,
1967,
29918,
1853,
13,
462,
462,
29871,
1723,
29871,
13,
268,
13,
13,
13,
1678,
1596,
877,
5323,
2827,
3630,
4309,
11932,
856,
1495,
13,
1678,
659,
29918,
24713,
353,
383,
3194,
16390,
24541,
29898,
14573,
29918,
10145,
29892,
8845,
353,
5852,
29892,
13,
462,
18884,
659,
29918,
5451,
353,
659,
29918,
5451,
29892,
13,
462,
18884,
4327,
353,
3439,
6154,
1525,
791,
1469,
13372,
29898,
3027,
29918,
2311,
511,
13,
462,
18884,
1967,
29918,
1853,
353,
1967,
29918,
1853,
13,
462,
18884,
1723,
13,
268,
13,
13,
1678,
1596,
877,
19448,
3630,
4309,
11932,
856,
1495,
13,
13,
1678,
396,
1359,
1904,
13,
1678,
954,
29918,
27736,
353,
7431,
29898,
14968,
29918,
24713,
29897,
13,
13,
1678,
396,
2344,
1904,
411,
9853,
2159,
29892,
954,
29918,
27736,
313,
2435,
310,
848,
511,
21502,
12168,
304,
7945,
29892,
322,
1120,
974,
12772,
6509,
6554,
13,
1678,
1904,
353,
3439,
6154,
29934,
29898,
1279,
353,
525,
690,
1212,
29896,
29947,
742,
9853,
29918,
2311,
353,
29871,
29896,
29892,
954,
29918,
27736,
353,
954,
29918,
27736,
29892,
330,
13364,
353,
330,
13364,
29892,
8783,
353,
525,
8516,
1495,
396,
13,
268,
13,
1678,
1904,
29889,
3977,
6119,
353,
620,
1212,
29896,
29947,
29898,
1457,
3018,
1312,
29922,
8824,
29892,
937,
29918,
20580,
29922,
4299,
29889,
4102,
29918,
20580,
29892,
4236,
10109,
29896,
29922,
4299,
29889,
3317,
10109,
29896,
29892,
736,
29918,
497,
29918,
14394,
29918,
10339,
29922,
8824,
29897,
13,
1678,
1904,
29889,
771,
6929,
353,
1019,
6929,
29898,
2080,
29918,
6229,
353,
29871,
29945,
29896,
29906,
29892,
7934,
29918,
6229,
353,
29871,
29906,
29945,
29953,
29892,
1962,
29918,
6229,
353,
23655,
29918,
2311,
29897,
396,
957,
24040,
13,
13,
1678,
1904,
29889,
1359,
29918,
3859,
29918,
8977,
29898,
7345,
305,
29889,
1359,
29898,
20387,
29931,
29918,
10145,
876,
13,
268,
13,
13,
1678,
1904,
29889,
29883,
6191,
580,
13,
1678,
1596,
877,
14191,
3730,
7500,
596,
1904,
363,
17983,
29889,
1495,
13,
268,
13,
1678,
396,
21094,
19745,
373,
8845,
848,
13,
1678,
4078,
29918,
2084,
353,
285,
29908,
29912,
20387,
29931,
29918,
10145,
7503,
29899,
29941,
29962,
6822,
29923,
4387,
362,
29914,
18157,
10095,
10817,
29908,
13,
1678,
10802,
29898,
7620,
29918,
2084,
467,
11256,
3972,
29898,
862,
1237,
29922,
5574,
29892,
1863,
29918,
554,
29922,
5574,
29897,
13,
1678,
19745,
29918,
17987,
29881,
886,
29898,
4299,
29892,
659,
29918,
24713,
29892,
4078,
29918,
2084,
29892,
7115,
29918,
517,
29892,
4175,
29918,
29882,
332,
29897,
13,
1678,
1596,
877,
19448,
3630,
382,
4387,
362,
25034,
29889,
1495,
13,
268,
13,
1678,
396,
21094,
19745,
373,
6694,
848,
13,
1678,
4078,
29918,
2084,
353,
285,
29908,
29912,
20387,
29931,
29918,
10145,
7503,
29899,
29941,
29962,
6822,
29923,
4387,
362,
29914,
26495,
10095,
10817,
29908,
13,
1678,
10802,
29898,
7620,
29918,
2084,
467,
11256,
3972,
29898,
862,
1237,
29922,
5574,
29892,
1863,
29918,
554,
29922,
5574,
29897,
13,
1678,
19745,
29918,
17987,
29881,
886,
29898,
4299,
29892,
7945,
29918,
24713,
29892,
4078,
29918,
2084,
29892,
7115,
29918,
517,
29892,
4175,
29918,
29882,
332,
29897,
13,
1678,
1596,
877,
5323,
2827,
3630,
382,
4387,
362,
25034,
29889,
1495,
13,
1678,
13,
1678,
1596,
29898,
29888,
29915,
12148,
1423,
426,
20387,
29931,
29918,
10145,
7503,
29899,
29941,
29962,
6822,
29923,
4387,
362,
29914,
363,
596,
2582,
1495,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
9335,
29918,
3396,
580,
13,
2
] |
Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/lms/djangoapps/grades/course_grade.py | osoco/better-ways-of-thinking-about-software | 3 | 28320 | <reponame>osoco/better-ways-of-thinking-about-software
"""
CourseGrade Class
"""
from abc import abstractmethod
from collections import OrderedDict, defaultdict
from ccx_keys.locator import CCXLocator
from django.conf import settings
from lazy import lazy
from openedx.core.lib.grade_utils import round_away_from_zero
from xmodule import block_metadata_utils
from .config import assume_zero_if_absent
from .scores import compute_percent
from .subsection_grade import ZeroSubsectionGrade
from .subsection_grade_factory import SubsectionGradeFactory
class CourseGradeBase:
"""
Base class for Course Grades.
"""
def __init__(self, user, course_data, percent=0.0, letter_grade=None, passed=False, force_update_subsections=False):
self.user = user
self.course_data = course_data
self.percent = percent
self.passed = passed
# Convert empty strings to None when reading from the table
self.letter_grade = letter_grade or None
self.force_update_subsections = force_update_subsections
def __str__(self):
return 'Course Grade: percent: {}, letter_grade: {}, passed: {}'.format(
str(self.percent),
self.letter_grade,
self.passed,
)
@property
def attempted(self):
"""
Returns whether at least one problem was attempted
by the user in the course.
"""
return False
def subsection_grade(self, subsection_key):
"""
Returns the subsection grade for the given subsection usage key.
Raises `KeyError` if the course structure does not contain the key.
If the course structure contains the key, this will always succeed
(and return a grade) regardless of whether the user can access that section;
it is up to the caller to ensure that the grade isn't
shown to users that shouldn't be able to access it
(e.g. a student shouldn't see a grade for an unreleased subsection);
"""
# look in the user structure first and fallback to the collected;
# however, we assume the state of course_data is intentional,
# so we use effective_structure to avoid additional fetching
subsection = (
self.course_data.effective_structure[subsection_key]
if subsection_key in self.course_data.effective_structure
else self.course_data.collected_structure[subsection_key]
)
return self._get_subsection_grade(subsection)
@lazy
def graded_subsections_by_format(self):
"""
Returns grades for the subsections in the course in
a dict keyed by subsection format types.
"""
subsections_by_format = defaultdict(OrderedDict)
for chapter in self.chapter_grades.values():
for subsection_grade in chapter['sections']:
if subsection_grade.graded:
graded_total = subsection_grade.graded_total
if graded_total.possible > 0:
subsections_by_format[subsection_grade.format][subsection_grade.location] = subsection_grade
return subsections_by_format
@lazy
def chapter_grades(self):
"""
Returns a dictionary of dictionaries.
The primary dictionary is keyed by the chapter's usage_key.
The secondary dictionary contains the chapter's
subsection grades, display name, and url name.
"""
course_structure = self.course_data.structure
grades = OrderedDict()
for chapter_key in course_structure.get_children(self.course_data.location):
grades[chapter_key] = self._get_chapter_grade_info(course_structure[chapter_key], course_structure)
return grades
@lazy
def subsection_grades(self):
"""
Returns an ordered dictionary of subsection grades,
keyed by subsection location.
"""
subsection_grades = defaultdict(OrderedDict)
for chapter in self.chapter_grades.values():
for subsection_grade in chapter['sections']:
subsection_grades[subsection_grade.location] = subsection_grade
return subsection_grades
@lazy
def problem_scores(self):
"""
Returns a dict of problem scores keyed by their locations.
"""
problem_scores = {}
for chapter in self.chapter_grades.values():
for subsection_grade in chapter['sections']:
problem_scores.update(subsection_grade.problem_scores)
return problem_scores
def chapter_percentage(self, chapter_key):
"""
Returns the rounded aggregate weighted percentage for the given chapter.
Raises:
KeyError if the chapter is not found.
"""
earned, possible = 0.0, 0.0
chapter_grade = self.chapter_grades[chapter_key]
for section in chapter_grade['sections']:
earned += section.graded_total.earned
possible += section.graded_total.possible
return compute_percent(earned, possible)
def score_for_module(self, location):
"""
Calculate the aggregate weighted score for any location in the course.
This method returns a tuple containing (earned_score, possible_score).
If the location is of 'problem' type, this method will return the
possible and earned scores for that problem. If the location refers to a
composite module (a vertical or section ) the scores will be the sums of
all scored problems that are children of the chosen location.
"""
if location in self.problem_scores:
score = self.problem_scores[location]
return score.earned, score.possible
children = self.course_data.structure.get_children(location)
earned, possible = 0.0, 0.0
for child in children:
child_earned, child_possible = self.score_for_module(child)
earned += child_earned
possible += child_possible
return earned, possible
@lazy
def grader_result(self):
"""
Returns the result from the course grader.
"""
course = self._prep_course_for_grading(self.course_data.course)
return course.grader.grade(
self.graded_subsections_by_format,
generate_random_scores=settings.GENERATE_PROFILE_SCORES,
)
@property
def summary(self):
"""
Returns the grade summary as calculated by the course's grader.
DEPRECATED: To be removed as part of TNL-5291.
"""
# TODO(TNL-5291) Remove usages of this deprecated property.
grade_summary = self.grader_result
grade_summary['percent'] = self.percent
grade_summary['grade'] = self.letter_grade
return grade_summary
@classmethod
def get_subsection_type_graders(cls, course):
"""
Returns a dictionary mapping subsection types to their
corresponding configured graders, per grading policy.
"""
course = cls._prep_course_for_grading(course)
return {
subsection_type: subsection_type_grader
for (subsection_type_grader, subsection_type, _)
in course.grader.subgraders
}
@classmethod
def _prep_course_for_grading(cls, course):
"""
Make sure any overrides to the grading policy are used.
This is most relevant for CCX courses.
Right now, we still access the grading policy from the course
object. Once we get the grading policy from the BlockStructure
this will no longer be needed - since BlockStructure correctly
retrieves/uses all field overrides.
"""
if isinstance(course.id, CCXLocator):
# clean out any field values that may have been set from the
# parent course of the CCX course.
course._field_data_cache = {} # pylint: disable=protected-access
# this is "magic" code that automatically retrieves any overrides
# to the grading policy and updates the course object.
course.set_grading_policy(course.grading_policy)
return course
def _get_chapter_grade_info(self, chapter, course_structure):
"""
Helper that returns a dictionary of chapter grade information.
"""
chapter_subsection_grades = self._get_subsection_grades(course_structure, chapter.location)
return {
'display_name': block_metadata_utils.display_name_with_default(chapter),
'url_name': block_metadata_utils.url_name_for_block(chapter),
'sections': chapter_subsection_grades,
}
def _get_subsection_grades(self, course_structure, chapter_key):
"""
Returns a list of subsection grades for the given chapter.
"""
return [
self._get_subsection_grade(course_structure[subsection_key], self.force_update_subsections)
for subsection_key in _uniqueify_and_keep_order(course_structure.get_children(chapter_key))
]
@abstractmethod
def _get_subsection_grade(self, subsection, force_update_subsections=False):
"""
Abstract method to be implemented by subclasses for returning
the grade of the given subsection.
"""
raise NotImplementedError
class ZeroCourseGrade(CourseGradeBase):
"""
Course Grade class for Zero-value grades when no problems were
attempted in the course.
"""
def _get_subsection_grade(self, subsection, force_update_subsections=False):
return ZeroSubsectionGrade(subsection, self.course_data)
class CourseGrade(CourseGradeBase):
"""
Course Grade class when grades are updated or read from storage.
"""
def __init__(self, user, course_data, *args, **kwargs):
super().__init__(user, course_data, *args, **kwargs)
self._subsection_grade_factory = SubsectionGradeFactory(user, course_data=course_data)
def update(self):
"""
Updates the grade for the course. Also updates subsection grades
if self.force_update_subsections is true, via the lazy call
to self.grader_result.
"""
# TODO update this code to be more functional and readable.
# Currently, it is hard to follow since there are plenty of
# side-effects. Once functional, force_update_subsections
# can be passed through and not confusingly stored and used
# at a later time.
grade_cutoffs = self.course_data.course.grade_cutoffs
self.percent = self._compute_percent(self.grader_result)
self.letter_grade = self._compute_letter_grade(grade_cutoffs, self.percent)
self.passed = self._compute_passed(grade_cutoffs, self.percent)
return self
@lazy
def attempted(self): # lint-amnesty, pylint: disable=invalid-overridden-method
"""
Returns whether any of the subsections in this course
have been attempted by the student.
"""
if assume_zero_if_absent(self.course_data.course_key):
return True
for chapter in self.chapter_grades.values():
for subsection_grade in chapter['sections']:
if subsection_grade.all_total.first_attempted:
return True
return False
def _get_subsection_grade(self, subsection, force_update_subsections=False):
if self.force_update_subsections:
return self._subsection_grade_factory.update(subsection, force_update_subsections=force_update_subsections)
else:
# Pass read_only here so the subsection grades can be persisted in bulk at the end.
return self._subsection_grade_factory.create(subsection, read_only=True)
@staticmethod
def _compute_percent(grader_result):
"""
Computes and returns the grade percentage from the given
result from the grader.
"""
# Confused about the addition of .05 here? See https://openedx.atlassian.net/browse/TNL-6972
return round_away_from_zero(grader_result['percent'] * 100 + 0.05) / 100
@staticmethod
def _compute_letter_grade(grade_cutoffs, percent):
"""
Computes and returns the course letter grade given the
inputs, as defined in the grading_policy (e.g. 'A' 'B' 'C')
or None if not passed.
"""
letter_grade = None
# Possible grades, sorted in descending order of score
descending_grades = sorted(grade_cutoffs, key=lambda x: grade_cutoffs[x], reverse=True)
for possible_grade in descending_grades:
if percent >= grade_cutoffs[possible_grade]:
letter_grade = possible_grade
break
return letter_grade
@staticmethod
def _compute_passed(grade_cutoffs, percent):
"""
Computes and returns whether the given percent value
is a passing grade according to the given grade cutoffs.
"""
nonzero_cutoffs = [cutoff for cutoff in grade_cutoffs.values() if cutoff > 0]
success_cutoff = min(nonzero_cutoffs) if nonzero_cutoffs else None
return success_cutoff and percent >= success_cutoff
def _uniqueify_and_keep_order(iterable):
return list(OrderedDict([(item, None) for item in iterable]).keys())
| [
1,
529,
276,
1112,
420,
29958,
359,
6235,
29914,
6878,
357,
29899,
1994,
29899,
974,
29899,
386,
18159,
29899,
12717,
29899,
20415,
13,
15945,
29908,
13,
29907,
10242,
29954,
15464,
4134,
13,
15945,
29908,
13,
13,
13,
3166,
25638,
1053,
9846,
5696,
13,
3166,
16250,
1053,
8170,
287,
21533,
29892,
2322,
8977,
13,
13,
3166,
274,
18904,
29918,
8149,
29889,
2029,
1061,
1053,
19178,
29990,
3524,
1061,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
3166,
17366,
1053,
17366,
13,
13,
3166,
6496,
29916,
29889,
3221,
29889,
1982,
29889,
8228,
29918,
13239,
1053,
4513,
29918,
21694,
29918,
3166,
29918,
9171,
13,
3166,
921,
5453,
1053,
2908,
29918,
19635,
29918,
13239,
13,
13,
3166,
869,
2917,
1053,
5251,
29918,
9171,
29918,
361,
29918,
6897,
296,
13,
3166,
869,
1557,
2361,
1053,
10272,
29918,
25376,
13,
3166,
869,
7235,
29918,
8228,
1053,
28933,
4035,
2042,
29954,
15464,
13,
3166,
869,
7235,
29918,
8228,
29918,
14399,
1053,
3323,
2042,
29954,
15464,
5126,
13,
13,
13,
1990,
6325,
344,
29954,
15464,
5160,
29901,
13,
1678,
9995,
13,
1678,
7399,
770,
363,
6325,
344,
1632,
3076,
29889,
13,
1678,
9995,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1404,
29892,
3236,
29918,
1272,
29892,
10151,
29922,
29900,
29889,
29900,
29892,
5497,
29918,
8228,
29922,
8516,
29892,
4502,
29922,
8824,
29892,
4889,
29918,
5504,
29918,
1491,
27117,
29922,
8824,
1125,
13,
4706,
1583,
29889,
1792,
353,
1404,
13,
4706,
1583,
29889,
15775,
29918,
1272,
353,
3236,
29918,
1272,
13,
13,
4706,
1583,
29889,
25376,
353,
10151,
13,
4706,
1583,
29889,
3364,
287,
353,
4502,
13,
13,
4706,
396,
14806,
4069,
6031,
304,
6213,
746,
5183,
515,
278,
1591,
13,
4706,
1583,
29889,
15670,
29918,
8228,
353,
5497,
29918,
8228,
470,
6213,
13,
4706,
1583,
29889,
10118,
29918,
5504,
29918,
1491,
27117,
353,
4889,
29918,
5504,
29918,
1491,
27117,
13,
13,
1678,
822,
4770,
710,
12035,
1311,
1125,
13,
4706,
736,
525,
29907,
10242,
4989,
311,
29901,
10151,
29901,
24335,
5497,
29918,
8228,
29901,
24335,
4502,
29901,
6571,
4286,
4830,
29898,
13,
9651,
851,
29898,
1311,
29889,
25376,
511,
13,
9651,
1583,
29889,
15670,
29918,
8228,
29892,
13,
9651,
1583,
29889,
3364,
287,
29892,
13,
4706,
1723,
13,
13,
1678,
732,
6799,
13,
1678,
822,
16388,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
16969,
3692,
472,
3203,
697,
1108,
471,
16388,
13,
4706,
491,
278,
1404,
297,
278,
3236,
29889,
13,
4706,
9995,
13,
4706,
736,
7700,
13,
13,
1678,
822,
1014,
2042,
29918,
8228,
29898,
1311,
29892,
1014,
2042,
29918,
1989,
1125,
13,
4706,
9995,
13,
4706,
16969,
278,
1014,
2042,
19468,
363,
278,
2183,
1014,
2042,
8744,
1820,
29889,
13,
13,
4706,
390,
1759,
267,
421,
2558,
2392,
29952,
565,
278,
3236,
3829,
947,
451,
1712,
278,
1820,
29889,
13,
13,
4706,
960,
278,
3236,
3829,
3743,
278,
1820,
29892,
445,
674,
2337,
9269,
13,
4706,
313,
392,
736,
263,
19468,
29897,
17126,
310,
3692,
278,
1404,
508,
2130,
393,
4004,
29936,
13,
4706,
372,
338,
701,
304,
278,
24959,
304,
9801,
393,
278,
19468,
3508,
29915,
29873,
13,
4706,
4318,
304,
4160,
393,
9273,
29915,
29873,
367,
2221,
304,
2130,
372,
13,
4706,
313,
29872,
29889,
29887,
29889,
263,
8368,
9273,
29915,
29873,
1074,
263,
19468,
363,
385,
443,
276,
4611,
1014,
2042,
416,
13,
4706,
9995,
13,
4706,
396,
1106,
297,
278,
1404,
3829,
937,
322,
6416,
1627,
304,
278,
16531,
29936,
13,
4706,
396,
3138,
29892,
591,
5251,
278,
2106,
310,
3236,
29918,
1272,
338,
7609,
1848,
29892,
13,
4706,
396,
577,
591,
671,
11828,
29918,
23905,
304,
4772,
5684,
6699,
292,
13,
4706,
1014,
2042,
353,
313,
13,
9651,
1583,
29889,
15775,
29918,
1272,
29889,
15987,
573,
29918,
23905,
29961,
7235,
29918,
1989,
29962,
13,
9651,
565,
1014,
2042,
29918,
1989,
297,
1583,
29889,
15775,
29918,
1272,
29889,
15987,
573,
29918,
23905,
13,
9651,
1683,
1583,
29889,
15775,
29918,
1272,
29889,
15914,
287,
29918,
23905,
29961,
7235,
29918,
1989,
29962,
13,
4706,
1723,
13,
4706,
736,
1583,
3032,
657,
29918,
7235,
29918,
8228,
29898,
7235,
29897,
13,
13,
1678,
732,
433,
1537,
13,
1678,
822,
4656,
287,
29918,
1491,
27117,
29918,
1609,
29918,
4830,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
16969,
867,
3076,
363,
278,
1014,
27117,
297,
278,
3236,
297,
13,
4706,
263,
9657,
1820,
287,
491,
1014,
2042,
3402,
4072,
29889,
13,
4706,
9995,
13,
4706,
1014,
27117,
29918,
1609,
29918,
4830,
353,
2322,
8977,
29898,
7514,
287,
21533,
29897,
13,
4706,
363,
16385,
297,
1583,
29889,
27349,
29918,
629,
3076,
29889,
5975,
7295,
13,
9651,
363,
1014,
2042,
29918,
8228,
297,
16385,
1839,
27117,
2033,
29901,
13,
18884,
565,
1014,
2042,
29918,
8228,
29889,
5105,
287,
29901,
13,
462,
1678,
4656,
287,
29918,
7827,
353,
1014,
2042,
29918,
8228,
29889,
5105,
287,
29918,
7827,
13,
462,
1678,
565,
4656,
287,
29918,
7827,
29889,
27338,
1405,
29871,
29900,
29901,
13,
462,
4706,
1014,
27117,
29918,
1609,
29918,
4830,
29961,
7235,
29918,
8228,
29889,
4830,
3816,
7235,
29918,
8228,
29889,
5479,
29962,
353,
1014,
2042,
29918,
8228,
13,
4706,
736,
1014,
27117,
29918,
1609,
29918,
4830,
13,
13,
1678,
732,
433,
1537,
13,
1678,
822,
16385,
29918,
629,
3076,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
16969,
263,
8600,
310,
21503,
4314,
29889,
13,
4706,
450,
7601,
8600,
338,
1820,
287,
491,
278,
16385,
29915,
29879,
8744,
29918,
1989,
29889,
13,
4706,
450,
16723,
8600,
3743,
278,
16385,
29915,
29879,
13,
4706,
1014,
2042,
867,
3076,
29892,
2479,
1024,
29892,
322,
3142,
1024,
29889,
13,
4706,
9995,
13,
4706,
3236,
29918,
23905,
353,
1583,
29889,
15775,
29918,
1272,
29889,
23905,
13,
4706,
867,
3076,
353,
8170,
287,
21533,
580,
13,
4706,
363,
16385,
29918,
1989,
297,
3236,
29918,
23905,
29889,
657,
29918,
11991,
29898,
1311,
29889,
15775,
29918,
1272,
29889,
5479,
1125,
13,
9651,
867,
3076,
29961,
27349,
29918,
1989,
29962,
353,
1583,
3032,
657,
29918,
27349,
29918,
8228,
29918,
3888,
29898,
15775,
29918,
23905,
29961,
27349,
29918,
1989,
1402,
3236,
29918,
23905,
29897,
13,
4706,
736,
867,
3076,
13,
13,
1678,
732,
433,
1537,
13,
1678,
822,
1014,
2042,
29918,
629,
3076,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
16969,
385,
10372,
8600,
310,
1014,
2042,
867,
3076,
29892,
13,
4706,
1820,
287,
491,
1014,
2042,
4423,
29889,
13,
4706,
9995,
13,
4706,
1014,
2042,
29918,
629,
3076,
353,
2322,
8977,
29898,
7514,
287,
21533,
29897,
13,
4706,
363,
16385,
297,
1583,
29889,
27349,
29918,
629,
3076,
29889,
5975,
7295,
13,
9651,
363,
1014,
2042,
29918,
8228,
297,
16385,
1839,
27117,
2033,
29901,
13,
18884,
1014,
2042,
29918,
629,
3076,
29961,
7235,
29918,
8228,
29889,
5479,
29962,
353,
1014,
2042,
29918,
8228,
13,
4706,
736,
1014,
2042,
29918,
629,
3076,
13,
13,
1678,
732,
433,
1537,
13,
1678,
822,
1108,
29918,
1557,
2361,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
16969,
263,
9657,
310,
1108,
19435,
1820,
287,
491,
1009,
14354,
29889,
13,
4706,
9995,
13,
4706,
1108,
29918,
1557,
2361,
353,
6571,
13,
4706,
363,
16385,
297,
1583,
29889,
27349,
29918,
629,
3076,
29889,
5975,
7295,
13,
9651,
363,
1014,
2042,
29918,
8228,
297,
16385,
1839,
27117,
2033,
29901,
13,
18884,
1108,
29918,
1557,
2361,
29889,
5504,
29898,
7235,
29918,
8228,
29889,
17199,
29918,
1557,
2361,
29897,
13,
4706,
736,
1108,
29918,
1557,
2361,
13,
13,
1678,
822,
16385,
29918,
25376,
482,
29898,
1311,
29892,
16385,
29918,
1989,
1125,
13,
4706,
9995,
13,
4706,
16969,
278,
28240,
20431,
7688,
287,
19649,
363,
278,
2183,
16385,
29889,
13,
4706,
390,
1759,
267,
29901,
13,
9651,
7670,
2392,
565,
278,
16385,
338,
451,
1476,
29889,
13,
4706,
9995,
13,
4706,
20591,
29892,
1950,
353,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
13,
4706,
16385,
29918,
8228,
353,
1583,
29889,
27349,
29918,
629,
3076,
29961,
27349,
29918,
1989,
29962,
13,
4706,
363,
4004,
297,
16385,
29918,
8228,
1839,
27117,
2033,
29901,
13,
9651,
20591,
4619,
4004,
29889,
5105,
287,
29918,
7827,
29889,
799,
9571,
13,
9651,
1950,
4619,
4004,
29889,
5105,
287,
29918,
7827,
29889,
27338,
13,
4706,
736,
10272,
29918,
25376,
29898,
799,
9571,
29892,
1950,
29897,
13,
13,
1678,
822,
8158,
29918,
1454,
29918,
5453,
29898,
1311,
29892,
4423,
1125,
13,
4706,
9995,
13,
4706,
20535,
403,
278,
20431,
7688,
287,
8158,
363,
738,
4423,
297,
278,
3236,
29889,
13,
4706,
910,
1158,
3639,
263,
18761,
6943,
313,
799,
9571,
29918,
13628,
29892,
1950,
29918,
13628,
467,
13,
4706,
960,
278,
4423,
338,
310,
525,
17199,
29915,
1134,
29892,
445,
1158,
674,
736,
278,
13,
4706,
1950,
322,
20591,
19435,
363,
393,
1108,
29889,
960,
278,
4423,
14637,
304,
263,
13,
4706,
20842,
3883,
313,
29874,
11408,
470,
4004,
1723,
278,
19435,
674,
367,
278,
25470,
310,
13,
4706,
599,
15569,
4828,
393,
526,
4344,
310,
278,
10434,
4423,
29889,
13,
4706,
9995,
13,
4706,
565,
4423,
297,
1583,
29889,
17199,
29918,
1557,
2361,
29901,
13,
9651,
8158,
353,
1583,
29889,
17199,
29918,
1557,
2361,
29961,
5479,
29962,
13,
9651,
736,
8158,
29889,
799,
9571,
29892,
8158,
29889,
27338,
13,
4706,
4344,
353,
1583,
29889,
15775,
29918,
1272,
29889,
23905,
29889,
657,
29918,
11991,
29898,
5479,
29897,
13,
4706,
20591,
29892,
1950,
353,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
13,
4706,
363,
2278,
297,
4344,
29901,
13,
9651,
2278,
29918,
799,
9571,
29892,
2278,
29918,
27338,
353,
1583,
29889,
13628,
29918,
1454,
29918,
5453,
29898,
5145,
29897,
13,
9651,
20591,
4619,
2278,
29918,
799,
9571,
13,
9651,
1950,
4619,
2278,
29918,
27338,
13,
4706,
736,
20591,
29892,
1950,
13,
13,
1678,
732,
433,
1537,
13,
1678,
822,
867,
1664,
29918,
2914,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
16969,
278,
1121,
515,
278,
3236,
867,
1664,
29889,
13,
4706,
9995,
13,
4706,
3236,
353,
1583,
3032,
15287,
29918,
15775,
29918,
1454,
29918,
5105,
292,
29898,
1311,
29889,
15775,
29918,
1272,
29889,
15775,
29897,
13,
4706,
736,
3236,
29889,
629,
1664,
29889,
8228,
29898,
13,
9651,
1583,
29889,
5105,
287,
29918,
1491,
27117,
29918,
1609,
29918,
4830,
29892,
13,
9651,
5706,
29918,
8172,
29918,
1557,
2361,
29922,
11027,
29889,
24647,
1001,
3040,
29918,
8618,
7724,
29918,
29903,
3217,
15989,
29892,
13,
4706,
1723,
13,
13,
1678,
732,
6799,
13,
1678,
822,
15837,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
16969,
278,
19468,
15837,
408,
12833,
491,
278,
3236,
29915,
29879,
867,
1664,
29889,
13,
4706,
5012,
15094,
29907,
3040,
29928,
29901,
1763,
367,
6206,
408,
760,
310,
323,
25103,
29899,
29945,
29906,
29929,
29896,
29889,
13,
4706,
9995,
13,
4706,
396,
14402,
29898,
29911,
25103,
29899,
29945,
29906,
29929,
29896,
29897,
15154,
502,
1179,
310,
445,
18164,
2875,
29889,
13,
4706,
19468,
29918,
7727,
353,
1583,
29889,
629,
1664,
29918,
2914,
13,
4706,
19468,
29918,
7727,
1839,
25376,
2033,
353,
1583,
29889,
25376,
13,
4706,
19468,
29918,
7727,
1839,
8228,
2033,
353,
1583,
29889,
15670,
29918,
8228,
13,
4706,
736,
19468,
29918,
7727,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
679,
29918,
7235,
29918,
1853,
29918,
5105,
414,
29898,
25932,
29892,
3236,
1125,
13,
4706,
9995,
13,
4706,
16969,
263,
8600,
10417,
1014,
2042,
4072,
304,
1009,
13,
4706,
6590,
13252,
4656,
414,
29892,
639,
4656,
292,
8898,
29889,
13,
4706,
9995,
13,
4706,
3236,
353,
1067,
29879,
3032,
15287,
29918,
15775,
29918,
1454,
29918,
5105,
292,
29898,
15775,
29897,
13,
4706,
736,
426,
13,
9651,
1014,
2042,
29918,
1853,
29901,
1014,
2042,
29918,
1853,
29918,
629,
1664,
13,
9651,
363,
313,
7235,
29918,
1853,
29918,
629,
1664,
29892,
1014,
2042,
29918,
1853,
29892,
24459,
13,
9651,
297,
3236,
29889,
629,
1664,
29889,
1491,
5105,
414,
13,
4706,
500,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
903,
15287,
29918,
15775,
29918,
1454,
29918,
5105,
292,
29898,
25932,
29892,
3236,
1125,
13,
4706,
9995,
13,
4706,
8561,
1854,
738,
975,
24040,
304,
278,
4656,
292,
8898,
526,
1304,
29889,
13,
4706,
910,
338,
1556,
8018,
363,
19178,
29990,
21888,
29889,
13,
13,
4706,
10428,
1286,
29892,
591,
1603,
2130,
278,
4656,
292,
8898,
515,
278,
3236,
13,
4706,
1203,
29889,
9038,
591,
679,
278,
4656,
292,
8898,
515,
278,
15658,
5015,
12425,
13,
4706,
445,
674,
694,
5520,
367,
4312,
448,
1951,
15658,
5015,
12425,
5149,
13,
4706,
5663,
17180,
29914,
6394,
599,
1746,
975,
24040,
29889,
13,
4706,
9995,
13,
4706,
565,
338,
8758,
29898,
15775,
29889,
333,
29892,
19178,
29990,
3524,
1061,
1125,
13,
9651,
396,
5941,
714,
738,
1746,
1819,
393,
1122,
505,
1063,
731,
515,
278,
13,
9651,
396,
3847,
3236,
310,
278,
19178,
29990,
3236,
29889,
13,
9651,
3236,
3032,
2671,
29918,
1272,
29918,
8173,
353,
6571,
29871,
396,
282,
2904,
524,
29901,
11262,
29922,
24681,
29899,
5943,
13,
13,
9651,
396,
445,
338,
376,
11082,
293,
29908,
775,
393,
6336,
5663,
17180,
738,
975,
24040,
13,
9651,
396,
304,
278,
4656,
292,
8898,
322,
11217,
278,
3236,
1203,
29889,
13,
9651,
3236,
29889,
842,
29918,
5105,
292,
29918,
22197,
29898,
15775,
29889,
5105,
292,
29918,
22197,
29897,
13,
4706,
736,
3236,
13,
13,
1678,
822,
903,
657,
29918,
27349,
29918,
8228,
29918,
3888,
29898,
1311,
29892,
16385,
29892,
3236,
29918,
23905,
1125,
13,
4706,
9995,
13,
4706,
6162,
546,
393,
3639,
263,
8600,
310,
16385,
19468,
2472,
29889,
13,
4706,
9995,
13,
4706,
16385,
29918,
7235,
29918,
629,
3076,
353,
1583,
3032,
657,
29918,
7235,
29918,
629,
3076,
29898,
15775,
29918,
23905,
29892,
16385,
29889,
5479,
29897,
13,
4706,
736,
426,
13,
9651,
525,
4990,
29918,
978,
2396,
2908,
29918,
19635,
29918,
13239,
29889,
4990,
29918,
978,
29918,
2541,
29918,
4381,
29898,
27349,
511,
13,
9651,
525,
2271,
29918,
978,
2396,
2908,
29918,
19635,
29918,
13239,
29889,
2271,
29918,
978,
29918,
1454,
29918,
1271,
29898,
27349,
511,
13,
9651,
525,
27117,
2396,
16385,
29918,
7235,
29918,
629,
3076,
29892,
13,
4706,
500,
13,
13,
1678,
822,
903,
657,
29918,
7235,
29918,
629,
3076,
29898,
1311,
29892,
3236,
29918,
23905,
29892,
16385,
29918,
1989,
1125,
13,
4706,
9995,
13,
4706,
16969,
263,
1051,
310,
1014,
2042,
867,
3076,
363,
278,
2183,
16385,
29889,
13,
4706,
9995,
13,
4706,
736,
518,
13,
9651,
1583,
3032,
657,
29918,
7235,
29918,
8228,
29898,
15775,
29918,
23905,
29961,
7235,
29918,
1989,
1402,
1583,
29889,
10118,
29918,
5504,
29918,
1491,
27117,
29897,
13,
9651,
363,
1014,
2042,
29918,
1989,
297,
903,
13092,
1598,
29918,
392,
29918,
17462,
29918,
2098,
29898,
15775,
29918,
23905,
29889,
657,
29918,
11991,
29898,
27349,
29918,
1989,
876,
13,
4706,
4514,
13,
13,
1678,
732,
16595,
5696,
13,
1678,
822,
903,
657,
29918,
7235,
29918,
8228,
29898,
1311,
29892,
1014,
2042,
29892,
4889,
29918,
5504,
29918,
1491,
27117,
29922,
8824,
1125,
13,
4706,
9995,
13,
4706,
25513,
1158,
304,
367,
8762,
491,
1014,
13203,
363,
7863,
13,
4706,
278,
19468,
310,
278,
2183,
1014,
2042,
29889,
13,
4706,
9995,
13,
4706,
12020,
2216,
1888,
2037,
287,
2392,
13,
13,
13,
1990,
28933,
29907,
10242,
29954,
15464,
29898,
29907,
10242,
29954,
15464,
5160,
1125,
13,
1678,
9995,
13,
1678,
6325,
344,
4989,
311,
770,
363,
28933,
29899,
1767,
867,
3076,
746,
694,
4828,
892,
13,
1678,
16388,
297,
278,
3236,
29889,
13,
1678,
9995,
13,
1678,
822,
903,
657,
29918,
7235,
29918,
8228,
29898,
1311,
29892,
1014,
2042,
29892,
4889,
29918,
5504,
29918,
1491,
27117,
29922,
8824,
1125,
13,
4706,
736,
28933,
4035,
2042,
29954,
15464,
29898,
7235,
29892,
1583,
29889,
15775,
29918,
1272,
29897,
13,
13,
13,
1990,
6325,
344,
29954,
15464,
29898,
29907,
10242,
29954,
15464,
5160,
1125,
13,
1678,
9995,
13,
1678,
6325,
344,
4989,
311,
770,
746,
867,
3076,
526,
4784,
470,
1303,
515,
8635,
29889,
13,
1678,
9995,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1404,
29892,
3236,
29918,
1272,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
2428,
2141,
1649,
2344,
12035,
1792,
29892,
3236,
29918,
1272,
29892,
334,
5085,
29892,
3579,
19290,
29897,
13,
4706,
1583,
3032,
7235,
29918,
8228,
29918,
14399,
353,
3323,
2042,
29954,
15464,
5126,
29898,
1792,
29892,
3236,
29918,
1272,
29922,
15775,
29918,
1272,
29897,
13,
13,
1678,
822,
2767,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
5020,
15190,
278,
19468,
363,
278,
3236,
29889,
3115,
11217,
1014,
2042,
867,
3076,
13,
4706,
565,
1583,
29889,
10118,
29918,
5504,
29918,
1491,
27117,
338,
1565,
29892,
3025,
278,
17366,
1246,
13,
4706,
304,
1583,
29889,
629,
1664,
29918,
2914,
29889,
13,
4706,
9995,
13,
4706,
396,
14402,
2767,
445,
775,
304,
367,
901,
13303,
322,
19909,
29889,
13,
4706,
396,
15447,
29892,
372,
338,
2898,
304,
1101,
1951,
727,
526,
20947,
310,
13,
4706,
396,
2625,
29899,
15987,
29879,
29889,
9038,
13303,
29892,
4889,
29918,
5504,
29918,
1491,
27117,
13,
4706,
396,
508,
367,
4502,
1549,
322,
451,
16051,
368,
6087,
322,
1304,
13,
4706,
396,
472,
263,
2678,
931,
29889,
13,
4706,
19468,
29918,
7582,
22450,
353,
1583,
29889,
15775,
29918,
1272,
29889,
15775,
29889,
8228,
29918,
7582,
22450,
13,
4706,
1583,
29889,
25376,
353,
1583,
3032,
26017,
29918,
25376,
29898,
1311,
29889,
629,
1664,
29918,
2914,
29897,
13,
4706,
1583,
29889,
15670,
29918,
8228,
353,
1583,
3032,
26017,
29918,
15670,
29918,
8228,
29898,
8228,
29918,
7582,
22450,
29892,
1583,
29889,
25376,
29897,
13,
4706,
1583,
29889,
3364,
287,
353,
1583,
3032,
26017,
29918,
3364,
287,
29898,
8228,
29918,
7582,
22450,
29892,
1583,
29889,
25376,
29897,
13,
4706,
736,
1583,
13,
13,
1678,
732,
433,
1537,
13,
1678,
822,
16388,
29898,
1311,
1125,
29871,
396,
301,
524,
29899,
314,
29876,
14596,
29892,
282,
2904,
524,
29901,
11262,
29922,
20965,
29899,
957,
2429,
1145,
29899,
5696,
13,
4706,
9995,
13,
4706,
16969,
3692,
738,
310,
278,
1014,
27117,
297,
445,
3236,
13,
4706,
505,
1063,
16388,
491,
278,
8368,
29889,
13,
4706,
9995,
13,
4706,
565,
5251,
29918,
9171,
29918,
361,
29918,
6897,
296,
29898,
1311,
29889,
15775,
29918,
1272,
29889,
15775,
29918,
1989,
1125,
13,
9651,
736,
5852,
13,
13,
4706,
363,
16385,
297,
1583,
29889,
27349,
29918,
629,
3076,
29889,
5975,
7295,
13,
9651,
363,
1014,
2042,
29918,
8228,
297,
16385,
1839,
27117,
2033,
29901,
13,
18884,
565,
1014,
2042,
29918,
8228,
29889,
497,
29918,
7827,
29889,
4102,
29918,
1131,
3456,
287,
29901,
13,
462,
1678,
736,
5852,
13,
4706,
736,
7700,
13,
13,
1678,
822,
903,
657,
29918,
7235,
29918,
8228,
29898,
1311,
29892,
1014,
2042,
29892,
4889,
29918,
5504,
29918,
1491,
27117,
29922,
8824,
1125,
13,
4706,
565,
1583,
29889,
10118,
29918,
5504,
29918,
1491,
27117,
29901,
13,
9651,
736,
1583,
3032,
7235,
29918,
8228,
29918,
14399,
29889,
5504,
29898,
7235,
29892,
4889,
29918,
5504,
29918,
1491,
27117,
29922,
10118,
29918,
5504,
29918,
1491,
27117,
29897,
13,
4706,
1683,
29901,
13,
9651,
396,
6978,
1303,
29918,
6194,
1244,
577,
278,
1014,
2042,
867,
3076,
508,
367,
3736,
12652,
297,
21610,
472,
278,
1095,
29889,
13,
9651,
736,
1583,
3032,
7235,
29918,
8228,
29918,
14399,
29889,
3258,
29898,
7235,
29892,
1303,
29918,
6194,
29922,
5574,
29897,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
903,
26017,
29918,
25376,
29898,
629,
1664,
29918,
2914,
1125,
13,
4706,
9995,
13,
4706,
11796,
267,
322,
3639,
278,
19468,
19649,
515,
278,
2183,
13,
4706,
1121,
515,
278,
867,
1664,
29889,
13,
4706,
9995,
13,
13,
4706,
396,
10811,
3880,
1048,
278,
6124,
310,
869,
29900,
29945,
1244,
29973,
29871,
2823,
2045,
597,
3150,
287,
29916,
29889,
271,
605,
713,
29889,
1212,
29914,
23721,
344,
29914,
29911,
25103,
29899,
29953,
29929,
29955,
29906,
13,
4706,
736,
4513,
29918,
21694,
29918,
3166,
29918,
9171,
29898,
629,
1664,
29918,
2914,
1839,
25376,
2033,
334,
29871,
29896,
29900,
29900,
718,
29871,
29900,
29889,
29900,
29945,
29897,
847,
29871,
29896,
29900,
29900,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
903,
26017,
29918,
15670,
29918,
8228,
29898,
8228,
29918,
7582,
22450,
29892,
10151,
1125,
13,
4706,
9995,
13,
4706,
11796,
267,
322,
3639,
278,
3236,
5497,
19468,
2183,
278,
13,
4706,
10970,
29892,
408,
3342,
297,
278,
4656,
292,
29918,
22197,
313,
29872,
29889,
29887,
29889,
525,
29909,
29915,
525,
29933,
29915,
525,
29907,
1495,
13,
4706,
470,
6213,
565,
451,
4502,
29889,
13,
4706,
9995,
13,
4706,
5497,
29918,
8228,
353,
6213,
13,
13,
4706,
396,
20049,
867,
3076,
29892,
12705,
297,
5153,
2548,
1797,
310,
8158,
13,
4706,
5153,
2548,
29918,
629,
3076,
353,
12705,
29898,
8228,
29918,
7582,
22450,
29892,
1820,
29922,
2892,
921,
29901,
19468,
29918,
7582,
22450,
29961,
29916,
1402,
11837,
29922,
5574,
29897,
13,
4706,
363,
1950,
29918,
8228,
297,
5153,
2548,
29918,
629,
3076,
29901,
13,
9651,
565,
10151,
6736,
19468,
29918,
7582,
22450,
29961,
27338,
29918,
8228,
5387,
13,
18884,
5497,
29918,
8228,
353,
1950,
29918,
8228,
13,
18884,
2867,
13,
13,
4706,
736,
5497,
29918,
8228,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
903,
26017,
29918,
3364,
287,
29898,
8228,
29918,
7582,
22450,
29892,
10151,
1125,
13,
4706,
9995,
13,
4706,
11796,
267,
322,
3639,
3692,
278,
2183,
10151,
995,
13,
4706,
338,
263,
6819,
19468,
5034,
304,
278,
2183,
19468,
5700,
22450,
29889,
13,
4706,
9995,
13,
4706,
1661,
9171,
29918,
7582,
22450,
353,
518,
7582,
2696,
363,
5700,
2696,
297,
19468,
29918,
7582,
22450,
29889,
5975,
580,
565,
5700,
2696,
1405,
29871,
29900,
29962,
13,
4706,
2551,
29918,
7582,
2696,
353,
1375,
29898,
5464,
9171,
29918,
7582,
22450,
29897,
565,
1661,
9171,
29918,
7582,
22450,
1683,
6213,
13,
4706,
736,
2551,
29918,
7582,
2696,
322,
10151,
6736,
2551,
29918,
7582,
2696,
13,
13,
13,
1753,
903,
13092,
1598,
29918,
392,
29918,
17462,
29918,
2098,
29898,
1524,
519,
1125,
13,
1678,
736,
1051,
29898,
7514,
287,
21533,
4197,
29898,
667,
29892,
6213,
29897,
363,
2944,
297,
4256,
519,
14664,
8149,
3101,
13,
2
] |
Scripts/hilberttrans.py | TChauvire/EPR_ESR_Suite | 2 | 88749 | <reponame>TChauvire/EPR_ESR_Suite
import numpy as np
from scipy.signal import hilbert
def hilberttrans(data, N=None):
"""
Hilbert transform.
Reconstruct imaginary data via hilbert transform.
This script is freely inspired by the easyspin suite from the Stefan Stoll lab
(https://github.com/StollLab/EasySpin/)
(https://easyspin.org/easyspin/)
Script written by <NAME> (https://github.com/TChauvire/EPR_ESR_Suite/), 09/09/2020
Parameters
----------
data : numpy data array column vector
N : int or None
Number of Fourier components.
Returns
-------
z : Hilbert transformed complex vector.
TYPE : numpy data array column vector
References
----------
.. [1] Wikipedia, "Analytic signal".
https://en.wikipedia.org/wiki/Analytic_signal
.. [2] <NAME>, "Time-Frequency Analysis", 1995. Chapter 2.
.. [3] <NAME>, <NAME>. Discrete-Time Signal
Processing, Third Edition, 2009. Chapter 12.
ISBN 13: 978-1292-02572-8
"""
shape = data.shape
if (data.shape[0] == np.ravel(data).shape[0]): # Check if the data is a column vector
data = np.ravel(data)
if N == None:
N = data.shape[-1]
# create an empty output array
fac = N / data.shape[-1]
z = np.empty(data.shape, dtype=(data.flat[0] + data.flat[1] * 1.j).dtype)
if data.ndim == 1:
z[:] = hilbert(data.real, N)[:data.shape[-1]] * fac
else:
for i, vec in enumerate(data):
z[i] = hilbert(vec.real, N)[:data.shape[-1]] * fac
# correct the real data as sometimes it changes
z.real = data.real
z = z.reshape(shape)
return z | [
1,
529,
276,
1112,
420,
29958,
29911,
1451,
585,
29894,
533,
29914,
29923,
10593,
29918,
2890,
29934,
29918,
5091,
568,
13,
5215,
12655,
408,
7442,
13,
3166,
4560,
2272,
29889,
25436,
1053,
298,
309,
2151,
13,
13,
1753,
298,
309,
2151,
3286,
29898,
1272,
29892,
405,
29922,
8516,
1125,
13,
1678,
9995,
13,
1678,
12338,
2151,
4327,
29889,
13,
1678,
830,
11433,
6382,
3821,
848,
3025,
298,
309,
2151,
4327,
29889,
13,
268,
13,
1678,
910,
2471,
338,
28472,
20603,
491,
278,
2240,
952,
12687,
9460,
515,
278,
21512,
624,
3028,
9775,
13,
1678,
313,
991,
597,
3292,
29889,
510,
29914,
855,
3028,
28632,
29914,
29923,
8995,
5592,
262,
4551,
13,
1678,
313,
991,
597,
29872,
294,
952,
12687,
29889,
990,
29914,
29872,
294,
952,
12687,
4551,
13,
268,
13,
1678,
14415,
3971,
491,
529,
5813,
29958,
313,
991,
597,
3292,
29889,
510,
29914,
29911,
1451,
585,
29894,
533,
29914,
29923,
10593,
29918,
2890,
29934,
29918,
5091,
568,
23201,
29871,
29900,
29929,
29914,
29900,
29929,
29914,
29906,
29900,
29906,
29900,
13,
268,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
848,
584,
12655,
848,
1409,
1897,
4608,
13,
1678,
405,
584,
938,
470,
6213,
13,
4706,
9681,
310,
27506,
7117,
29889,
13,
1678,
16969,
13,
1678,
448,
22158,
13,
1678,
503,
584,
12338,
2151,
27615,
4280,
4608,
29889,
13,
4706,
323,
6959,
584,
12655,
848,
1409,
1897,
4608,
13,
1678,
28318,
13,
1678,
448,
1378,
29899,
13,
1678,
6317,
518,
29896,
29962,
14109,
29892,
376,
21067,
3637,
293,
7182,
1642,
13,
965,
2045,
597,
264,
29889,
6011,
29889,
990,
29914,
4594,
29914,
21067,
3637,
293,
29918,
25436,
13,
1678,
6317,
518,
29906,
29962,
529,
5813,
10202,
376,
2481,
29899,
23923,
23860,
24352,
613,
29871,
29896,
29929,
29929,
29945,
29889,
23040,
29871,
29906,
29889,
13,
1678,
6317,
518,
29941,
29962,
529,
5813,
10202,
529,
5813,
15513,
3295,
9084,
29899,
2481,
9954,
284,
13,
965,
10554,
292,
29892,
18008,
17138,
29892,
29871,
29906,
29900,
29900,
29929,
29889,
23040,
29871,
29896,
29906,
29889,
13,
965,
2210,
29871,
29896,
29941,
29901,
29871,
29929,
29955,
29947,
29899,
29896,
29906,
29929,
29906,
29899,
29900,
29906,
29945,
29955,
29906,
29899,
29947,
13,
13,
1678,
9995,
13,
1678,
8267,
353,
848,
29889,
12181,
13,
1678,
565,
313,
1272,
29889,
12181,
29961,
29900,
29962,
1275,
7442,
29889,
336,
955,
29898,
1272,
467,
12181,
29961,
29900,
29962,
1125,
396,
5399,
565,
278,
848,
338,
263,
1897,
4608,
13,
4706,
848,
353,
7442,
29889,
336,
955,
29898,
1272,
29897,
13,
1678,
565,
405,
1275,
6213,
29901,
13,
4706,
405,
353,
848,
29889,
12181,
14352,
29896,
29962,
13,
1678,
396,
1653,
385,
4069,
1962,
1409,
13,
1678,
4024,
353,
405,
847,
848,
29889,
12181,
14352,
29896,
29962,
13,
1678,
503,
353,
7442,
29889,
6310,
29898,
1272,
29889,
12181,
29892,
26688,
7607,
1272,
29889,
20620,
29961,
29900,
29962,
718,
848,
29889,
20620,
29961,
29896,
29962,
334,
29871,
29896,
29889,
29926,
467,
29881,
1853,
29897,
13,
1678,
565,
848,
29889,
299,
326,
1275,
29871,
29896,
29901,
13,
4706,
503,
7503,
29962,
353,
298,
309,
2151,
29898,
1272,
29889,
6370,
29892,
405,
29897,
7503,
1272,
29889,
12181,
14352,
29896,
5262,
334,
4024,
13,
1678,
1683,
29901,
13,
4706,
363,
474,
29892,
9649,
297,
26985,
29898,
1272,
1125,
13,
9651,
503,
29961,
29875,
29962,
353,
298,
309,
2151,
29898,
2003,
29889,
6370,
29892,
405,
29897,
7503,
1272,
29889,
12181,
14352,
29896,
5262,
334,
4024,
13,
13,
1678,
396,
1959,
278,
1855,
848,
408,
6041,
372,
3620,
13,
1678,
503,
29889,
6370,
353,
848,
29889,
6370,
13,
1678,
503,
353,
503,
29889,
690,
14443,
29898,
12181,
29897,
13,
1678,
736,
503,
2
] |
__main__.py | Arab-developers/PSHMode | 27 | 1602691 | <reponame>Arab-developers/PSHMode<gh_stars>10-100
import os
import runpy
runpy.run_path(os.path.join(os.path.abspath(__file__).rsplit("/", 1)[0], "bin/PSHMode"))
| [
1,
529,
276,
1112,
420,
29958,
29909,
4201,
29899,
17426,
29914,
7024,
29950,
6818,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29899,
29896,
29900,
29900,
13,
5215,
2897,
13,
5215,
1065,
2272,
13,
13,
3389,
2272,
29889,
3389,
29918,
2084,
29898,
359,
29889,
2084,
29889,
7122,
29898,
359,
29889,
2084,
29889,
370,
1028,
493,
22168,
1445,
1649,
467,
2288,
2830,
11974,
613,
29871,
29896,
9601,
29900,
1402,
376,
2109,
29914,
7024,
29950,
6818,
5783,
13,
2
] |
scripts/update_hashes.py | presalytics/amplitude | 1 | 1606866 | import yaml
import sys
import git # type: ignore
import os
import pathlib
if __name__ == '__main__':
repo = git.Repo(search_parent_directories=True)
sha = repo.head.object.hexsha
manifests_dir = pathlib.Path(__file__).parent.absolute().parent.absolute().joinpath('manifests')
for manifest in os.listdir(manifests_dir):
file = manifests_dir.joinpath(manifest)
try:
data = {}
with open(file) as f:
data = yaml.load(f, Loader=yaml.FullLoader)
if data['apiVersion'] == 'serving.knative.dev/v1' and data['kind'] == 'Service':
data['spec']['template']['metadata']['labels']['gitHash'] = sha
with open(file, "w") as f:
f.write(yaml.dump(data, default_flow_style=False))
print("Version label of manifest {0} updated to {1}".format(manifest, sha))
except Exception as ex:
print("Hash update operation failed")
print("Error: " + ex.args[1])
exit(1) | [
1,
1053,
343,
8807,
13,
5215,
10876,
13,
5215,
6315,
29871,
396,
1134,
29901,
11455,
13,
5215,
2897,
13,
5215,
2224,
1982,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
13761,
353,
6315,
29889,
5612,
29877,
29898,
4478,
29918,
3560,
29918,
11851,
3842,
29922,
5574,
29897,
13,
1678,
528,
29874,
353,
13761,
29889,
2813,
29889,
3318,
29889,
20970,
17051,
13,
1678,
10419,
29879,
29918,
3972,
353,
2224,
1982,
29889,
2605,
22168,
1445,
1649,
467,
3560,
29889,
23552,
2141,
3560,
29889,
23552,
2141,
7122,
2084,
877,
29135,
29879,
1495,
13,
1678,
363,
10419,
297,
2897,
29889,
1761,
3972,
29898,
29135,
29879,
29918,
3972,
1125,
13,
4706,
934,
353,
10419,
29879,
29918,
3972,
29889,
7122,
2084,
29898,
29135,
29897,
13,
4706,
1018,
29901,
13,
9651,
848,
353,
6571,
13,
9651,
411,
1722,
29898,
1445,
29897,
408,
285,
29901,
13,
18884,
848,
353,
343,
8807,
29889,
1359,
29898,
29888,
29892,
4309,
1664,
29922,
25162,
29889,
13658,
10036,
29897,
13,
9651,
565,
848,
1839,
2754,
6594,
2033,
1275,
525,
643,
1747,
29889,
3959,
1230,
29889,
3359,
29914,
29894,
29896,
29915,
322,
848,
1839,
14380,
2033,
1275,
525,
3170,
2396,
13,
18884,
848,
1839,
6550,
16215,
6886,
16215,
19635,
16215,
21134,
16215,
5559,
10438,
2033,
353,
528,
29874,
13,
9651,
411,
1722,
29898,
1445,
29892,
376,
29893,
1159,
408,
285,
29901,
13,
18884,
285,
29889,
3539,
29898,
25162,
29889,
15070,
29898,
1272,
29892,
2322,
29918,
1731,
29918,
3293,
29922,
8824,
876,
13,
9651,
1596,
703,
6594,
3858,
310,
10419,
426,
29900,
29913,
4784,
304,
426,
29896,
29913,
1642,
4830,
29898,
29135,
29892,
528,
29874,
876,
13,
4706,
5174,
8960,
408,
429,
29901,
13,
9651,
1596,
703,
10438,
2767,
5858,
5229,
1159,
13,
9651,
1596,
703,
2392,
29901,
376,
718,
429,
29889,
5085,
29961,
29896,
2314,
13,
9651,
6876,
29898,
29896,
29897,
2
] |
bot/handlers/bans.py | Mehavoid/telegram-feedback-bot | 41 | 148008 | from contextlib import suppress
from aiogram import Dispatcher, types
from aiogram.dispatcher.filters import IsReplyFilter, IDFilter
from bot.blocklists import banned, shadowbanned
from bot.handlers.adminmode import extract_id
async def cmd_ban(message: types.Message):
try:
user_id = extract_id(message)
except ValueError as ex:
return await message.reply(str(ex))
banned.add(int(user_id))
await message.reply(
f"ID {user_id} добавлен в список заблокированных. "
f"При попытке отправить сообщение пользователь получит уведомление о том, что заблокирован."
)
async def cmd_shadowban(message: types.Message):
try:
user_id = extract_id(message)
except ValueError as ex:
return await message.reply(str(ex))
shadowbanned.add(int(user_id))
await message.reply(
f"ID {user_id} добавлен в список скрытно заблокированных. "
f"При попытке отправить сообщение пользователь не узнает, что заблокирован."
)
async def cmd_unban(message: types.Message):
try:
user_id = extract_id(message)
except ValueError as ex:
return await message.reply(str(ex))
user_id = int(user_id)
with suppress(KeyError):
banned.remove(user_id)
with suppress(KeyError):
shadowbanned.remove(user_id)
await message.reply(f"ID {user_id} разблокирован")
async def cmd_list_banned(message: types.Message):
has_bans = len(banned) > 0 or len(shadowbanned) > 0
if not has_bans:
await message.answer("Нет заблокированных пользователей")
return
result = []
if len(banned) > 0:
result.append("Список заблокированных:")
for item in banned:
result.append(f"• #id{item}")
if len(shadowbanned) > 0:
result.append("\nСписок скрытно заблокированных:")
for item in shadowbanned:
result.append(f"• #id{item}")
await message.answer("\n".join(result))
def register_bans_handlers(dp: Dispatcher, admin_chat_id: int):
dp.register_message_handler(cmd_ban, IsReplyFilter(is_reply=True), IDFilter(chat_id=admin_chat_id),
commands="ban")
dp.register_message_handler(cmd_shadowban, IsReplyFilter(is_reply=True), IDFilter(chat_id=admin_chat_id),
commands="shadowban")
dp.register_message_handler(cmd_unban, IsReplyFilter(is_reply=True), IDFilter(chat_id=admin_chat_id),
commands="unban")
dp.register_message_handler(cmd_list_banned, IDFilter(chat_id=admin_chat_id),
commands="list_banned")
| [
1,
515,
3030,
1982,
1053,
21301,
13,
13,
3166,
7468,
13342,
1053,
3295,
5041,
261,
29892,
4072,
13,
3166,
7468,
13342,
29889,
13369,
261,
29889,
26705,
1053,
1317,
5612,
368,
5072,
29892,
3553,
5072,
13,
13,
3166,
9225,
29889,
1271,
21513,
1053,
289,
11310,
29892,
15504,
29890,
11310,
13,
3166,
9225,
29889,
3179,
9306,
29889,
6406,
8513,
1053,
6597,
29918,
333,
13,
13,
13,
12674,
822,
9920,
29918,
2571,
29898,
4906,
29901,
4072,
29889,
3728,
1125,
13,
1678,
1018,
29901,
13,
4706,
1404,
29918,
333,
353,
6597,
29918,
333,
29898,
4906,
29897,
13,
1678,
5174,
7865,
2392,
408,
429,
29901,
13,
4706,
736,
7272,
2643,
29889,
3445,
368,
29898,
710,
29898,
735,
876,
13,
1678,
289,
11310,
29889,
1202,
29898,
524,
29898,
1792,
29918,
333,
876,
13,
1678,
7272,
2643,
29889,
3445,
368,
29898,
13,
4706,
285,
29908,
1367,
426,
1792,
29918,
333,
29913,
1447,
3102,
29942,
2510,
490,
531,
18021,
1077,
29975,
843,
717,
11866,
2430,
29889,
376,
13,
4706,
285,
29908,
30013,
641,
733,
8384,
29932,
2476,
1685,
19524,
1413,
25032,
24849,
18636,
9718,
2584,
12052,
29932,
863,
1521,
8418,
6195,
614,
13610,
29892,
4281,
1077,
29975,
843,
717,
11866,
1213,
13,
1678,
1723,
13,
13,
13,
12674,
822,
9920,
29918,
17505,
2571,
29898,
4906,
29901,
4072,
29889,
3728,
1125,
13,
1678,
1018,
29901,
13,
4706,
1404,
29918,
333,
353,
6597,
29918,
333,
29898,
4906,
29897,
13,
1678,
5174,
7865,
2392,
408,
429,
29901,
13,
4706,
736,
7272,
2643,
29889,
3445,
368,
29898,
710,
29898,
735,
876,
13,
1678,
15504,
29890,
11310,
29889,
1202,
29898,
524,
29898,
1792,
29918,
333,
876,
13,
1678,
7272,
2643,
29889,
3445,
368,
29898,
13,
4706,
285,
29908,
1367,
426,
1792,
29918,
333,
29913,
1447,
3102,
29942,
2510,
490,
531,
18021,
531,
10300,
13050,
1077,
29975,
843,
717,
11866,
2430,
29889,
376,
13,
4706,
285,
29908,
30013,
641,
733,
8384,
29932,
2476,
1685,
19524,
1413,
25032,
24849,
18636,
9718,
2584,
1538,
863,
4372,
1257,
29892,
4281,
1077,
29975,
843,
717,
11866,
1213,
13,
1678,
1723,
13,
13,
13,
12674,
822,
9920,
29918,
348,
2571,
29898,
4906,
29901,
4072,
29889,
3728,
1125,
13,
1678,
1018,
29901,
13,
4706,
1404,
29918,
333,
353,
6597,
29918,
333,
29898,
4906,
29897,
13,
1678,
5174,
7865,
2392,
408,
429,
29901,
13,
4706,
736,
7272,
2643,
29889,
3445,
368,
29898,
710,
29898,
735,
876,
13,
1678,
1404,
29918,
333,
353,
938,
29898,
1792,
29918,
333,
29897,
13,
1678,
411,
21301,
29898,
2558,
2392,
1125,
13,
4706,
289,
11310,
29889,
5992,
29898,
1792,
29918,
333,
29897,
13,
1678,
411,
21301,
29898,
2558,
2392,
1125,
13,
4706,
15504,
29890,
11310,
29889,
5992,
29898,
1792,
29918,
333,
29897,
13,
1678,
7272,
2643,
29889,
3445,
368,
29898,
29888,
29908,
1367,
426,
1792,
29918,
333,
29913,
3212,
29975,
843,
717,
11866,
1159,
13,
13,
13,
12674,
822,
9920,
29918,
1761,
29918,
29890,
11310,
29898,
4906,
29901,
4072,
29889,
3728,
1125,
13,
1678,
756,
29918,
29890,
550,
353,
7431,
29898,
29890,
11310,
29897,
1405,
29871,
29900,
470,
7431,
29898,
17505,
29890,
11310,
29897,
1405,
29871,
29900,
13,
1678,
565,
451,
756,
29918,
29890,
550,
29901,
13,
4706,
7272,
2643,
29889,
12011,
703,
30029,
1257,
1077,
29975,
843,
717,
11866,
2430,
18636,
9718,
11572,
1159,
13,
4706,
736,
13,
1678,
1121,
353,
5159,
13,
1678,
565,
7431,
29898,
29890,
11310,
29897,
1405,
29871,
29900,
29901,
13,
4706,
1121,
29889,
4397,
703,
30008,
18021,
1077,
29975,
843,
717,
11866,
2430,
29901,
1159,
13,
4706,
363,
2944,
297,
289,
11310,
29901,
13,
9651,
1121,
29889,
4397,
29898,
29888,
29908,
30119,
396,
333,
29912,
667,
27195,
13,
1678,
565,
7431,
29898,
17505,
29890,
11310,
29897,
1405,
29871,
29900,
29901,
13,
4706,
1121,
29889,
4397,
14182,
29876,
30008,
18021,
531,
10300,
13050,
1077,
29975,
843,
717,
11866,
2430,
29901,
1159,
13,
4706,
363,
2944,
297,
15504,
29890,
11310,
29901,
13,
9651,
1121,
29889,
4397,
29898,
29888,
29908,
30119,
396,
333,
29912,
667,
27195,
13,
13,
1678,
7272,
2643,
29889,
12011,
14182,
29876,
1642,
7122,
29898,
2914,
876,
13,
13,
13,
1753,
6036,
29918,
29890,
550,
29918,
3179,
9306,
29898,
6099,
29901,
3295,
5041,
261,
29892,
4113,
29918,
13496,
29918,
333,
29901,
938,
1125,
13,
1678,
270,
29886,
29889,
9573,
29918,
4906,
29918,
13789,
29898,
9006,
29918,
2571,
29892,
1317,
5612,
368,
5072,
29898,
275,
29918,
3445,
368,
29922,
5574,
511,
3553,
5072,
29898,
13496,
29918,
333,
29922,
6406,
29918,
13496,
29918,
333,
511,
13,
462,
18884,
8260,
543,
2571,
1159,
13,
1678,
270,
29886,
29889,
9573,
29918,
4906,
29918,
13789,
29898,
9006,
29918,
17505,
2571,
29892,
1317,
5612,
368,
5072,
29898,
275,
29918,
3445,
368,
29922,
5574,
511,
3553,
5072,
29898,
13496,
29918,
333,
29922,
6406,
29918,
13496,
29918,
333,
511,
13,
462,
18884,
8260,
543,
17505,
2571,
1159,
13,
1678,
270,
29886,
29889,
9573,
29918,
4906,
29918,
13789,
29898,
9006,
29918,
348,
2571,
29892,
1317,
5612,
368,
5072,
29898,
275,
29918,
3445,
368,
29922,
5574,
511,
3553,
5072,
29898,
13496,
29918,
333,
29922,
6406,
29918,
13496,
29918,
333,
511,
13,
462,
18884,
8260,
543,
348,
2571,
1159,
13,
1678,
270,
29886,
29889,
9573,
29918,
4906,
29918,
13789,
29898,
9006,
29918,
1761,
29918,
29890,
11310,
29892,
3553,
5072,
29898,
13496,
29918,
333,
29922,
6406,
29918,
13496,
29918,
333,
511,
13,
462,
18884,
8260,
543,
1761,
29918,
29890,
11310,
1159,
13,
2
] |
app/views.py | TheWolfA2/cppstyle | 0 | 173640 | import os
from flask import render_template, redirect, session, url_for, request, send_from_directory, jsonify
from app import app
from werkzeug import secure_filename
from style_grader_main import style_grader_driver
app.config['UPLOAD_FOLDER'] = 'uploads/'
app.config['ALLOWED_EXTENSIONS'] = set(['cpp', 'h'])
# @app.before_request
# def before_request():
# g.user = current_user
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']
@app.route('/', methods = ['GET'])
@app.route('/index', methods = ['GET', 'POST'])
def index():
# user = g.user
if request.method == 'POST':
# Get the FileStorage instance from request
file = request.files['file']
filename = secure_filename(file.filename)
# Render template with file info
return render_template('file.html',
filename = filename,
type = file.content_type)
return render_template('index.html',
title = 'Home')
@app.route('/uploadajax', methods=['POST'])
def add_numbers():
# Get the name of the uploaded files
uploaded_files = request.files.getlist("file[]")
filenames = []
for file in uploaded_files:
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join("app/" + app.config['UPLOAD_FOLDER'], filename))
filenames.append(filename)
list_of_online_files = []
for filename in filenames:
online_file = os.path.join("app/" + app.config['UPLOAD_FOLDER'], filename)
list_of_online_files.append(online_file)
response = style_grader_driver(list_of_online_files)
# if response != []:
# sub = Submission(user_id = g.user.id, passed_grader = False)
# else:
# sub = Submission(umich_id = g.user.umich_id, user_id = g.user.id, passed_grader = True)
# db.session.add(sub)
# db.session.commit()
return jsonify(errors=response)
@app.route('/uploads/<filename>')
def uploaded_file(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'],
filename)
# @app.route('/login', methods = ['GET', 'POST'])
# @oid.loginhandler
# def login():
# if g.user is not None and g.user.is_authenticated():
# return redirect(url_for('index'))
# form = LoginForm()
# if form.validate_on_submit():
# session['remember_me'] = form.remember_me.data
# return oid.try_login(form.openid.data, ask_for = ['nickname', 'email'])
# return render_template('login.html',
# title = 'Sign In',
# form = form,
# providers = app.config['OPENID_PROVIDERS'])
# @lm.user_loader
# def load_user(id):
# return User.query.get(int(id))
# @oid.after_login
# def after_login(resp):
# if resp.email is None or resp.email == "":
# flash('Invalid login. Please try again.')
# return redirect(url_for('login'))
# user = User.query.filter_by(email = resp.email).first()
# if user is None:
# nickname = resp.nickname
# if nickname is None or nickname == "":
# nickname = resp.email.split('@')[0]
# user = User(email = resp.email, passed_grader = 0)
# db.session.add(user)
# db.session.commit()
# remember_me = False
# if 'remember_me' in session:
# remember_me = session['remember_me']
# session.pop('remember_me', None)
# login_user(user, remember = remember_me)
# return redirect(request.args.get('next') or url_for('index'))
# @app.route('/logout')
# def logout():
# logout_user()
##return redirect(url_for('index'))
| [
1,
1053,
2897,
13,
3166,
29784,
1053,
4050,
29918,
6886,
29892,
6684,
29892,
4867,
29892,
3142,
29918,
1454,
29892,
2009,
29892,
3638,
29918,
3166,
29918,
12322,
29892,
4390,
1598,
13,
3166,
623,
1053,
623,
13,
3166,
23085,
13289,
1053,
11592,
29918,
9507,
13,
3166,
3114,
29918,
629,
1664,
29918,
3396,
1053,
3114,
29918,
629,
1664,
29918,
9465,
13,
13,
932,
29889,
2917,
1839,
4897,
29428,
29918,
29943,
5607,
8032,
2033,
353,
525,
9009,
29879,
22208,
13,
932,
29889,
2917,
1839,
1964,
27998,
3352,
29918,
12194,
1430,
13381,
29903,
2033,
353,
731,
18959,
8223,
742,
525,
29882,
11287,
13,
13,
29937,
732,
932,
29889,
11083,
29918,
3827,
13,
29937,
822,
1434,
29918,
3827,
7295,
13,
29937,
268,
330,
29889,
1792,
353,
1857,
29918,
1792,
13,
13,
1753,
6068,
29918,
1445,
29898,
9507,
1125,
13,
1678,
736,
525,
6169,
297,
10422,
322,
320,
13,
965,
10422,
29889,
2288,
2830,
12839,
742,
29871,
29896,
9601,
29896,
29962,
297,
623,
29889,
2917,
1839,
1964,
27998,
3352,
29918,
12194,
1430,
13381,
29903,
2033,
13,
13,
29992,
932,
29889,
13134,
11219,
742,
29871,
3519,
353,
6024,
7194,
11287,
13,
29992,
932,
29889,
13134,
11219,
2248,
742,
3519,
353,
6024,
7194,
742,
525,
5438,
11287,
13,
1753,
2380,
7295,
13,
1678,
396,
1404,
353,
330,
29889,
1792,
13,
13,
1678,
565,
2009,
29889,
5696,
1275,
525,
5438,
2396,
13,
4706,
396,
3617,
278,
3497,
10486,
2777,
515,
2009,
13,
4706,
934,
353,
2009,
29889,
5325,
1839,
1445,
2033,
13,
4706,
10422,
353,
11592,
29918,
9507,
29898,
1445,
29889,
9507,
29897,
13,
4706,
396,
26000,
4472,
411,
934,
5235,
13,
4706,
736,
4050,
29918,
6886,
877,
1445,
29889,
1420,
742,
13,
9651,
10422,
353,
10422,
29892,
13,
9651,
1134,
353,
934,
29889,
3051,
29918,
1853,
29897,
13,
1678,
736,
4050,
29918,
6886,
877,
2248,
29889,
1420,
742,
13,
462,
9651,
3611,
353,
525,
11184,
1495,
13,
13,
29992,
932,
29889,
13134,
11219,
786,
417,
1114,
6487,
742,
3519,
29922,
1839,
5438,
11287,
13,
1753,
788,
29918,
20326,
7295,
13,
1678,
396,
3617,
278,
1024,
310,
278,
20373,
2066,
13,
1678,
20373,
29918,
5325,
353,
2009,
29889,
5325,
29889,
657,
1761,
703,
1445,
2636,
1159,
13,
1678,
977,
264,
1280,
353,
5159,
13,
1678,
363,
934,
297,
20373,
29918,
5325,
29901,
13,
4706,
565,
934,
322,
6068,
29918,
1445,
29898,
1445,
29889,
9507,
1125,
13,
9651,
10422,
353,
11592,
29918,
9507,
29898,
1445,
29889,
9507,
29897,
13,
9651,
934,
29889,
7620,
29898,
359,
29889,
2084,
29889,
7122,
703,
932,
12975,
718,
623,
29889,
2917,
1839,
4897,
29428,
29918,
29943,
5607,
8032,
7464,
10422,
876,
13,
9651,
977,
264,
1280,
29889,
4397,
29898,
9507,
29897,
13,
13,
1678,
1051,
29918,
974,
29918,
14627,
29918,
5325,
353,
5159,
13,
1678,
363,
10422,
297,
977,
264,
1280,
29901,
13,
4706,
7395,
29918,
1445,
353,
2897,
29889,
2084,
29889,
7122,
703,
932,
12975,
718,
623,
29889,
2917,
1839,
4897,
29428,
29918,
29943,
5607,
8032,
7464,
10422,
29897,
13,
4706,
1051,
29918,
974,
29918,
14627,
29918,
5325,
29889,
4397,
29898,
14627,
29918,
1445,
29897,
13,
13,
1678,
2933,
353,
3114,
29918,
629,
1664,
29918,
9465,
29898,
1761,
29918,
974,
29918,
14627,
29918,
5325,
29897,
13,
1678,
396,
565,
2933,
2804,
5159,
29901,
13,
1678,
396,
268,
1014,
353,
3323,
6737,
29898,
1792,
29918,
333,
353,
330,
29889,
1792,
29889,
333,
29892,
4502,
29918,
629,
1664,
353,
7700,
29897,
13,
1678,
396,
1683,
29901,
13,
1678,
396,
268,
1014,
353,
29871,
3323,
6737,
29898,
398,
436,
29918,
333,
353,
330,
29889,
1792,
29889,
398,
436,
29918,
333,
29892,
1404,
29918,
333,
353,
330,
29889,
1792,
29889,
333,
29892,
4502,
29918,
629,
1664,
353,
5852,
29897,
13,
13,
1678,
396,
4833,
29889,
7924,
29889,
1202,
29898,
1491,
29897,
13,
1678,
396,
4833,
29889,
7924,
29889,
15060,
580,
13,
13,
1678,
736,
4390,
1598,
29898,
12523,
29922,
5327,
29897,
13,
13,
29992,
932,
29889,
13134,
11219,
9009,
29879,
29914,
29966,
9507,
29958,
1495,
13,
1753,
20373,
29918,
1445,
29898,
9507,
1125,
13,
1678,
736,
3638,
29918,
3166,
29918,
12322,
29898,
932,
29889,
2917,
1839,
4897,
29428,
29918,
29943,
5607,
8032,
7464,
13,
462,
1669,
10422,
29897,
13,
13,
29937,
732,
932,
29889,
13134,
11219,
7507,
742,
3519,
353,
6024,
7194,
742,
525,
5438,
11287,
13,
29937,
732,
3398,
29889,
7507,
13789,
13,
29937,
822,
6464,
7295,
13,
29937,
268,
565,
330,
29889,
1792,
338,
451,
6213,
322,
330,
29889,
1792,
29889,
275,
29918,
27218,
630,
7295,
13,
29937,
308,
736,
6684,
29898,
2271,
29918,
1454,
877,
2248,
8785,
13,
29937,
268,
883,
353,
19130,
2500,
580,
13,
29937,
268,
565,
883,
29889,
15480,
29918,
265,
29918,
7892,
7295,
13,
29937,
308,
4867,
1839,
1745,
1096,
29918,
1004,
2033,
353,
883,
29889,
1745,
1096,
29918,
1004,
29889,
1272,
13,
29937,
308,
736,
288,
333,
29889,
2202,
29918,
7507,
29898,
689,
29889,
3150,
333,
29889,
1272,
29892,
2244,
29918,
1454,
353,
6024,
19254,
978,
742,
525,
5269,
11287,
13,
29937,
268,
736,
4050,
29918,
6886,
877,
7507,
29889,
1420,
742,
13,
29937,
308,
3611,
353,
525,
10140,
512,
742,
13,
29937,
308,
883,
353,
883,
29892,
13,
29937,
308,
1326,
11376,
353,
623,
29889,
2917,
1839,
4590,
1430,
1367,
29918,
8618,
13044,
23598,
11287,
13,
13,
13,
29937,
732,
21457,
29889,
1792,
29918,
12657,
13,
29937,
822,
2254,
29918,
1792,
29898,
333,
1125,
13,
29937,
268,
736,
4911,
29889,
1972,
29889,
657,
29898,
524,
29898,
333,
876,
13,
13,
29937,
732,
3398,
29889,
7045,
29918,
7507,
13,
29937,
822,
1156,
29918,
7507,
29898,
13713,
1125,
13,
29937,
268,
565,
4613,
29889,
5269,
338,
6213,
470,
4613,
29889,
5269,
1275,
376,
1115,
13,
29937,
308,
11013,
877,
13919,
6464,
29889,
3529,
1018,
1449,
29889,
1495,
13,
29937,
308,
736,
6684,
29898,
2271,
29918,
1454,
877,
7507,
8785,
13,
29937,
268,
1404,
353,
4911,
29889,
1972,
29889,
4572,
29918,
1609,
29898,
5269,
353,
4613,
29889,
5269,
467,
4102,
580,
13,
29937,
268,
565,
1404,
338,
6213,
29901,
13,
29937,
308,
25985,
978,
353,
4613,
29889,
19254,
978,
13,
29937,
308,
565,
25985,
978,
338,
6213,
470,
25985,
978,
1275,
376,
1115,
13,
29937,
632,
25985,
978,
353,
4613,
29889,
5269,
29889,
5451,
877,
29992,
29861,
29900,
29962,
13,
29937,
308,
1404,
353,
4911,
29898,
5269,
353,
4613,
29889,
5269,
29892,
4502,
29918,
629,
1664,
353,
29871,
29900,
29897,
13,
29937,
308,
4833,
29889,
7924,
29889,
1202,
29898,
1792,
29897,
13,
29937,
308,
4833,
29889,
7924,
29889,
15060,
580,
13,
29937,
268,
6456,
29918,
1004,
353,
7700,
13,
29937,
268,
565,
525,
1745,
1096,
29918,
1004,
29915,
297,
4867,
29901,
13,
29937,
308,
6456,
29918,
1004,
353,
4867,
1839,
1745,
1096,
29918,
1004,
2033,
13,
29937,
308,
4867,
29889,
7323,
877,
1745,
1096,
29918,
1004,
742,
6213,
29897,
13,
29937,
268,
6464,
29918,
1792,
29898,
1792,
29892,
6456,
353,
6456,
29918,
1004,
29897,
13,
29937,
268,
736,
6684,
29898,
3827,
29889,
5085,
29889,
657,
877,
4622,
1495,
470,
3142,
29918,
1454,
877,
2248,
8785,
13,
13,
29937,
732,
932,
29889,
13134,
11219,
1188,
449,
1495,
13,
29937,
822,
1480,
449,
7295,
13,
29937,
268,
1480,
449,
29918,
1792,
580,
13,
2277,
2457,
6684,
29898,
2271,
29918,
1454,
877,
2248,
8785,
13,
2
] |
main.py | IgorZyktin/Colortex | 17 | 76010 | <filename>main.py
"""
Colortex - simple textual painter
Based on:
https://gist.github.com/BigglesZX/4016539
https://gist.github.com/almost/d2832d0998ad9dfec2cacef934e7d247
"""
import ct_images
import ct_files
def main():
"""
Main flow
"""
print('--- Colortex image conversion script ---')
total_converted = 0
local_files = ct_files.get_filenames()
if not local_files:
print('Nothing to convert')
return
for i, file_dict in enumerate(local_files, start=1):
total_converted += ct_images.convert(file_dict, i, len(local_files))
if total_converted:
print(f'\nConversion complete, {total_converted} files converted.')
else:
print('\nComplete. No files converted.')
if __name__ == '__main__':
main()
| [
1,
529,
9507,
29958,
3396,
29889,
2272,
13,
15945,
29908,
13,
13,
1678,
9159,
4776,
448,
2560,
1426,
950,
23187,
13,
13,
1678,
16564,
373,
29901,
13,
4706,
2045,
597,
29887,
391,
29889,
3292,
29889,
510,
29914,
6970,
29887,
793,
29999,
29990,
29914,
29946,
29900,
29896,
29953,
29945,
29941,
29929,
13,
4706,
2045,
597,
29887,
391,
29889,
3292,
29889,
510,
29914,
284,
3242,
29914,
29881,
29906,
29947,
29941,
29906,
29881,
29900,
29929,
29929,
29947,
328,
29929,
2176,
687,
29906,
29883,
815,
29888,
29929,
29941,
29946,
29872,
29955,
29881,
29906,
29946,
29955,
13,
13,
15945,
29908,
13,
5215,
274,
29873,
29918,
8346,
13,
5215,
274,
29873,
29918,
5325,
13,
13,
13,
1753,
1667,
7295,
13,
1678,
9995,
13,
1678,
4241,
4972,
13,
1678,
9995,
13,
1678,
1596,
877,
5634,
9159,
4776,
1967,
11301,
2471,
11474,
1495,
13,
13,
1678,
3001,
29918,
13441,
287,
353,
29871,
29900,
13,
1678,
1887,
29918,
5325,
353,
274,
29873,
29918,
5325,
29889,
657,
29918,
1777,
264,
1280,
580,
13,
13,
1678,
565,
451,
1887,
29918,
5325,
29901,
13,
4706,
1596,
877,
26521,
304,
3588,
1495,
13,
4706,
736,
13,
13,
1678,
363,
474,
29892,
934,
29918,
8977,
297,
26985,
29898,
2997,
29918,
5325,
29892,
1369,
29922,
29896,
1125,
13,
4706,
3001,
29918,
13441,
287,
4619,
274,
29873,
29918,
8346,
29889,
13441,
29898,
1445,
29918,
8977,
29892,
474,
29892,
7431,
29898,
2997,
29918,
5325,
876,
13,
13,
1678,
565,
3001,
29918,
13441,
287,
29901,
13,
4706,
1596,
29898,
29888,
12764,
29876,
1168,
3259,
4866,
29892,
426,
7827,
29918,
13441,
287,
29913,
2066,
11543,
29889,
1495,
13,
1678,
1683,
29901,
13,
4706,
1596,
28909,
29876,
17813,
29889,
1939,
2066,
11543,
29889,
1495,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
1667,
580,
13,
2
] |
icrawler/utils/session.py | awesome-archive/icrawler | 0 | 86127 | <filename>icrawler/utils/session.py
import requests
from six.moves.urllib.parse import urlsplit
class Session(requests.Session):
def __init__(self, proxy_pool):
super(Session, self).__init__()
self.proxy_pool = proxy_pool
def _url_scheme(self, url):
return urlsplit(url).scheme
def get(self, url, **kwargs):
proxy = self.proxy_pool.get_next(protocol=self._url_scheme(url))
if proxy is None:
return super(Session, self).get(url, **kwargs)
try:
response = super(Session, self).get(url, proxies=proxy.format(),
**kwargs)
except requests.exceptions.ConnectionError:
self.proxy_pool.decrease_weight(proxy)
raise
except:
raise
else:
self.proxy_pool.increase_weight(proxy)
return response
def post(self, url, data=None, json=None, **kwargs):
proxy = self.proxy_pool.get_next(protocol=self._url_scheme(url))
if proxy is None:
return super(Session, self).get(url, data, json, **kwargs)
try:
response = super(Session, self).post(url, data, json,
proxies=proxy.format(),
**kwargs)
except requests.exceptions.ConnectionError:
self.proxy_pool.decrease_weight(proxy)
raise
except:
raise
else:
self.proxy_pool.increase_weight(proxy)
return response
| [
1,
529,
9507,
29958,
293,
1610,
1358,
29914,
13239,
29914,
7924,
29889,
2272,
13,
5215,
7274,
13,
3166,
4832,
29889,
13529,
267,
29889,
2271,
1982,
29889,
5510,
1053,
3142,
5451,
13,
13,
13,
1990,
16441,
29898,
24830,
29889,
7317,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
10166,
29918,
10109,
1125,
13,
4706,
2428,
29898,
7317,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
14701,
29918,
10109,
353,
10166,
29918,
10109,
13,
13,
1678,
822,
903,
2271,
29918,
816,
2004,
29898,
1311,
29892,
3142,
1125,
13,
4706,
736,
3142,
5451,
29898,
2271,
467,
816,
2004,
13,
13,
1678,
822,
679,
29898,
1311,
29892,
3142,
29892,
3579,
19290,
1125,
13,
4706,
10166,
353,
1583,
29889,
14701,
29918,
10109,
29889,
657,
29918,
4622,
29898,
20464,
29922,
1311,
3032,
2271,
29918,
816,
2004,
29898,
2271,
876,
13,
4706,
565,
10166,
338,
6213,
29901,
13,
9651,
736,
2428,
29898,
7317,
29892,
1583,
467,
657,
29898,
2271,
29892,
3579,
19290,
29897,
13,
4706,
1018,
29901,
13,
9651,
2933,
353,
2428,
29898,
7317,
29892,
1583,
467,
657,
29898,
2271,
29892,
410,
29916,
583,
29922,
14701,
29889,
4830,
3285,
13,
462,
462,
18884,
3579,
19290,
29897,
13,
4706,
5174,
7274,
29889,
11739,
29879,
29889,
5350,
2392,
29901,
13,
9651,
1583,
29889,
14701,
29918,
10109,
29889,
311,
1037,
559,
29918,
7915,
29898,
14701,
29897,
13,
9651,
12020,
13,
4706,
5174,
29901,
13,
9651,
12020,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
14701,
29918,
10109,
29889,
262,
1037,
559,
29918,
7915,
29898,
14701,
29897,
13,
9651,
736,
2933,
13,
13,
1678,
822,
1400,
29898,
1311,
29892,
3142,
29892,
848,
29922,
8516,
29892,
4390,
29922,
8516,
29892,
3579,
19290,
1125,
13,
4706,
10166,
353,
1583,
29889,
14701,
29918,
10109,
29889,
657,
29918,
4622,
29898,
20464,
29922,
1311,
3032,
2271,
29918,
816,
2004,
29898,
2271,
876,
13,
4706,
565,
10166,
338,
6213,
29901,
13,
9651,
736,
2428,
29898,
7317,
29892,
1583,
467,
657,
29898,
2271,
29892,
848,
29892,
4390,
29892,
3579,
19290,
29897,
13,
4706,
1018,
29901,
13,
9651,
2933,
353,
2428,
29898,
7317,
29892,
1583,
467,
2490,
29898,
2271,
29892,
848,
29892,
4390,
29892,
13,
462,
462,
462,
410,
29916,
583,
29922,
14701,
29889,
4830,
3285,
13,
462,
462,
462,
3579,
19290,
29897,
13,
4706,
5174,
7274,
29889,
11739,
29879,
29889,
5350,
2392,
29901,
13,
9651,
1583,
29889,
14701,
29918,
10109,
29889,
311,
1037,
559,
29918,
7915,
29898,
14701,
29897,
13,
9651,
12020,
13,
4706,
5174,
29901,
13,
9651,
12020,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
14701,
29918,
10109,
29889,
262,
1037,
559,
29918,
7915,
29898,
14701,
29897,
13,
9651,
736,
2933,
13,
2
] |
passwordValidator.py | valentinsoare/currentlyLearningPythonProjectsBased | 1 | 108516 | #!/usr/bin/python3
import re
def catch_input():
password = input(f'\n\033[1;31m *Enter Your Password for Validation:\033[0m ')
return password
def password_validator_rules(input_rule, given_password):
rules = re.compile(input_rule)
pattern = re.search(rules, given_password)
return True if pattern else False
def main():
password_to_check = catch_input()
checking = False
while not checking:
if password_validator_rules(r'([A-Za-z0-9].*[\-\s.,_]){5,}', password_to_check):
print(f'\n\033[1;34m **Basic rule applies here, looks ok.\033[0m\n')
checking = True
elif password_validator_rules(r'(?=.{8,})([A-Z].*)([a-z].*)([0-9].*)([@#$%^&+=].*)', password_to_check):
print(f'\n\033[1;34m **Eight characters rule applies here, we good to go.\033[0m\n')
checking = True
else:
print(f'\n\033[1;41m***ERROR, given password is not within desired guidelines. Please try again.\033[0m')
password_to_check = catch_input()
main()
| [
1,
18787,
4855,
29914,
2109,
29914,
4691,
29941,
13,
13,
5215,
337,
13,
13,
13,
1753,
4380,
29918,
2080,
7295,
13,
1678,
4800,
353,
1881,
29898,
29888,
12764,
29876,
29905,
29900,
29941,
29941,
29961,
29896,
29936,
29941,
29896,
29885,
334,
10399,
3575,
25280,
363,
15758,
362,
3583,
29900,
29941,
29941,
29961,
29900,
29885,
25710,
13,
1678,
736,
4800,
13,
13,
13,
1753,
4800,
29918,
3084,
1061,
29918,
19238,
29898,
2080,
29918,
7491,
29892,
2183,
29918,
5630,
1125,
13,
1678,
6865,
353,
337,
29889,
12198,
29898,
2080,
29918,
7491,
29897,
13,
1678,
4766,
353,
337,
29889,
4478,
29898,
19238,
29892,
2183,
29918,
5630,
29897,
13,
13,
1678,
736,
5852,
565,
4766,
1683,
7700,
13,
13,
13,
1753,
1667,
7295,
13,
1678,
4800,
29918,
517,
29918,
3198,
353,
4380,
29918,
2080,
580,
13,
1678,
8454,
353,
7700,
13,
13,
1678,
1550,
451,
8454,
29901,
13,
4706,
565,
4800,
29918,
3084,
1061,
29918,
19238,
29898,
29878,
29915,
4197,
29909,
29899,
29999,
29874,
29899,
29920,
29900,
29899,
29929,
1822,
29930,
7110,
2612,
29879,
1696,
29918,
2314,
29912,
29945,
29892,
29913,
742,
4800,
29918,
517,
29918,
3198,
1125,
13,
9651,
1596,
29898,
29888,
12764,
29876,
29905,
29900,
29941,
29941,
29961,
29896,
29936,
29941,
29946,
29885,
3579,
16616,
5751,
16058,
1244,
29892,
3430,
3431,
7790,
29900,
29941,
29941,
29961,
29900,
29885,
29905,
29876,
1495,
13,
9651,
8454,
353,
5852,
13,
4706,
25342,
4800,
29918,
3084,
1061,
29918,
19238,
29898,
29878,
29915,
10780,
21098,
29912,
29947,
29892,
1800,
4197,
29909,
29899,
29999,
1822,
7528,
4197,
29874,
29899,
29920,
1822,
7528,
4197,
29900,
29899,
29929,
1822,
7528,
4197,
29992,
29937,
29938,
29995,
29985,
29987,
23661,
1822,
7528,
742,
4800,
29918,
517,
29918,
3198,
1125,
13,
9651,
1596,
29898,
29888,
12764,
29876,
29905,
29900,
29941,
29941,
29961,
29896,
29936,
29941,
29946,
29885,
3579,
29923,
523,
4890,
5751,
16058,
1244,
29892,
591,
1781,
304,
748,
7790,
29900,
29941,
29941,
29961,
29900,
29885,
29905,
29876,
1495,
13,
9651,
8454,
353,
5852,
13,
4706,
1683,
29901,
13,
9651,
1596,
29898,
29888,
12764,
29876,
29905,
29900,
29941,
29941,
29961,
29896,
29936,
29946,
29896,
29885,
17435,
11432,
29892,
2183,
4800,
338,
451,
2629,
7429,
1410,
10652,
1475,
29889,
3529,
1018,
1449,
7790,
29900,
29941,
29941,
29961,
29900,
29885,
1495,
13,
9651,
4800,
29918,
517,
29918,
3198,
353,
4380,
29918,
2080,
580,
13,
13,
13,
3396,
580,
13,
2
] |
mainapp/migrations/0001_initial.py | CheboiDerrick/hood-alert | 0 | 170252 | <gh_stars>0
# Generated by Django 3.2.9 on 2021-11-02 22:27
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Neighborhood',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=70)),
('location', models.CharField(max_length=70)),
('occupant_count', models.IntegerField()),
('user', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Profile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('photo', models.ImageField(blank=True, null=True, upload_to='posts/')),
('name', models.CharField(max_length=100)),
('email', models.EmailField(max_length=254, unique=True)),
('neighborhood', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='mainapp.neighborhood')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Post',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('detail', models.TextField()),
('image', models.ImageField(blank=True, null=True, upload_to='posts/')),
('posted_on', models.DateTimeField(auto_now_add=True)),
('neighborhood', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mainapp.neighborhood')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-posted_on'],
},
),
migrations.CreateModel(
name='Contacts',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('phone', models.CharField(max_length=50)),
('neighborhood', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='users', to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Business',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.TextField(blank=True, null=True)),
('email', models.EmailField(blank=True, max_length=254, null=True, unique=True)),
('phone', models.CharField(blank=True, max_length=50, null=True)),
('neighborhood', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mainapp.neighborhood')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
3251,
630,
491,
15337,
29871,
29941,
29889,
29906,
29889,
29929,
373,
29871,
29906,
29900,
29906,
29896,
29899,
29896,
29896,
29899,
29900,
29906,
29871,
29906,
29906,
29901,
29906,
29955,
13,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
2585,
1053,
9725,
800,
29892,
4733,
13,
5215,
9557,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
13,
13,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
13,
13,
1678,
2847,
353,
5852,
13,
13,
1678,
9962,
353,
518,
13,
4706,
9725,
800,
29889,
2774,
932,
519,
29918,
10836,
29898,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
511,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
8139,
1141,
4089,
6614,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
6970,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29955,
29900,
8243,
13,
18884,
6702,
5479,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29955,
29900,
8243,
13,
18884,
6702,
16770,
424,
29918,
2798,
742,
4733,
29889,
7798,
3073,
25739,
13,
18884,
6702,
1792,
742,
4733,
29889,
27755,
2558,
29898,
4381,
29922,
29896,
29892,
373,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
13909,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
6970,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
21596,
742,
4733,
29889,
2940,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
29892,
6441,
29918,
517,
2433,
14080,
29914,
1495,
511,
13,
18884,
6702,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
18884,
6702,
5269,
742,
4733,
29889,
9823,
3073,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29946,
29892,
5412,
29922,
5574,
8243,
13,
18884,
6702,
484,
1141,
4089,
6614,
742,
4733,
29889,
6716,
1762,
6716,
3073,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
3396,
932,
29889,
484,
1141,
4089,
6614,
1495,
511,
13,
18884,
6702,
1792,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
6747,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
6970,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
3257,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
18884,
6702,
16432,
742,
4733,
29889,
15778,
25739,
13,
18884,
6702,
3027,
742,
4733,
29889,
2940,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
29892,
6441,
29918,
517,
2433,
14080,
29914,
1495,
511,
13,
18884,
6702,
2490,
287,
29918,
265,
742,
4733,
29889,
11384,
3073,
29898,
6921,
29918,
3707,
29918,
1202,
29922,
5574,
8243,
13,
18884,
6702,
484,
1141,
4089,
6614,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
3396,
932,
29889,
484,
1141,
4089,
6614,
1495,
511,
13,
18884,
6702,
1792,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
8243,
13,
9651,
21251,
13,
9651,
3987,
3790,
13,
18884,
525,
2098,
292,
2396,
6024,
29899,
2490,
287,
29918,
265,
7464,
13,
9651,
2981,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
13443,
29879,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
6970,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
18884,
6702,
6710,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29945,
29900,
8243,
13,
18884,
6702,
484,
1141,
4089,
6614,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
8243,
13,
18884,
6702,
1792,
742,
4733,
29889,
27755,
2558,
29898,
4381,
29922,
29896,
29892,
373,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
4475,
29918,
978,
2433,
7193,
742,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
16890,
3335,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
6970,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
13,
18884,
6702,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29896,
29900,
29900,
8243,
13,
18884,
6702,
8216,
742,
4733,
29889,
15778,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
8243,
13,
18884,
6702,
5269,
742,
4733,
29889,
9823,
3073,
29898,
19465,
29922,
5574,
29892,
4236,
29918,
2848,
29922,
29906,
29945,
29946,
29892,
1870,
29922,
5574,
29892,
5412,
29922,
5574,
8243,
13,
18884,
6702,
6710,
742,
4733,
29889,
27890,
29898,
19465,
29922,
5574,
29892,
4236,
29918,
2848,
29922,
29945,
29900,
29892,
1870,
29922,
5574,
8243,
13,
18884,
6702,
484,
1141,
4089,
6614,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
2433,
3396,
932,
29889,
484,
1141,
4089,
6614,
1495,
511,
13,
18884,
6702,
1792,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
29907,
3289,
5454,
2287,
29892,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
8243,
13,
9651,
21251,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
pendulum.py | x75/playground | 0 | 1604798 | <gh_stars>0
"""Quick test of data asymmetry in a motor driven pendulum"""
import numpy as np
import matplotlib
import matplotlib.gridspec as gridspec
# matplotlib.use("Cairo")
import matplotlib.pyplot as plt
l = 2e-0
g = 9.81
m = 1.0
cf = -4.8
# cf = -1.45
fr = 1e-2
one_over_fr = 1 - fr
scale = 1.0 # 0.1
# dt = 0.5e-2
dt = 1e-2
# dt = 1e-1
numsteps = 10000
x = np.zeros((numsteps, 3))
# x[0,0] = -np.pi/2.0
x[0,0] = np.pi/2.1
g *= scale
cf *= scale
for i in range(1, numsteps):
x[i,2] = (-g * m) / l * np.sin(x[i-1,0]) + cf + np.random.normal(0.0, 5e-0)
x[i,1] = one_over_fr * x[i-1,1] + x[i,2] * dt
x[i,0] = x[i-1,0] + x[i,1] * dt
if x[i,0] > (1*np.pi):
print("larger", x)
x[i,0] = x[i,0] - (2 * np.pi)
elif x[i,0] < (-1*np.pi):
print("smaller", x)
x[i,0] = x[i,0] + (2 * np.pi)
gs = gridspec.GridSpec(2, 3)
fig = plt.figure()
ax1 = fig.add_subplot(gs[0,:2])
# ax1.plot(np.abs(x))
# ax1.plot(x, "k,")
ax1.plot(x, "k-")
ax2 = fig.add_subplot(gs[0,2])
# si = x[:,0] ==
sls = 2000 # 1980+130
print("sls", sls)
# sls = x[sls:,0] == np.pi * 0.4
print("x[sls:,0]", x[sls:,0].shape)
print("x[sls:,0] < (np.pi * 0.4)", (x[sls:,0] < (np.pi * 0.4)))
print("x[sls:,0] > (np.pi * 0.39)", (x[sls:,0] > (np.pi * 0.39)))
sls += np.argwhere(np.logical_and(x[sls:,0] > (np.pi * 0.40), x[sls:,0] < (np.pi * 0.41)))[0,0]
sloffs = 10
sle = sloffs + np.argwhere(np.logical_and(x[sls+sloffs:,0] > (np.pi * 0.40), x[sls+sloffs:,0] < (np.pi * 0.41)))[0,0]
print("sle", sle)
print("x[sls+sloffs+sle:,0]", x[sls+sloffs+sle:,0])
# sle = np.argwhere(np.logical_and(x[sls:,0] > (np.pi * 0.6), x[sls:,0] < (np.pi * 0.61)))[0,0]
print("sls", sls)
sll = sle # int(115*6.8)
sl = slice(sls, sls + sll)
# ax2.plot([0, np.cos(x[sl,0]) * l], [0, np.sin(x[sl,0]) * l], "k-", alpha=0.1)
for x_ in x[sl,0]:
ax2.plot([0, np.cos(x_) * l * 2], [0, np.sin(x_) * l * 2], "k-", linewidth=10.0, alpha=0.3)
ax2.plot(np.cos(x[sl,0]) * l * 2.05, np.sin(x[sl,0]) * l * 2.05, "ko", alpha=0.5)
ax2.set_aspect(1)
ax3 = fig.add_subplot(gs[1,:])
# print "x[:,0].shape", x[:,0].shape
# x_ = np.vstack((x[1:-1,0], x[2:,0])).T
rng = 1400 # detect freq of oscillation
x_ = np.vstack([x[i:-rng+i,0] for i in range(rng)]).T
print("x_", x_.shape)
# ax3.plot(x_[:,0], x_[:,1], "ko", alpha=0.25)
transoffs = 1000
x_comp = []
x_offs = []
y_comp = []
y_offs = []
for i in range(1, rng, 10):
# mp = ax3.scatter(x_[:,0], x_[:,i], c = x[:-rng,1], alpha=0.25)
# mp = ax3.scatter(x_[:,0], np.abs(x_[:,i]), c = x[:-rng,1], cmap=plt.get_cmap("gray"), alpha=float(i)/rng)
sl = slice(transoffs, transoffs + 1000)
x_comp.append(np.sin(x_[sl,0]))
x_offs.append(np.ones_like(x_comp[-1]) * (i % (rng/10)))
y_comp.append(np.sin(x_[sl,i]))
y_offs.append(np.ones_like(y_comp[-1]) * 2.5 * (i // (rng/10)))
# mp = ax3.scatter(x_comp + i, y_comp, c = x_comp - y_comp, cmap=plt.get_cmap("spectral"), alpha=float(i)/rng)
# ax3.set_yscale("log")
x_comp = np.array(x_comp).flatten()
x_offs = np.array(x_offs).flatten()
y_comp = np.array(y_comp).flatten()
y_offs = np.array(y_offs).flatten()
mp = ax3.scatter(x_comp + x_offs, y_comp + y_offs, c = x_comp - y_comp, cmap=plt.get_cmap("Spectral"), alpha=0.25, s=2, linewidths=0)
# mp = ax3.scatter(x_[:,0], x_[:,1], c = x[:-1,1], alpha=0.25)
fig.colorbar(mappable = mp, ax = ax3, orientation="horizontal", fraction=0.05)
# ax3.set_aspect(1)
plt.show()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
15945,
29908,
2182,
860,
1243,
310,
848,
16936,
2527,
719,
297,
263,
10992,
18225,
282,
355,
352,
398,
15945,
29908,
13,
13,
5215,
12655,
408,
7442,
13,
5215,
22889,
13,
13,
5215,
22889,
29889,
629,
4841,
3135,
408,
867,
4841,
3135,
13,
13,
29937,
22889,
29889,
1509,
703,
29907,
26025,
1159,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
13,
13,
29880,
353,
29871,
29906,
29872,
29899,
29900,
13,
29887,
353,
29871,
29929,
29889,
29947,
29896,
13,
29885,
353,
29871,
29896,
29889,
29900,
13,
6854,
353,
448,
29946,
29889,
29947,
29871,
13,
29937,
274,
29888,
353,
448,
29896,
29889,
29946,
29945,
29871,
13,
1341,
353,
29871,
29896,
29872,
29899,
29906,
13,
650,
29918,
957,
29918,
1341,
353,
29871,
29896,
448,
1424,
13,
13,
7052,
353,
29871,
29896,
29889,
29900,
396,
29871,
29900,
29889,
29896,
13,
13,
29937,
11636,
353,
29871,
29900,
29889,
29945,
29872,
29899,
29906,
13,
6008,
353,
29871,
29896,
29872,
29899,
29906,
13,
29937,
11636,
353,
29871,
29896,
29872,
29899,
29896,
13,
1949,
24530,
353,
29871,
29896,
29900,
29900,
29900,
29900,
13,
13,
29916,
353,
7442,
29889,
3298,
359,
3552,
1949,
24530,
29892,
29871,
29941,
876,
13,
29937,
921,
29961,
29900,
29892,
29900,
29962,
353,
448,
9302,
29889,
1631,
29914,
29906,
29889,
29900,
13,
29916,
29961,
29900,
29892,
29900,
29962,
353,
7442,
29889,
1631,
29914,
29906,
29889,
29896,
13,
13,
29887,
334,
29922,
6287,
13,
6854,
334,
29922,
6287,
13,
13,
1454,
474,
297,
3464,
29898,
29896,
29892,
954,
24530,
1125,
13,
1678,
921,
29961,
29875,
29892,
29906,
29962,
353,
8521,
29887,
334,
286,
29897,
847,
301,
334,
7442,
29889,
5223,
29898,
29916,
29961,
29875,
29899,
29896,
29892,
29900,
2314,
718,
274,
29888,
718,
7442,
29889,
8172,
29889,
8945,
29898,
29900,
29889,
29900,
29892,
29871,
29945,
29872,
29899,
29900,
29897,
13,
1678,
921,
29961,
29875,
29892,
29896,
29962,
353,
697,
29918,
957,
29918,
1341,
334,
921,
29961,
29875,
29899,
29896,
29892,
29896,
29962,
718,
921,
29961,
29875,
29892,
29906,
29962,
334,
11636,
13,
1678,
921,
29961,
29875,
29892,
29900,
29962,
353,
921,
29961,
29875,
29899,
29896,
29892,
29900,
29962,
718,
921,
29961,
29875,
29892,
29896,
29962,
334,
11636,
13,
1678,
565,
921,
29961,
29875,
29892,
29900,
29962,
1405,
313,
29896,
29930,
9302,
29889,
1631,
1125,
13,
4706,
1596,
703,
4675,
914,
613,
921,
29897,
13,
4706,
921,
29961,
29875,
29892,
29900,
29962,
353,
921,
29961,
29875,
29892,
29900,
29962,
448,
313,
29906,
334,
7442,
29889,
1631,
29897,
13,
1678,
25342,
921,
29961,
29875,
29892,
29900,
29962,
529,
8521,
29896,
29930,
9302,
29889,
1631,
1125,
13,
4706,
1596,
703,
9278,
261,
613,
921,
29897,
13,
4706,
921,
29961,
29875,
29892,
29900,
29962,
353,
921,
29961,
29875,
29892,
29900,
29962,
718,
313,
29906,
334,
7442,
29889,
1631,
29897,
13,
13,
3174,
353,
867,
4841,
3135,
29889,
5756,
10299,
29898,
29906,
29892,
29871,
29941,
29897,
13,
308,
13,
1003,
353,
14770,
29889,
4532,
580,
13,
1165,
29896,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
3174,
29961,
29900,
29892,
29901,
29906,
2314,
13,
29937,
4853,
29896,
29889,
5317,
29898,
9302,
29889,
6897,
29898,
29916,
876,
13,
29937,
4853,
29896,
29889,
5317,
29898,
29916,
29892,
376,
29895,
29892,
1159,
13,
1165,
29896,
29889,
5317,
29898,
29916,
29892,
376,
29895,
29899,
1159,
13,
1165,
29906,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
3174,
29961,
29900,
29892,
29906,
2314,
13,
29937,
1354,
353,
921,
7503,
29892,
29900,
29962,
1275,
13,
2536,
29879,
353,
29871,
29906,
29900,
29900,
29900,
396,
29871,
29896,
29929,
29947,
29900,
29974,
29896,
29941,
29900,
13,
2158,
703,
2536,
29879,
613,
2243,
29879,
29897,
13,
29937,
2243,
29879,
353,
921,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
1275,
7442,
29889,
1631,
334,
29871,
29900,
29889,
29946,
13,
2158,
703,
29916,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
613,
921,
29961,
2536,
29879,
29901,
29892,
29900,
1822,
12181,
29897,
13,
2158,
703,
29916,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
529,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29946,
19123,
313,
29916,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
529,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29946,
4961,
13,
2158,
703,
29916,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
1405,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29941,
29929,
19123,
313,
29916,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
1405,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29941,
29929,
4961,
13,
2536,
29879,
4619,
7442,
29889,
1191,
3062,
29898,
9302,
29889,
1188,
936,
29918,
392,
29898,
29916,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
1405,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29946,
29900,
511,
921,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
529,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29946,
29896,
4961,
29961,
29900,
29892,
29900,
29962,
13,
29879,
417,
600,
29879,
353,
29871,
29896,
29900,
13,
29879,
280,
29871,
353,
14216,
600,
29879,
718,
7442,
29889,
1191,
3062,
29898,
9302,
29889,
1188,
936,
29918,
392,
29898,
29916,
29961,
2536,
29879,
29974,
29879,
417,
600,
29879,
29901,
29892,
29900,
29962,
1405,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29946,
29900,
511,
921,
29961,
2536,
29879,
29974,
29879,
417,
600,
29879,
29901,
29892,
29900,
29962,
529,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29946,
29896,
4961,
29961,
29900,
29892,
29900,
29962,
13,
2158,
703,
29879,
280,
613,
12844,
29897,
13,
2158,
703,
29916,
29961,
2536,
29879,
29974,
29879,
417,
600,
29879,
29974,
29879,
280,
29901,
29892,
29900,
29962,
613,
921,
29961,
2536,
29879,
29974,
29879,
417,
600,
29879,
29974,
29879,
280,
29901,
29892,
29900,
2314,
13,
29937,
12844,
29871,
353,
7442,
29889,
1191,
3062,
29898,
9302,
29889,
1188,
936,
29918,
392,
29898,
29916,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
1405,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29953,
511,
921,
29961,
2536,
29879,
29901,
29892,
29900,
29962,
529,
313,
9302,
29889,
1631,
334,
29871,
29900,
29889,
29953,
29896,
4961,
29961,
29900,
29892,
29900,
29962,
13,
2158,
703,
2536,
29879,
613,
2243,
29879,
29897,
13,
29879,
645,
353,
12844,
396,
938,
29898,
29896,
29896,
29945,
29930,
29953,
29889,
29947,
29897,
13,
2536,
353,
22780,
29898,
2536,
29879,
29892,
2243,
29879,
718,
269,
645,
29897,
13,
29937,
4853,
29906,
29889,
5317,
4197,
29900,
29892,
7442,
29889,
3944,
29898,
29916,
29961,
2536,
29892,
29900,
2314,
334,
301,
1402,
518,
29900,
29892,
7442,
29889,
5223,
29898,
29916,
29961,
2536,
29892,
29900,
2314,
334,
301,
1402,
376,
29895,
29899,
613,
15595,
29922,
29900,
29889,
29896,
29897,
13,
1454,
921,
29918,
297,
921,
29961,
2536,
29892,
29900,
5387,
13,
1678,
4853,
29906,
29889,
5317,
4197,
29900,
29892,
7442,
29889,
3944,
29898,
29916,
19925,
334,
301,
334,
29871,
29906,
1402,
518,
29900,
29892,
7442,
29889,
5223,
29898,
29916,
19925,
334,
301,
334,
29871,
29906,
1402,
376,
29895,
29899,
613,
1196,
2103,
29922,
29896,
29900,
29889,
29900,
29892,
15595,
29922,
29900,
29889,
29941,
29897,
13,
1165,
29906,
29889,
5317,
29898,
9302,
29889,
3944,
29898,
29916,
29961,
2536,
29892,
29900,
2314,
334,
301,
334,
29871,
29906,
29889,
29900,
29945,
29892,
7442,
29889,
5223,
29898,
29916,
29961,
2536,
29892,
29900,
2314,
334,
301,
334,
29871,
29906,
29889,
29900,
29945,
29892,
376,
2901,
613,
15595,
29922,
29900,
29889,
29945,
29897,
13,
1165,
29906,
29889,
842,
29918,
294,
1103,
29898,
29896,
29897,
13,
13,
1165,
29941,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
3174,
29961,
29896,
29892,
29901,
2314,
13,
29937,
1596,
376,
29916,
7503,
29892,
29900,
1822,
12181,
613,
921,
7503,
29892,
29900,
1822,
12181,
13,
29937,
921,
29918,
353,
7442,
29889,
29894,
1429,
3552,
29916,
29961,
29896,
13018,
29896,
29892,
29900,
1402,
921,
29961,
29906,
29901,
29892,
29900,
2314,
467,
29911,
13,
29878,
865,
353,
29871,
29896,
29946,
29900,
29900,
396,
6459,
3005,
29939,
310,
21519,
362,
13,
29916,
29918,
353,
7442,
29889,
29894,
1429,
4197,
29916,
29961,
29875,
13018,
29878,
865,
29974,
29875,
29892,
29900,
29962,
363,
474,
297,
3464,
29898,
29878,
865,
4638,
467,
29911,
13,
2158,
703,
29916,
29918,
613,
921,
5396,
12181,
29897,
13,
29937,
4853,
29941,
29889,
5317,
29898,
29916,
29918,
7503,
29892,
29900,
1402,
921,
29918,
7503,
29892,
29896,
1402,
376,
2901,
613,
15595,
29922,
29900,
29889,
29906,
29945,
29897,
13,
3286,
22450,
353,
29871,
29896,
29900,
29900,
29900,
13,
29916,
29918,
2388,
353,
5159,
13,
29916,
29918,
22450,
353,
5159,
13,
29891,
29918,
2388,
353,
5159,
13,
29891,
29918,
22450,
353,
5159,
13,
1454,
474,
297,
3464,
29898,
29896,
29892,
364,
865,
29892,
29871,
29896,
29900,
1125,
13,
1678,
396,
22326,
353,
4853,
29941,
29889,
1557,
2620,
29898,
29916,
29918,
7503,
29892,
29900,
1402,
921,
29918,
7503,
29892,
29875,
1402,
274,
353,
921,
7503,
29899,
29878,
865,
29892,
29896,
1402,
15595,
29922,
29900,
29889,
29906,
29945,
29897,
13,
1678,
396,
22326,
353,
4853,
29941,
29889,
1557,
2620,
29898,
29916,
29918,
7503,
29892,
29900,
1402,
7442,
29889,
6897,
29898,
29916,
29918,
7503,
29892,
29875,
11724,
274,
353,
921,
7503,
29899,
29878,
865,
29892,
29896,
1402,
274,
1958,
29922,
572,
29873,
29889,
657,
29918,
29883,
1958,
703,
21012,
4968,
15595,
29922,
7411,
29898,
29875,
6802,
29878,
865,
29897,
13,
1678,
2243,
353,
22780,
29898,
3286,
22450,
29892,
1301,
22450,
718,
29871,
29896,
29900,
29900,
29900,
29897,
13,
1678,
921,
29918,
2388,
29889,
4397,
29898,
9302,
29889,
5223,
29898,
29916,
29918,
29961,
2536,
29892,
29900,
12622,
13,
1678,
921,
29918,
22450,
29889,
4397,
29898,
9302,
29889,
2873,
29918,
4561,
29898,
29916,
29918,
2388,
14352,
29896,
2314,
334,
313,
29875,
1273,
313,
29878,
865,
29914,
29896,
29900,
4961,
13,
1678,
343,
29918,
2388,
29889,
4397,
29898,
9302,
29889,
5223,
29898,
29916,
29918,
29961,
2536,
29892,
29875,
12622,
13,
1678,
343,
29918,
22450,
29889,
4397,
29898,
9302,
29889,
2873,
29918,
4561,
29898,
29891,
29918,
2388,
14352,
29896,
2314,
334,
29871,
29906,
29889,
29945,
334,
313,
29875,
849,
313,
29878,
865,
29914,
29896,
29900,
4961,
13,
1678,
396,
22326,
353,
4853,
29941,
29889,
1557,
2620,
29898,
29916,
29918,
2388,
718,
474,
29892,
343,
29918,
2388,
29892,
274,
353,
921,
29918,
2388,
448,
343,
29918,
2388,
29892,
274,
1958,
29922,
572,
29873,
29889,
657,
29918,
29883,
1958,
703,
21494,
1705,
4968,
15595,
29922,
7411,
29898,
29875,
6802,
29878,
865,
29897,
13,
1678,
396,
4853,
29941,
29889,
842,
29918,
952,
29883,
744,
703,
1188,
1159,
13,
29916,
29918,
2388,
353,
7442,
29889,
2378,
29898,
29916,
29918,
2388,
467,
1579,
8606,
580,
13,
29916,
29918,
22450,
353,
7442,
29889,
2378,
29898,
29916,
29918,
22450,
467,
1579,
8606,
580,
13,
29891,
29918,
2388,
353,
7442,
29889,
2378,
29898,
29891,
29918,
2388,
467,
1579,
8606,
580,
13,
29891,
29918,
22450,
353,
7442,
29889,
2378,
29898,
29891,
29918,
22450,
467,
1579,
8606,
580,
13,
1526,
353,
4853,
29941,
29889,
1557,
2620,
29898,
29916,
29918,
2388,
718,
921,
29918,
22450,
29892,
343,
29918,
2388,
718,
343,
29918,
22450,
29892,
274,
353,
921,
29918,
2388,
448,
343,
29918,
2388,
29892,
274,
1958,
29922,
572,
29873,
29889,
657,
29918,
29883,
1958,
703,
29903,
1103,
1705,
4968,
15595,
29922,
29900,
29889,
29906,
29945,
29892,
269,
29922,
29906,
29892,
1196,
2103,
29879,
29922,
29900,
29897,
13,
268,
13,
29937,
22326,
353,
4853,
29941,
29889,
1557,
2620,
29898,
29916,
29918,
7503,
29892,
29900,
1402,
921,
29918,
7503,
29892,
29896,
1402,
274,
353,
921,
7503,
29899,
29896,
29892,
29896,
1402,
15595,
29922,
29900,
29889,
29906,
29945,
29897,
13,
1003,
29889,
2780,
1646,
29898,
655,
407,
519,
353,
22326,
29892,
4853,
353,
4853,
29941,
29892,
19843,
543,
22672,
613,
15958,
29922,
29900,
29889,
29900,
29945,
29897,
13,
29937,
4853,
29941,
29889,
842,
29918,
294,
1103,
29898,
29896,
29897,
13,
13,
572,
29873,
29889,
4294,
580,
13,
2
] |
golden_search.py | nandaVT/Optimization-Techniques-for-Engineering-design | 0 | 189907 | import sys
try:
import math
import sympy as sym
from sympy import sin,cos,tan,N
except:
print("Packages not installed. Please install 'sympy' package")
sys.exit()
print("Fibonacci search method")
x = sym.Symbol('x')
def substitute(k):
return (f.subs(x,k))
while(True):
s = ""
func = "x**2+(54/x)"#input("Enter the function = ") #"x**2+(54/x)"
for i in func:
s= s+i
try:
exec("f = "+s)
print(f)
break
except:
print("Entered function is incompatible. Try again.")
a = 0#float(input("Enter 'a' value = "))
b = 5#float(input("Enter 'b' value = "))
k = 1
epsilon = 0.8
l_o = b - a
iteration = 1
while(1):
print("\nIteration = ",iteration)
iteration = iteration + 1
l_k_star = ((0.618)**k)*l_o
print("l_k_star = ",l_k_star)
x1 = a + l_k_star
x2 = b - l_k_star
print("x1 = {} x2 = {}".format(x1,x2))
f_x1 = substitute(x1)
f_x2 = substitute(x2)
print("f_x1 = {} f_x2 = {}".format(f_x1,f_x2))
if(x1 > x2):
if(f_x1 < f_x2):
a = x2
print("f_x1 > f_x2")
if(f_x1 > f_x2):
b = x1
print("f_x1 < f_x2")
else:
if(f_x1 > f_x2):
a = x1
print("f_x1 > f_x2")
elif(f_x1 < f_x2):
b = x2
print("f_x1 < f_x2")
#print(k)
l = b - a
print("l = ", l)
if(l < epsilon):
print("l < epsilon")
break
print("l > epsilon")
k = k + 1
print("(a = {} , b = {})".format(a,b)) | [
1,
1053,
10876,
30004,
13,
2202,
29901,
6756,
13,
1678,
1053,
5844,
30004,
13,
1678,
1053,
5016,
2272,
408,
5016,
30004,
13,
1678,
515,
5016,
2272,
1053,
4457,
29892,
3944,
29892,
13161,
29892,
29940,
30004,
13,
19499,
29901,
30004,
13,
1678,
1596,
703,
16638,
1179,
451,
5130,
29889,
3529,
2601,
525,
11967,
2272,
29915,
3577,
1159,
30004,
13,
1678,
10876,
29889,
13322,
26471,
13,
30004,
13,
2158,
703,
29943,
747,
265,
21566,
2740,
1158,
1159,
30004,
13,
29916,
353,
5016,
29889,
14730,
877,
29916,
1495,
30004,
13,
30004,
13,
1753,
23764,
29898,
29895,
1125,
30004,
13,
1678,
736,
313,
29888,
29889,
1491,
29879,
29898,
29916,
29892,
29895,
876,
30004,
13,
30004,
13,
8000,
29898,
5574,
1125,
30004,
13,
1678,
269,
353,
5124,
30004,
13,
1678,
3653,
353,
376,
29916,
1068,
29906,
17108,
29945,
29946,
29914,
29916,
5513,
29937,
2080,
703,
10399,
278,
740,
353,
16521,
1678,
396,
29908,
29916,
1068,
29906,
17108,
29945,
29946,
29914,
29916,
5513,
30004,
13,
1678,
363,
474,
297,
3653,
29901,
30004,
13,
4706,
269,
29922,
269,
29974,
29875,
30004,
13,
4706,
6756,
13,
1678,
1018,
29901,
30004,
13,
4706,
2279,
703,
29888,
353,
15691,
29879,
8443,
13,
4706,
1596,
29898,
29888,
8443,
13,
4706,
2867,
30004,
13,
1678,
5174,
29901,
30004,
13,
4706,
1596,
703,
10399,
287,
740,
338,
297,
23712,
29889,
3967,
1449,
23157,
30004,
13,
4706,
6756,
13,
29874,
353,
29871,
29900,
29937,
7411,
29898,
2080,
703,
10399,
525,
29874,
29915,
995,
353,
376,
876,
30004,
13,
29890,
353,
29871,
29945,
29937,
7411,
29898,
2080,
703,
10399,
525,
29890,
29915,
995,
353,
376,
876,
30004,
13,
29895,
353,
29871,
29896,
30004,
13,
5463,
353,
29871,
29900,
29889,
29947,
30004,
13,
29880,
29918,
29877,
353,
289,
448,
263,
30004,
13,
1524,
362,
353,
29871,
29896,
30004,
13,
30004,
13,
8000,
29898,
29896,
1125,
30004,
13,
1678,
1596,
14182,
29876,
13463,
362,
353,
9162,
1524,
362,
8443,
13,
1678,
12541,
353,
12541,
718,
29871,
29896,
30004,
13,
1678,
301,
29918,
29895,
29918,
8508,
353,
5135,
29900,
29889,
29953,
29896,
29947,
29897,
1068,
29895,
11877,
29880,
29918,
29877,
30004,
13,
1678,
1596,
703,
29880,
29918,
29895,
29918,
8508,
353,
9162,
29880,
29918,
29895,
29918,
8508,
8443,
13,
1678,
921,
29896,
353,
263,
718,
301,
29918,
29895,
29918,
8508,
30004,
13,
1678,
921,
29906,
353,
289,
448,
301,
29918,
29895,
29918,
8508,
30004,
13,
1678,
1596,
703,
29916,
29896,
353,
6571,
921,
29906,
353,
6571,
1642,
4830,
29898,
29916,
29896,
29892,
29916,
29906,
876,
30004,
13,
1678,
285,
29918,
29916,
29896,
353,
23764,
29898,
29916,
29896,
8443,
13,
1678,
285,
29918,
29916,
29906,
353,
23764,
29898,
29916,
29906,
8443,
13,
1678,
1596,
703,
29888,
29918,
29916,
29896,
353,
6571,
285,
29918,
29916,
29906,
353,
6571,
1642,
4830,
29898,
29888,
29918,
29916,
29896,
29892,
29888,
29918,
29916,
29906,
876,
30004,
13,
1678,
565,
29898,
29916,
29896,
1405,
921,
29906,
1125,
30004,
13,
4706,
565,
29898,
29888,
29918,
29916,
29896,
529,
285,
29918,
29916,
29906,
1125,
30004,
13,
9651,
263,
353,
921,
29906,
30004,
13,
9651,
1596,
703,
29888,
29918,
29916,
29896,
1405,
285,
29918,
29916,
29906,
1159,
30004,
13,
4706,
565,
29898,
29888,
29918,
29916,
29896,
1405,
285,
29918,
29916,
29906,
1125,
30004,
13,
9651,
289,
353,
921,
29896,
30004,
13,
9651,
1596,
703,
29888,
29918,
29916,
29896,
529,
285,
29918,
29916,
29906,
1159,
30004,
13,
1678,
1683,
29901,
30004,
13,
4706,
565,
29898,
29888,
29918,
29916,
29896,
1405,
285,
29918,
29916,
29906,
1125,
30004,
13,
9651,
263,
353,
921,
29896,
30004,
13,
9651,
1596,
703,
29888,
29918,
29916,
29896,
1405,
285,
29918,
29916,
29906,
1159,
30004,
13,
4706,
25342,
29898,
29888,
29918,
29916,
29896,
529,
285,
29918,
29916,
29906,
1125,
30004,
13,
9651,
289,
353,
921,
29906,
30004,
13,
9651,
1596,
703,
29888,
29918,
29916,
29896,
529,
285,
29918,
29916,
29906,
1159,
30004,
13,
1678,
396,
2158,
29898,
29895,
8443,
13,
1678,
301,
353,
289,
448,
263,
30004,
13,
1678,
1596,
703,
29880,
353,
9162,
301,
8443,
13,
1678,
565,
29898,
29880,
529,
321,
3232,
1125,
30004,
13,
4706,
1596,
703,
29880,
529,
321,
3232,
1159,
30004,
13,
4706,
2867,
30004,
13,
1678,
1596,
703,
29880,
1405,
321,
3232,
1159,
30004,
13,
1678,
413,
353,
413,
718,
29871,
29896,
30004,
13,
1678,
6756,
13,
2158,
703,
29898,
29874,
353,
6571,
1919,
289,
353,
426,
1800,
1642,
4830,
29898,
29874,
29892,
29890,
876,
2
] |
kivy/input/providers/linuxwacom.py | VICTORVICKIE/kivy | 13,889 | 66757 | <filename>kivy/input/providers/linuxwacom.py
'''
Native support of Wacom tablet from linuxwacom driver
=====================================================
To configure LinuxWacom, add this to your configuration::
[input]
pen = linuxwacom,/dev/input/event2,mode=pen
finger = linuxwacom,/dev/input/event3,mode=touch
.. note::
You must have read access to the input event.
You can use a custom range for the X, Y and pressure values.
On some drivers, the range reported is invalid.
To fix that, you can add these options to the argument line:
* invert_x : 1 to invert X axis
* invert_y : 1 to invert Y axis
* min_position_x : X minimum
* max_position_x : X maximum
* min_position_y : Y minimum
* max_position_y : Y maximum
* min_pressure : pressure minimum
* max_pressure : pressure maximum
'''
__all__ = ('LinuxWacomMotionEventProvider', 'LinuxWacomMotionEvent')
import os
from kivy.input.motionevent import MotionEvent
from kivy.input.shape import ShapeRect
class LinuxWacomMotionEvent(MotionEvent):
def depack(self, args):
self.is_touch = True
self.sx = args['x']
self.sy = args['y']
self.profile = ['pos']
if 'size_w' in args and 'size_h' in args:
self.shape = ShapeRect()
self.shape.width = args['size_w']
self.shape.height = args['size_h']
self.profile.append('shape')
if 'pressure' in args:
self.pressure = args['pressure']
self.profile.append('pressure')
super(LinuxWacomMotionEvent, self).depack(args)
def __str__(self):
return '<LinuxWacomMotionEvent id=%d pos=(%f, %f) device=%s>' \
% (self.id, self.sx, self.sy, self.device)
if 'KIVY_DOC' in os.environ:
# documentation hack
LinuxWacomMotionEventProvider = None
else:
import threading
import collections
import struct
import fcntl
from kivy.input.provider import MotionEventProvider
from kivy.input.factory import MotionEventFactory
from kivy.logger import Logger
#
# This part is taken from linux-source-2.6.32/include/linux/input.h
#
# Event types
EV_SYN = 0x00
EV_KEY = 0x01
EV_REL = 0x02
EV_ABS = 0x03
EV_MSC = 0x04
EV_SW = 0x05
EV_LED = 0x11
EV_SND = 0x12
EV_REP = 0x14
EV_FF = 0x15
EV_PWR = 0x16
EV_FF_STATUS = 0x17
EV_MAX = 0x1f
EV_CNT = (EV_MAX + 1)
KEY_MAX = 0x2ff
# Synchronization events
SYN_REPORT = 0
SYN_CONFIG = 1
SYN_MT_REPORT = 2
# Misc events
MSC_SERIAL = 0x00
MSC_PULSELED = 0x01
MSC_GESTURE = 0x02
MSC_RAW = 0x03
MSC_SCAN = 0x04
MSC_MAX = 0x07
MSC_CNT = (MSC_MAX + 1)
ABS_X = 0x00
ABS_Y = 0x01
ABS_PRESSURE = 0x18
ABS_MISC = 0x28 # if 0, it's touch up
ABS_MT_TOUCH_MAJOR = 0x30 # Major axis of touching ellipse
ABS_MT_TOUCH_MINOR = 0x31 # Minor axis (omit if circular)
ABS_MT_WIDTH_MAJOR = 0x32 # Major axis of approaching ellipse
ABS_MT_WIDTH_MINOR = 0x33 # Minor axis (omit if circular)
ABS_MT_ORIENTATION = 0x34 # Ellipse orientation
ABS_MT_POSITION_X = 0x35 # Center X ellipse position
ABS_MT_POSITION_Y = 0x36 # Center Y ellipse position
ABS_MT_TOOL_TYPE = 0x37 # Type of touching device
ABS_MT_BLOB_ID = 0x38 # Group a set of packets as a blob
ABS_MT_TRACKING_ID = 0x39 # Unique ID of initiated contact
ABS_MT_PRESSURE = 0x3a # Pressure on contact area
# some ioctl base (with 0 value)
EVIOCGNAME = 2147501318
EVIOCGBIT = 2147501344
EVIOCGABS = 2149074240
# sizeof(struct input_event)
struct_input_event_sz = struct.calcsize('LLHHi')
struct_input_absinfo_sz = struct.calcsize('iiiiii')
sz_l = struct.calcsize('Q')
class LinuxWacomMotionEventProvider(MotionEventProvider):
options = ('min_position_x', 'max_position_x',
'min_position_y', 'max_position_y',
'min_pressure', 'max_pressure',
'invert_x', 'invert_y')
def __init__(self, device, args):
super(LinuxWacomMotionEventProvider, self).__init__(device, args)
self.input_fn = None
self.default_ranges = dict()
self.mode = 'touch'
# split arguments
args = args.split(',')
if not args:
Logger.error('LinuxWacom: No filename given in config')
Logger.error('LinuxWacom: Use /dev/input/event0 for example')
return
# read filename
self.input_fn = args[0]
Logger.info('LinuxWacom: Read event from <%s>' % self.input_fn)
# read parameters
for arg in args[1:]:
if arg == '':
continue
arg = arg.split('=')
# ensure it's a key = value
if len(arg) != 2:
err = 'LinuxWacom: Bad parameter' \
'%s: Not in key=value format.' % arg
Logger.error(err)
continue
# ensure the key exist
key, value = arg
if key == 'mode':
self.mode = value
continue
if key not in LinuxWacomMotionEventProvider.options:
Logger.error('LinuxWacom: unknown %s option' % key)
continue
# ensure the value
try:
self.default_ranges[key] = int(value)
except ValueError:
err = 'LinuxWacom: value %s invalid for %s' % (key, value)
Logger.error(err)
continue
# all good!
msg = 'LinuxWacom: Set custom %s to %d' % (key, int(value))
Logger.info(msg)
Logger.info('LinuxWacom: mode is <%s>' % self.mode)
def start(self):
if self.input_fn is None:
return
self.uid = 0
self.queue = collections.deque()
self.thread = threading.Thread(
target=self._thread_run,
kwargs=dict(
queue=self.queue,
input_fn=self.input_fn,
device=self.device,
default_ranges=self.default_ranges))
self.thread.daemon = True
self.thread.start()
def _thread_run(self, **kwargs):
input_fn = kwargs.get('input_fn')
queue = kwargs.get('queue')
device = kwargs.get('device')
drs = kwargs.get('default_ranges').get
touches = {}
touches_sent = []
l_points = {}
# prepare some vars to get limit of some component
range_min_position_x = 0
range_max_position_x = 2048
range_min_position_y = 0
range_max_position_y = 2048
range_min_pressure = 0
range_max_pressure = 255
invert_x = int(bool(drs('invert_x', 0)))
invert_y = int(bool(drs('invert_y', 0)))
reset_touch = False
def process(points):
actives = list(points.keys())
for args in points.values():
tid = args['id']
try:
touch = touches[tid]
except KeyError:
touch = LinuxWacomMotionEvent(device, tid, args)
touches[touch.id] = touch
if touch.sx == args['x'] \
and touch.sy == args['y'] \
and tid in touches_sent:
continue
touch.move(args)
if tid not in touches_sent:
queue.append(('begin', touch))
touches_sent.append(tid)
queue.append(('update', touch))
for tid in list(touches.keys())[:]:
if tid not in actives:
touch = touches[tid]
if tid in touches_sent:
touch.update_time_end()
queue.append(('end', touch))
touches_sent.remove(tid)
del touches[tid]
def normalize(value, vmin, vmax):
return (value - vmin) / float(vmax - vmin)
# open the input
try:
fd = open(input_fn, 'rb')
except IOError:
Logger.exception('Unable to open %s' % input_fn)
return
# get the controller name (EVIOCGNAME)
device_name = fcntl.ioctl(fd, EVIOCGNAME + (256 << 16),
" " * 256).split('\x00')[0]
Logger.info('LinuxWacom: using <%s>' % device_name)
# get abs infos
bit = fcntl.ioctl(fd, EVIOCGBIT + (EV_MAX << 16), ' ' * sz_l)
bit, = struct.unpack('Q', bit)
for x in range(EV_MAX):
# preserve this, we may want other things than EV_ABS
if x != EV_ABS:
continue
# EV_ABS available for this device ?
if (bit & (1 << x)) == 0:
continue
# ask abs info keys to the devices
sbit = fcntl.ioctl(fd, EVIOCGBIT + x + (KEY_MAX << 16),
' ' * sz_l)
sbit, = struct.unpack('Q', sbit)
for y in range(KEY_MAX):
if (sbit & (1 << y)) == 0:
continue
absinfo = fcntl.ioctl(fd, EVIOCGABS + y +
(struct_input_absinfo_sz << 16),
' ' * struct_input_absinfo_sz)
abs_value, abs_min, abs_max, abs_fuzz, \
abs_flat, abs_res = struct.unpack('iiiiii', absinfo)
if y == ABS_X:
range_min_position_x = drs('min_position_x', abs_min)
range_max_position_x = drs('max_position_x', abs_max)
Logger.info('LinuxWacom: ' +
'<%s> range position X is %d - %d' % (
device_name, abs_min, abs_max))
elif y == ABS_Y:
range_min_position_y = drs('min_position_y', abs_min)
range_max_position_y = drs('max_position_y', abs_max)
Logger.info('LinuxWacom: ' +
'<%s> range position Y is %d - %d' % (
device_name, abs_min, abs_max))
elif y == ABS_PRESSURE:
range_min_pressure = drs('min_pressure', abs_min)
range_max_pressure = drs('max_pressure', abs_max)
Logger.info('LinuxWacom: ' +
'<%s> range pressure is %d - %d' % (
device_name, abs_min, abs_max))
# read until the end
changed = False
touch_id = 0
touch_x = 0
touch_y = 0
touch_pressure = 0
while fd:
data = fd.read(struct_input_event_sz)
if len(data) < struct_input_event_sz:
break
# extract each event
for i in range(len(data) / struct_input_event_sz):
ev = data[i * struct_input_event_sz:]
# extract timeval + event infos
tv_sec, tv_usec, ev_type, ev_code, ev_value = \
struct.unpack('LLHHi', ev[:struct_input_event_sz])
if ev_type == EV_SYN and ev_code == SYN_REPORT:
if touch_id in l_points:
p = l_points[touch_id]
else:
p = dict()
l_points[touch_id] = p
p['id'] = touch_id
if not reset_touch:
p['x'] = touch_x
p['y'] = touch_y
p['pressure'] = touch_pressure
if self.mode == 'pen' \
and touch_pressure == 0 \
and not reset_touch:
del l_points[touch_id]
if changed:
if 'x' not in p:
reset_touch = False
continue
process(l_points)
changed = False
if reset_touch:
l_points.clear()
reset_touch = False
process(l_points)
elif ev_type == EV_MSC and ev_code == MSC_SERIAL:
touch_id = ev_value
elif ev_type == EV_ABS and ev_code == ABS_X:
val = normalize(ev_value,
range_min_position_x,
range_max_position_x)
if invert_x:
val = 1. - val
touch_x = val
changed = True
elif ev_type == EV_ABS and ev_code == ABS_Y:
val = 1. - normalize(ev_value,
range_min_position_y,
range_max_position_y)
if invert_y:
val = 1. - val
touch_y = val
changed = True
elif ev_type == EV_ABS and ev_code == ABS_PRESSURE:
touch_pressure = normalize(ev_value,
range_min_pressure,
range_max_pressure)
changed = True
elif ev_type == EV_ABS and ev_code == ABS_MISC:
if ev_value == 0:
reset_touch = True
def update(self, dispatch_fn):
# dispatch all event from threads
try:
while True:
event_type, touch = self.queue.popleft()
dispatch_fn(event_type, touch)
except:
pass
MotionEventFactory.register('linuxwacom', LinuxWacomMotionEventProvider)
| [
1,
529,
9507,
29958,
29895,
440,
29891,
29914,
2080,
29914,
771,
29454,
29914,
9389,
2766,
510,
29889,
2272,
13,
12008,
13,
11024,
2304,
310,
22552,
510,
1591,
29873,
515,
10542,
2766,
510,
7156,
13,
9166,
9166,
9166,
2751,
29922,
13,
13,
1762,
10822,
8074,
29956,
29874,
510,
29892,
788,
445,
304,
596,
5285,
1057,
13,
13,
1678,
518,
2080,
29962,
13,
1678,
6584,
353,
10542,
2766,
510,
29892,
29914,
3359,
29914,
2080,
29914,
3696,
29906,
29892,
8513,
29922,
2238,
13,
1678,
19917,
353,
10542,
2766,
510,
29892,
29914,
3359,
29914,
2080,
29914,
3696,
29941,
29892,
8513,
29922,
16747,
13,
13,
636,
4443,
1057,
13,
1678,
887,
1818,
505,
1303,
2130,
304,
278,
1881,
1741,
29889,
13,
13,
3492,
508,
671,
263,
2888,
3464,
363,
278,
1060,
29892,
612,
322,
12959,
1819,
29889,
13,
2951,
777,
18563,
29892,
278,
3464,
8967,
338,
8340,
29889,
13,
1762,
2329,
393,
29892,
366,
508,
788,
1438,
3987,
304,
278,
2980,
1196,
29901,
13,
13,
29930,
21292,
29918,
29916,
584,
29871,
29896,
304,
21292,
1060,
9685,
13,
29930,
21292,
29918,
29891,
584,
29871,
29896,
304,
21292,
612,
9685,
13,
29930,
1375,
29918,
3283,
29918,
29916,
584,
1060,
9212,
13,
29930,
4236,
29918,
3283,
29918,
29916,
584,
1060,
7472,
13,
29930,
1375,
29918,
3283,
29918,
29891,
584,
612,
9212,
13,
29930,
4236,
29918,
3283,
29918,
29891,
584,
612,
7472,
13,
29930,
1375,
29918,
2139,
545,
584,
12959,
9212,
13,
29930,
4236,
29918,
2139,
545,
584,
12959,
7472,
13,
12008,
13,
13,
1649,
497,
1649,
353,
6702,
24085,
29956,
29874,
510,
29924,
8194,
2624,
6980,
742,
525,
24085,
29956,
29874,
510,
29924,
8194,
2624,
1495,
13,
13,
5215,
2897,
13,
3166,
413,
440,
29891,
29889,
2080,
29889,
14817,
1421,
794,
1053,
7142,
291,
2624,
13,
3166,
413,
440,
29891,
29889,
2080,
29889,
12181,
1053,
1383,
4085,
7364,
13,
13,
13,
1990,
8074,
29956,
29874,
510,
29924,
8194,
2624,
29898,
29924,
8194,
2624,
1125,
13,
13,
1678,
822,
1401,
547,
29898,
1311,
29892,
6389,
1125,
13,
4706,
1583,
29889,
275,
29918,
16747,
353,
5852,
13,
4706,
1583,
29889,
29879,
29916,
353,
6389,
1839,
29916,
2033,
13,
4706,
1583,
29889,
29879,
29891,
353,
6389,
1839,
29891,
2033,
13,
4706,
1583,
29889,
10185,
353,
6024,
1066,
2033,
13,
4706,
565,
525,
2311,
29918,
29893,
29915,
297,
6389,
322,
525,
2311,
29918,
29882,
29915,
297,
6389,
29901,
13,
9651,
1583,
29889,
12181,
353,
1383,
4085,
7364,
580,
13,
9651,
1583,
29889,
12181,
29889,
2103,
353,
6389,
1839,
2311,
29918,
29893,
2033,
13,
9651,
1583,
29889,
12181,
29889,
3545,
353,
6389,
1839,
2311,
29918,
29882,
2033,
13,
9651,
1583,
29889,
10185,
29889,
4397,
877,
12181,
1495,
13,
4706,
565,
525,
2139,
545,
29915,
297,
6389,
29901,
13,
9651,
1583,
29889,
2139,
545,
353,
6389,
1839,
2139,
545,
2033,
13,
9651,
1583,
29889,
10185,
29889,
4397,
877,
2139,
545,
1495,
13,
4706,
2428,
29898,
24085,
29956,
29874,
510,
29924,
8194,
2624,
29892,
1583,
467,
2716,
547,
29898,
5085,
29897,
13,
13,
1678,
822,
4770,
710,
12035,
1311,
1125,
13,
4706,
736,
12801,
24085,
29956,
29874,
510,
29924,
8194,
2624,
1178,
16328,
29881,
926,
7607,
29995,
29888,
29892,
1273,
29888,
29897,
4742,
16328,
29879,
16299,
320,
13,
9651,
1273,
313,
1311,
29889,
333,
29892,
1583,
29889,
29879,
29916,
29892,
1583,
29889,
29879,
29891,
29892,
1583,
29889,
10141,
29897,
13,
13,
13,
361,
525,
29968,
5667,
29979,
29918,
28665,
29915,
297,
2897,
29889,
21813,
29901,
13,
1678,
396,
5106,
15833,
13,
1678,
8074,
29956,
29874,
510,
29924,
8194,
2624,
6980,
353,
6213,
13,
13,
2870,
29901,
13,
1678,
1053,
3244,
292,
13,
1678,
1053,
16250,
13,
1678,
1053,
2281,
13,
1678,
1053,
285,
20047,
29880,
13,
1678,
515,
413,
440,
29891,
29889,
2080,
29889,
18121,
1053,
7142,
291,
2624,
6980,
13,
1678,
515,
413,
440,
29891,
29889,
2080,
29889,
14399,
1053,
7142,
291,
2624,
5126,
13,
1678,
515,
413,
440,
29891,
29889,
21707,
1053,
28468,
13,
13,
1678,
396,
13,
1678,
396,
910,
760,
338,
4586,
515,
10542,
29899,
4993,
29899,
29906,
29889,
29953,
29889,
29941,
29906,
29914,
2856,
29914,
9389,
29914,
2080,
29889,
29882,
13,
1678,
396,
13,
13,
1678,
396,
6864,
4072,
13,
1678,
382,
29963,
29918,
14816,
29940,
353,
29871,
29900,
29916,
29900,
29900,
13,
1678,
382,
29963,
29918,
10818,
353,
29871,
29900,
29916,
29900,
29896,
13,
1678,
382,
29963,
29918,
1525,
29931,
353,
29871,
29900,
29916,
29900,
29906,
13,
1678,
382,
29963,
29918,
2882,
29903,
353,
29871,
29900,
29916,
29900,
29941,
13,
1678,
382,
29963,
29918,
4345,
29907,
353,
29871,
29900,
29916,
29900,
29946,
13,
1678,
382,
29963,
29918,
23066,
353,
29871,
29900,
29916,
29900,
29945,
13,
1678,
382,
29963,
29918,
20566,
353,
29871,
29900,
29916,
29896,
29896,
13,
1678,
382,
29963,
29918,
29903,
2797,
353,
29871,
29900,
29916,
29896,
29906,
13,
1678,
382,
29963,
29918,
1525,
29925,
353,
29871,
29900,
29916,
29896,
29946,
13,
1678,
382,
29963,
29918,
4198,
353,
29871,
29900,
29916,
29896,
29945,
13,
1678,
382,
29963,
29918,
29925,
9980,
353,
29871,
29900,
29916,
29896,
29953,
13,
1678,
382,
29963,
29918,
4198,
29918,
27047,
353,
29871,
29900,
29916,
29896,
29955,
13,
1678,
382,
29963,
29918,
12648,
353,
29871,
29900,
29916,
29896,
29888,
13,
1678,
382,
29963,
29918,
13778,
29911,
353,
313,
22240,
29918,
12648,
718,
29871,
29896,
29897,
13,
13,
1678,
14636,
29918,
12648,
353,
29871,
29900,
29916,
29906,
600,
13,
13,
1678,
396,
317,
9524,
2133,
4959,
13,
1678,
28962,
29940,
29918,
1525,
15082,
353,
29871,
29900,
13,
1678,
28962,
29940,
29918,
25903,
353,
29871,
29896,
13,
1678,
28962,
29940,
29918,
11490,
29918,
1525,
15082,
353,
29871,
29906,
13,
13,
1678,
396,
341,
10669,
4959,
13,
1678,
341,
7187,
29918,
6304,
25758,
353,
29871,
29900,
29916,
29900,
29900,
13,
1678,
341,
7187,
29918,
7056,
29931,
1660,
20566,
353,
29871,
29900,
29916,
29900,
29896,
13,
1678,
341,
7187,
29918,
1692,
1254,
11499,
353,
29871,
29900,
29916,
29900,
29906,
13,
1678,
341,
7187,
29918,
4717,
29956,
353,
29871,
29900,
29916,
29900,
29941,
13,
1678,
341,
7187,
29918,
7187,
2190,
353,
29871,
29900,
29916,
29900,
29946,
13,
1678,
341,
7187,
29918,
12648,
353,
29871,
29900,
29916,
29900,
29955,
13,
1678,
341,
7187,
29918,
13778,
29911,
353,
313,
4345,
29907,
29918,
12648,
718,
29871,
29896,
29897,
13,
13,
1678,
319,
9851,
29918,
29990,
353,
29871,
29900,
29916,
29900,
29900,
13,
1678,
319,
9851,
29918,
29979,
353,
29871,
29900,
29916,
29900,
29896,
13,
1678,
319,
9851,
29918,
15094,
1799,
11499,
353,
29871,
29900,
29916,
29896,
29947,
13,
1678,
319,
9851,
29918,
29924,
3235,
29907,
353,
29871,
29900,
29916,
29906,
29947,
29871,
396,
565,
29871,
29900,
29892,
372,
29915,
29879,
6023,
701,
13,
1678,
319,
9851,
29918,
11490,
29918,
4986,
29965,
3210,
29918,
1529,
29967,
1955,
353,
29871,
29900,
29916,
29941,
29900,
29871,
396,
11019,
9685,
310,
6023,
292,
560,
5843,
13,
1678,
319,
9851,
29918,
11490,
29918,
4986,
29965,
3210,
29918,
16173,
1955,
353,
29871,
29900,
29916,
29941,
29896,
29871,
396,
21987,
9685,
313,
290,
277,
565,
19308,
29897,
13,
1678,
319,
9851,
29918,
11490,
29918,
22574,
29918,
1529,
29967,
1955,
353,
29871,
29900,
29916,
29941,
29906,
29871,
396,
11019,
9685,
310,
28702,
560,
5843,
13,
1678,
319,
9851,
29918,
11490,
29918,
22574,
29918,
16173,
1955,
353,
29871,
29900,
29916,
29941,
29941,
29871,
396,
21987,
9685,
313,
290,
277,
565,
19308,
29897,
13,
1678,
319,
9851,
29918,
11490,
29918,
1955,
29902,
3919,
8098,
353,
29871,
29900,
29916,
29941,
29946,
29871,
396,
1260,
5843,
19843,
13,
1678,
319,
9851,
29918,
11490,
29918,
24815,
22122,
29918,
29990,
353,
29871,
29900,
29916,
29941,
29945,
259,
396,
7817,
1060,
560,
5843,
2602,
13,
1678,
319,
9851,
29918,
11490,
29918,
24815,
22122,
29918,
29979,
353,
29871,
29900,
29916,
29941,
29953,
259,
396,
7817,
612,
560,
5843,
2602,
13,
1678,
319,
9851,
29918,
11490,
29918,
4986,
5607,
29918,
11116,
353,
29871,
29900,
29916,
29941,
29955,
1678,
396,
5167,
310,
6023,
292,
4742,
13,
1678,
319,
9851,
29918,
11490,
29918,
29933,
28902,
29918,
1367,
353,
29871,
29900,
29916,
29941,
29947,
418,
396,
6431,
263,
731,
310,
23912,
408,
263,
23755,
13,
1678,
319,
9851,
29918,
11490,
29918,
5659,
11375,
4214,
29918,
1367,
353,
29871,
29900,
29916,
29941,
29929,
29871,
396,
853,
1387,
3553,
310,
14511,
630,
6958,
13,
1678,
319,
9851,
29918,
11490,
29918,
15094,
1799,
11499,
353,
29871,
29900,
29916,
29941,
29874,
268,
396,
5254,
545,
373,
6958,
4038,
13,
13,
1678,
396,
777,
12013,
16948,
2967,
313,
2541,
29871,
29900,
995,
29897,
13,
1678,
382,
29963,
5971,
11135,
5813,
353,
29871,
29906,
29896,
29946,
29955,
29945,
29900,
29896,
29941,
29896,
29947,
13,
1678,
382,
29963,
5971,
29907,
7210,
1806,
353,
29871,
29906,
29896,
29946,
29955,
29945,
29900,
29896,
29941,
29946,
29946,
13,
1678,
382,
29963,
5971,
11135,
2882,
29903,
353,
29871,
29906,
29896,
29946,
29929,
29900,
29955,
29946,
29906,
29946,
29900,
13,
13,
1678,
396,
13810,
29898,
4984,
1881,
29918,
3696,
29897,
13,
1678,
2281,
29918,
2080,
29918,
3696,
29918,
3616,
353,
2281,
29889,
28667,
2311,
877,
2208,
29950,
18567,
1495,
13,
1678,
2281,
29918,
2080,
29918,
6897,
3888,
29918,
3616,
353,
2281,
29889,
28667,
2311,
877,
2236,
2236,
2236,
1495,
13,
1678,
2268,
29918,
29880,
353,
2281,
29889,
28667,
2311,
877,
29984,
1495,
13,
13,
1678,
770,
8074,
29956,
29874,
510,
29924,
8194,
2624,
6980,
29898,
29924,
8194,
2624,
6980,
1125,
13,
13,
4706,
3987,
353,
6702,
1195,
29918,
3283,
29918,
29916,
742,
525,
3317,
29918,
3283,
29918,
29916,
742,
13,
462,
259,
525,
1195,
29918,
3283,
29918,
29891,
742,
525,
3317,
29918,
3283,
29918,
29891,
742,
13,
462,
259,
525,
1195,
29918,
2139,
545,
742,
525,
3317,
29918,
2139,
545,
742,
13,
462,
259,
525,
262,
1765,
29918,
29916,
742,
525,
262,
1765,
29918,
29891,
1495,
13,
13,
4706,
822,
4770,
2344,
12035,
1311,
29892,
4742,
29892,
6389,
1125,
13,
9651,
2428,
29898,
24085,
29956,
29874,
510,
29924,
8194,
2624,
6980,
29892,
1583,
467,
1649,
2344,
12035,
10141,
29892,
6389,
29897,
13,
9651,
1583,
29889,
2080,
29918,
9144,
353,
6213,
13,
9651,
1583,
29889,
4381,
29918,
29878,
6916,
353,
9657,
580,
13,
9651,
1583,
29889,
8513,
353,
525,
16747,
29915,
13,
13,
9651,
396,
6219,
6273,
13,
9651,
6389,
353,
6389,
29889,
5451,
29317,
1495,
13,
9651,
565,
451,
6389,
29901,
13,
18884,
28468,
29889,
2704,
877,
24085,
29956,
29874,
510,
29901,
1939,
10422,
2183,
297,
2295,
1495,
13,
18884,
28468,
29889,
2704,
877,
24085,
29956,
29874,
510,
29901,
4803,
847,
3359,
29914,
2080,
29914,
3696,
29900,
363,
1342,
1495,
13,
18884,
736,
13,
13,
9651,
396,
1303,
10422,
13,
9651,
1583,
29889,
2080,
29918,
9144,
353,
6389,
29961,
29900,
29962,
13,
9651,
28468,
29889,
3888,
877,
24085,
29956,
29874,
510,
29901,
7523,
1741,
515,
20577,
29879,
16299,
1273,
1583,
29889,
2080,
29918,
9144,
29897,
13,
13,
9651,
396,
1303,
4128,
13,
9651,
363,
1852,
297,
6389,
29961,
29896,
29901,
5387,
13,
18884,
565,
1852,
1275,
525,
2396,
13,
462,
1678,
6773,
13,
18884,
1852,
353,
1852,
29889,
5451,
877,
29922,
1495,
13,
13,
18884,
396,
9801,
372,
29915,
29879,
263,
1820,
353,
995,
13,
18884,
565,
7431,
29898,
1191,
29897,
2804,
29871,
29906,
29901,
13,
462,
1678,
4589,
353,
525,
24085,
29956,
29874,
510,
29901,
9178,
3443,
29915,
320,
13,
462,
4706,
14210,
29879,
29901,
2216,
297,
1820,
29922,
1767,
3402,
6169,
1273,
1852,
13,
462,
1678,
28468,
29889,
2704,
29898,
3127,
29897,
13,
462,
1678,
6773,
13,
13,
18884,
396,
9801,
278,
1820,
1863,
13,
18884,
1820,
29892,
995,
353,
1852,
13,
18884,
565,
1820,
1275,
525,
8513,
2396,
13,
462,
1678,
1583,
29889,
8513,
353,
995,
13,
462,
1678,
6773,
13,
13,
18884,
565,
1820,
451,
297,
8074,
29956,
29874,
510,
29924,
8194,
2624,
6980,
29889,
6768,
29901,
13,
462,
1678,
28468,
29889,
2704,
877,
24085,
29956,
29874,
510,
29901,
9815,
1273,
29879,
2984,
29915,
1273,
1820,
29897,
13,
462,
1678,
6773,
13,
13,
18884,
396,
9801,
278,
995,
13,
18884,
1018,
29901,
13,
462,
1678,
1583,
29889,
4381,
29918,
29878,
6916,
29961,
1989,
29962,
353,
938,
29898,
1767,
29897,
13,
18884,
5174,
7865,
2392,
29901,
13,
462,
1678,
4589,
353,
525,
24085,
29956,
29874,
510,
29901,
995,
1273,
29879,
8340,
363,
1273,
29879,
29915,
1273,
313,
1989,
29892,
995,
29897,
13,
462,
1678,
28468,
29889,
2704,
29898,
3127,
29897,
13,
462,
1678,
6773,
13,
13,
18884,
396,
599,
1781,
29991,
13,
18884,
10191,
353,
525,
24085,
29956,
29874,
510,
29901,
3789,
2888,
1273,
29879,
304,
1273,
29881,
29915,
1273,
313,
1989,
29892,
938,
29898,
1767,
876,
13,
18884,
28468,
29889,
3888,
29898,
7645,
29897,
13,
9651,
28468,
29889,
3888,
877,
24085,
29956,
29874,
510,
29901,
4464,
338,
20577,
29879,
16299,
1273,
1583,
29889,
8513,
29897,
13,
13,
4706,
822,
1369,
29898,
1311,
1125,
13,
9651,
565,
1583,
29889,
2080,
29918,
9144,
338,
6213,
29901,
13,
18884,
736,
13,
9651,
1583,
29889,
5416,
353,
29871,
29900,
13,
9651,
1583,
29889,
9990,
353,
16250,
29889,
311,
802,
580,
13,
9651,
1583,
29889,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
18884,
3646,
29922,
1311,
3032,
7097,
29918,
3389,
29892,
13,
18884,
9049,
5085,
29922,
8977,
29898,
13,
462,
1678,
9521,
29922,
1311,
29889,
9990,
29892,
13,
462,
1678,
1881,
29918,
9144,
29922,
1311,
29889,
2080,
29918,
9144,
29892,
13,
462,
1678,
4742,
29922,
1311,
29889,
10141,
29892,
13,
462,
1678,
2322,
29918,
29878,
6916,
29922,
1311,
29889,
4381,
29918,
29878,
6916,
876,
13,
9651,
1583,
29889,
7097,
29889,
1388,
9857,
353,
5852,
13,
9651,
1583,
29889,
7097,
29889,
2962,
580,
13,
13,
4706,
822,
903,
7097,
29918,
3389,
29898,
1311,
29892,
3579,
19290,
1125,
13,
9651,
1881,
29918,
9144,
353,
9049,
5085,
29889,
657,
877,
2080,
29918,
9144,
1495,
13,
9651,
9521,
353,
9049,
5085,
29889,
657,
877,
9990,
1495,
13,
9651,
4742,
353,
9049,
5085,
29889,
657,
877,
10141,
1495,
13,
9651,
270,
2288,
353,
9049,
5085,
29889,
657,
877,
4381,
29918,
29878,
6916,
2824,
657,
13,
9651,
6023,
267,
353,
6571,
13,
9651,
6023,
267,
29918,
18616,
353,
5159,
13,
9651,
301,
29918,
9748,
353,
6571,
13,
13,
9651,
396,
19012,
777,
24987,
304,
679,
4046,
310,
777,
4163,
13,
9651,
3464,
29918,
1195,
29918,
3283,
29918,
29916,
353,
29871,
29900,
13,
9651,
3464,
29918,
3317,
29918,
3283,
29918,
29916,
353,
29871,
29906,
29900,
29946,
29947,
13,
9651,
3464,
29918,
1195,
29918,
3283,
29918,
29891,
353,
29871,
29900,
13,
9651,
3464,
29918,
3317,
29918,
3283,
29918,
29891,
353,
29871,
29906,
29900,
29946,
29947,
13,
9651,
3464,
29918,
1195,
29918,
2139,
545,
353,
29871,
29900,
13,
9651,
3464,
29918,
3317,
29918,
2139,
545,
353,
29871,
29906,
29945,
29945,
13,
9651,
21292,
29918,
29916,
353,
938,
29898,
11227,
29898,
29881,
2288,
877,
262,
1765,
29918,
29916,
742,
29871,
29900,
4961,
13,
9651,
21292,
29918,
29891,
353,
938,
29898,
11227,
29898,
29881,
2288,
877,
262,
1765,
29918,
29891,
742,
29871,
29900,
4961,
13,
9651,
10092,
29918,
16747,
353,
7700,
13,
13,
9651,
822,
1889,
29898,
9748,
1125,
13,
18884,
1044,
3145,
353,
1051,
29898,
9748,
29889,
8149,
3101,
13,
18884,
363,
6389,
297,
3291,
29889,
5975,
7295,
13,
462,
1678,
10668,
353,
6389,
1839,
333,
2033,
13,
462,
1678,
1018,
29901,
13,
462,
4706,
6023,
353,
6023,
267,
29961,
17681,
29962,
13,
462,
1678,
5174,
7670,
2392,
29901,
13,
462,
4706,
6023,
353,
8074,
29956,
29874,
510,
29924,
8194,
2624,
29898,
10141,
29892,
10668,
29892,
6389,
29897,
13,
462,
4706,
6023,
267,
29961,
16747,
29889,
333,
29962,
353,
6023,
13,
462,
1678,
565,
6023,
29889,
29879,
29916,
1275,
6389,
1839,
29916,
2033,
320,
13,
462,
9651,
322,
6023,
29889,
29879,
29891,
1275,
6389,
1839,
29891,
2033,
320,
13,
462,
9651,
322,
10668,
297,
6023,
267,
29918,
18616,
29901,
13,
462,
4706,
6773,
13,
462,
1678,
6023,
29889,
11631,
29898,
5085,
29897,
13,
462,
1678,
565,
10668,
451,
297,
6023,
267,
29918,
18616,
29901,
13,
462,
4706,
9521,
29889,
4397,
29898,
877,
463,
742,
6023,
876,
13,
462,
4706,
6023,
267,
29918,
18616,
29889,
4397,
29898,
17681,
29897,
13,
462,
1678,
9521,
29889,
4397,
29898,
877,
5504,
742,
6023,
876,
13,
13,
18884,
363,
10668,
297,
1051,
29898,
16747,
267,
29889,
8149,
3101,
7503,
5387,
13,
462,
1678,
565,
10668,
451,
297,
1044,
3145,
29901,
13,
462,
4706,
6023,
353,
6023,
267,
29961,
17681,
29962,
13,
462,
4706,
565,
10668,
297,
6023,
267,
29918,
18616,
29901,
13,
462,
9651,
6023,
29889,
5504,
29918,
2230,
29918,
355,
580,
13,
462,
9651,
9521,
29889,
4397,
29898,
877,
355,
742,
6023,
876,
13,
462,
9651,
6023,
267,
29918,
18616,
29889,
5992,
29898,
17681,
29897,
13,
462,
4706,
628,
6023,
267,
29961,
17681,
29962,
13,
13,
9651,
822,
4226,
675,
29898,
1767,
29892,
325,
1195,
29892,
325,
3317,
1125,
13,
18884,
736,
313,
1767,
448,
325,
1195,
29897,
847,
5785,
29898,
29894,
3317,
448,
325,
1195,
29897,
13,
13,
9651,
396,
1722,
278,
1881,
13,
9651,
1018,
29901,
13,
18884,
285,
29881,
353,
1722,
29898,
2080,
29918,
9144,
29892,
525,
6050,
1495,
13,
9651,
5174,
10663,
2392,
29901,
13,
18884,
28468,
29889,
11739,
877,
2525,
519,
304,
1722,
1273,
29879,
29915,
1273,
1881,
29918,
9144,
29897,
13,
18884,
736,
13,
13,
9651,
396,
679,
278,
4701,
1024,
313,
22240,
5971,
11135,
5813,
29897,
13,
9651,
4742,
29918,
978,
353,
285,
20047,
29880,
29889,
601,
16948,
29898,
11512,
29892,
382,
29963,
5971,
11135,
5813,
718,
313,
29906,
29945,
29953,
3532,
29871,
29896,
29953,
511,
13,
462,
462,
418,
376,
376,
334,
29871,
29906,
29945,
29953,
467,
5451,
28909,
29916,
29900,
29900,
29861,
29900,
29962,
13,
9651,
28468,
29889,
3888,
877,
24085,
29956,
29874,
510,
29901,
773,
20577,
29879,
16299,
1273,
4742,
29918,
978,
29897,
13,
13,
9651,
396,
679,
6425,
3041,
359,
13,
9651,
2586,
353,
285,
20047,
29880,
29889,
601,
16948,
29898,
11512,
29892,
382,
29963,
5971,
29907,
7210,
1806,
718,
313,
22240,
29918,
12648,
3532,
29871,
29896,
29953,
511,
525,
525,
334,
2268,
29918,
29880,
29897,
13,
9651,
2586,
29892,
353,
2281,
29889,
348,
4058,
877,
29984,
742,
2586,
29897,
13,
9651,
363,
921,
297,
3464,
29898,
22240,
29918,
12648,
1125,
13,
18884,
396,
19905,
445,
29892,
591,
1122,
864,
916,
2712,
1135,
382,
29963,
29918,
2882,
29903,
13,
18884,
565,
921,
2804,
382,
29963,
29918,
2882,
29903,
29901,
13,
462,
1678,
6773,
13,
18884,
396,
382,
29963,
29918,
2882,
29903,
3625,
363,
445,
4742,
1577,
13,
18884,
565,
313,
2966,
669,
313,
29896,
3532,
921,
876,
1275,
29871,
29900,
29901,
13,
462,
1678,
6773,
13,
18884,
396,
2244,
6425,
5235,
6611,
304,
278,
9224,
13,
18884,
269,
2966,
353,
285,
20047,
29880,
29889,
601,
16948,
29898,
11512,
29892,
382,
29963,
5971,
29907,
7210,
1806,
718,
921,
718,
313,
10818,
29918,
12648,
3532,
29871,
29896,
29953,
511,
13,
462,
462,
259,
525,
525,
334,
2268,
29918,
29880,
29897,
13,
18884,
269,
2966,
29892,
353,
2281,
29889,
348,
4058,
877,
29984,
742,
269,
2966,
29897,
13,
18884,
363,
343,
297,
3464,
29898,
10818,
29918,
12648,
1125,
13,
462,
1678,
565,
313,
29879,
2966,
669,
313,
29896,
3532,
343,
876,
1275,
29871,
29900,
29901,
13,
462,
4706,
6773,
13,
462,
1678,
6425,
3888,
353,
285,
20047,
29880,
29889,
601,
16948,
29898,
11512,
29892,
382,
29963,
5971,
11135,
2882,
29903,
718,
343,
718,
13,
462,
462,
3986,
313,
4984,
29918,
2080,
29918,
6897,
3888,
29918,
3616,
3532,
29871,
29896,
29953,
511,
13,
462,
462,
3986,
525,
525,
334,
2281,
29918,
2080,
29918,
6897,
3888,
29918,
3616,
29897,
13,
462,
1678,
6425,
29918,
1767,
29892,
6425,
29918,
1195,
29892,
6425,
29918,
3317,
29892,
6425,
29918,
29888,
18813,
29892,
320,
13,
462,
4706,
6425,
29918,
20620,
29892,
6425,
29918,
690,
353,
2281,
29889,
348,
4058,
877,
2236,
2236,
2236,
742,
6425,
3888,
29897,
13,
462,
1678,
565,
343,
1275,
319,
9851,
29918,
29990,
29901,
13,
462,
4706,
3464,
29918,
1195,
29918,
3283,
29918,
29916,
353,
270,
2288,
877,
1195,
29918,
3283,
29918,
29916,
742,
6425,
29918,
1195,
29897,
13,
462,
4706,
3464,
29918,
3317,
29918,
3283,
29918,
29916,
353,
270,
2288,
877,
3317,
29918,
3283,
29918,
29916,
742,
6425,
29918,
3317,
29897,
13,
462,
4706,
28468,
29889,
3888,
877,
24085,
29956,
29874,
510,
29901,
525,
718,
13,
462,
462,
1678,
12801,
29995,
29879,
29958,
3464,
2602,
1060,
338,
1273,
29881,
448,
1273,
29881,
29915,
1273,
313,
13,
462,
462,
4706,
4742,
29918,
978,
29892,
6425,
29918,
1195,
29892,
6425,
29918,
3317,
876,
13,
462,
1678,
25342,
343,
1275,
319,
9851,
29918,
29979,
29901,
13,
462,
4706,
3464,
29918,
1195,
29918,
3283,
29918,
29891,
353,
270,
2288,
877,
1195,
29918,
3283,
29918,
29891,
742,
6425,
29918,
1195,
29897,
13,
462,
4706,
3464,
29918,
3317,
29918,
3283,
29918,
29891,
353,
270,
2288,
877,
3317,
29918,
3283,
29918,
29891,
742,
6425,
29918,
3317,
29897,
13,
462,
4706,
28468,
29889,
3888,
877,
24085,
29956,
29874,
510,
29901,
525,
718,
13,
462,
462,
1678,
12801,
29995,
29879,
29958,
3464,
2602,
612,
338,
1273,
29881,
448,
1273,
29881,
29915,
1273,
313,
13,
462,
462,
4706,
4742,
29918,
978,
29892,
6425,
29918,
1195,
29892,
6425,
29918,
3317,
876,
13,
462,
1678,
25342,
343,
1275,
319,
9851,
29918,
15094,
1799,
11499,
29901,
13,
462,
4706,
3464,
29918,
1195,
29918,
2139,
545,
353,
270,
2288,
877,
1195,
29918,
2139,
545,
742,
6425,
29918,
1195,
29897,
13,
462,
4706,
3464,
29918,
3317,
29918,
2139,
545,
353,
270,
2288,
877,
3317,
29918,
2139,
545,
742,
6425,
29918,
3317,
29897,
13,
462,
4706,
28468,
29889,
3888,
877,
24085,
29956,
29874,
510,
29901,
525,
718,
13,
462,
462,
1678,
12801,
29995,
29879,
29958,
3464,
12959,
338,
1273,
29881,
448,
1273,
29881,
29915,
1273,
313,
13,
462,
462,
4706,
4742,
29918,
978,
29892,
6425,
29918,
1195,
29892,
6425,
29918,
3317,
876,
13,
13,
9651,
396,
1303,
2745,
278,
1095,
13,
9651,
3939,
353,
7700,
13,
9651,
6023,
29918,
333,
353,
29871,
29900,
13,
9651,
6023,
29918,
29916,
353,
29871,
29900,
13,
9651,
6023,
29918,
29891,
353,
29871,
29900,
13,
9651,
6023,
29918,
2139,
545,
353,
29871,
29900,
13,
9651,
1550,
285,
29881,
29901,
13,
13,
18884,
848,
353,
285,
29881,
29889,
949,
29898,
4984,
29918,
2080,
29918,
3696,
29918,
3616,
29897,
13,
18884,
565,
7431,
29898,
1272,
29897,
529,
2281,
29918,
2080,
29918,
3696,
29918,
3616,
29901,
13,
462,
1678,
2867,
13,
13,
18884,
396,
6597,
1269,
1741,
13,
18884,
363,
474,
297,
3464,
29898,
2435,
29898,
1272,
29897,
847,
2281,
29918,
2080,
29918,
3696,
29918,
3616,
1125,
13,
462,
1678,
3415,
353,
848,
29961,
29875,
334,
2281,
29918,
2080,
29918,
3696,
29918,
3616,
17531,
13,
13,
462,
1678,
396,
6597,
931,
791,
718,
1741,
3041,
359,
13,
462,
1678,
9631,
29918,
3471,
29892,
9631,
29918,
1509,
29883,
29892,
3415,
29918,
1853,
29892,
3415,
29918,
401,
29892,
3415,
29918,
1767,
353,
320,
13,
462,
4706,
2281,
29889,
348,
4058,
877,
2208,
29950,
18567,
742,
3415,
7503,
4984,
29918,
2080,
29918,
3696,
29918,
3616,
2314,
13,
13,
462,
1678,
565,
3415,
29918,
1853,
1275,
382,
29963,
29918,
14816,
29940,
322,
3415,
29918,
401,
1275,
28962,
29940,
29918,
1525,
15082,
29901,
13,
462,
4706,
565,
6023,
29918,
333,
297,
301,
29918,
9748,
29901,
13,
462,
9651,
282,
353,
301,
29918,
9748,
29961,
16747,
29918,
333,
29962,
13,
462,
4706,
1683,
29901,
13,
462,
9651,
282,
353,
9657,
580,
13,
462,
9651,
301,
29918,
9748,
29961,
16747,
29918,
333,
29962,
353,
282,
13,
462,
4706,
282,
1839,
333,
2033,
353,
6023,
29918,
333,
13,
462,
4706,
565,
451,
10092,
29918,
16747,
29901,
13,
462,
9651,
282,
1839,
29916,
2033,
353,
6023,
29918,
29916,
13,
462,
9651,
282,
1839,
29891,
2033,
353,
6023,
29918,
29891,
13,
462,
9651,
282,
1839,
2139,
545,
2033,
353,
6023,
29918,
2139,
545,
13,
462,
4706,
565,
1583,
29889,
8513,
1275,
525,
2238,
29915,
320,
13,
462,
18884,
322,
6023,
29918,
2139,
545,
1275,
29871,
29900,
320,
13,
462,
18884,
322,
451,
10092,
29918,
16747,
29901,
13,
462,
9651,
628,
301,
29918,
9748,
29961,
16747,
29918,
333,
29962,
13,
462,
4706,
565,
3939,
29901,
13,
462,
9651,
565,
525,
29916,
29915,
451,
297,
282,
29901,
13,
462,
18884,
10092,
29918,
16747,
353,
7700,
13,
462,
18884,
6773,
13,
462,
9651,
1889,
29898,
29880,
29918,
9748,
29897,
13,
462,
9651,
3939,
353,
7700,
13,
462,
4706,
565,
10092,
29918,
16747,
29901,
13,
462,
9651,
301,
29918,
9748,
29889,
8551,
580,
13,
462,
9651,
10092,
29918,
16747,
353,
7700,
13,
462,
9651,
1889,
29898,
29880,
29918,
9748,
29897,
13,
462,
1678,
25342,
3415,
29918,
1853,
1275,
382,
29963,
29918,
4345,
29907,
322,
3415,
29918,
401,
1275,
341,
7187,
29918,
6304,
25758,
29901,
13,
462,
4706,
6023,
29918,
333,
353,
3415,
29918,
1767,
13,
462,
1678,
25342,
3415,
29918,
1853,
1275,
382,
29963,
29918,
2882,
29903,
322,
3415,
29918,
401,
1275,
319,
9851,
29918,
29990,
29901,
13,
462,
4706,
659,
353,
4226,
675,
29898,
5750,
29918,
1767,
29892,
13,
462,
462,
4706,
3464,
29918,
1195,
29918,
3283,
29918,
29916,
29892,
13,
462,
462,
4706,
3464,
29918,
3317,
29918,
3283,
29918,
29916,
29897,
13,
462,
4706,
565,
21292,
29918,
29916,
29901,
13,
462,
9651,
659,
353,
29871,
29896,
29889,
448,
659,
13,
462,
4706,
6023,
29918,
29916,
353,
659,
13,
462,
4706,
3939,
353,
5852,
13,
462,
1678,
25342,
3415,
29918,
1853,
1275,
382,
29963,
29918,
2882,
29903,
322,
3415,
29918,
401,
1275,
319,
9851,
29918,
29979,
29901,
13,
462,
4706,
659,
353,
29871,
29896,
29889,
448,
4226,
675,
29898,
5750,
29918,
1767,
29892,
13,
462,
462,
632,
3464,
29918,
1195,
29918,
3283,
29918,
29891,
29892,
13,
462,
462,
632,
3464,
29918,
3317,
29918,
3283,
29918,
29891,
29897,
13,
462,
4706,
565,
21292,
29918,
29891,
29901,
13,
462,
9651,
659,
353,
29871,
29896,
29889,
448,
659,
13,
462,
4706,
6023,
29918,
29891,
353,
659,
13,
462,
4706,
3939,
353,
5852,
13,
462,
1678,
25342,
3415,
29918,
1853,
1275,
382,
29963,
29918,
2882,
29903,
322,
3415,
29918,
401,
1275,
319,
9851,
29918,
15094,
1799,
11499,
29901,
13,
462,
4706,
6023,
29918,
2139,
545,
353,
4226,
675,
29898,
5750,
29918,
1767,
29892,
13,
462,
462,
462,
259,
3464,
29918,
1195,
29918,
2139,
545,
29892,
13,
462,
462,
462,
259,
3464,
29918,
3317,
29918,
2139,
545,
29897,
13,
462,
4706,
3939,
353,
5852,
13,
462,
1678,
25342,
3415,
29918,
1853,
1275,
382,
29963,
29918,
2882,
29903,
322,
3415,
29918,
401,
1275,
319,
9851,
29918,
29924,
3235,
29907,
29901,
13,
462,
4706,
565,
3415,
29918,
1767,
1275,
29871,
29900,
29901,
13,
462,
9651,
10092,
29918,
16747,
353,
5852,
13,
13,
4706,
822,
2767,
29898,
1311,
29892,
13916,
29918,
9144,
1125,
13,
9651,
396,
13916,
599,
1741,
515,
9717,
13,
9651,
1018,
29901,
13,
18884,
1550,
5852,
29901,
13,
462,
1678,
1741,
29918,
1853,
29892,
6023,
353,
1583,
29889,
9990,
29889,
7323,
1563,
580,
13,
462,
1678,
13916,
29918,
9144,
29898,
3696,
29918,
1853,
29892,
6023,
29897,
13,
9651,
5174,
29901,
13,
18884,
1209,
13,
13,
1678,
7142,
291,
2624,
5126,
29889,
9573,
877,
9389,
2766,
510,
742,
8074,
29956,
29874,
510,
29924,
8194,
2624,
6980,
29897,
13,
2
] |
section-3-13-mini_project-solution.py | gopal-amlekar/Jumpstart-IOT-Exercise | 1 | 75991 | import RPi.GPIO as GPIO
import smbus
import time
SHT21_ADD = 0x40
SHT21_STATUS_MASK = 0xFFFC
SHT21_MEASURE_TEMP_CMD = 0xF3
SHT21_MEASURE_HUM_CMD = 0xF5
MAX_TEMPERATURE = 120
MAX_HUMIDITY = 100
temperatureBarGraph = [26,23,20,17,14,11,8,5]
humidityBarGraph = [27,24,21,18,15,12,9,6]
unusedLEDs = [16,13,10,7]
temperatureButton = 25
humidityButton = 22
def get_temperature():
bus.write_byte(SHT21_ADD, SHT21_MEASURE_TEMP_CMD)
time.sleep(0.1)
temp_msb = bus.read_byte (SHT21_ADD)
#print temp_msb
temp_lsb = bus.read_byte (SHT21_ADD)
#print temp_lsb
temp_chksm = bus.read_byte (SHT21_ADD)
#print temp_chksm
temperature = (temp_msb << 8) + temp_lsb
#print temperature
temperature &= SHT21_STATUS_MASK
#print temperature
temperature *= 175.72
#print temperature
temperature /= 1<<16
#print temperature
temperature -= 46.85
return temperature
def get_humidity():
bus.write_byte(SHT21_ADD, SHT21_MEASURE_HUM_CMD)
time.sleep(0.1)
hum_msb = bus.read_byte (SHT21_ADD)
#print temp_msb
hum_lsb = bus.read_byte (SHT21_ADD)
#print temp_lsb
hum_chksm = bus.read_byte (SHT21_ADD)
#print temp_chksm
humidity = (hum_msb << 8) + hum_lsb
#print temperature
humidity &= SHT21_STATUS_MASK
#print temperature
humidity *= 125.0
#print temperature
humidity /= 1<<16
#print temperature
humidity -= 6
return humidity
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
for led_tmp in temperatureBarGraph:
GPIO.setup(led_tmp, GPIO.OUT)
for led_hum in humidityBarGraph:
GPIO.setup(led_hum, GPIO.OUT)
for led_tmp in temperatureBarGraph:
GPIO.output(led_tmp, GPIO.LOW)
for led_hum in humidityBarGraph:
GPIO.output(led_hum, GPIO.LOW)
for led_unused in unusedLEDs:
GPIO.setup(led_unused, GPIO.OUT)
GPIO.output(led_unused, GPIO.LOW)
GPIO.setup(temperatureButton, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(humidityButton, GPIO.IN, pull_up_down=GPIO.PUD_UP)
temperatureLEDs = len(temperatureBarGraph)
humidityLEDs = len(humidityBarGraph)
temperatureDiv = int(MAX_TEMPERATURE / temperatureLEDs) - 1
humidityDiv = int(MAX_HUMIDITY / humidityLEDs)
try:
bus = smbus.SMBus(1)
while True:
time.sleep(2)
temperature = get_temperature()
humidity = get_humidity()
print "Temperature is ", temperature
print "Humidity is ", humidity
if (GPIO.input(temperatureButton)):
bar_level = int(temperature/temperatureDiv)
for led_temp in range(0, bar_level):
#print led_temp
GPIO.output(temperatureBarGraph[led_temp], GPIO.HIGH)
for led_temp in range(bar_level, len(temperatureBarGraph)):
GPIO.output(temperatureBarGraph[led_temp], GPIO.LOW)
else:
for led_tmp in temperatureBarGraph:
GPIO.output(led_tmp, GPIO.LOW)
if (GPIO.input(humidityButton)):
bar_level = int(humidity/humidityDiv)
for led_temp in range(0, bar_level):
#print led_temp
GPIO.output(humidityBarGraph[led_temp], GPIO.HIGH)
for led_temp in range(bar_level, len(humidityBarGraph)):
GPIO.output(humidityBarGraph[led_temp], GPIO.LOW)
else:
for led_tmp in humidityBarGraph:
GPIO.output(led_tmp, GPIO.LOW)
except IOError as (errno, strerror):
print "I/O error({0}): {1}. Try changing I2C device number in code".format(errno, strerror)
except KeyboardInterrupt:
print "Keyboard Interrupt Received"
except:
print "Unexpected error:"
raise
finally:
GPIO.cleanup()
print "Exiting Program"
| [
1,
1053,
390,
12197,
29889,
29954,
2227,
29949,
408,
402,
2227,
29949,
13,
5215,
1560,
8262,
13,
5215,
931,
13,
13,
29903,
3912,
29906,
29896,
29918,
17744,
353,
29871,
29900,
29916,
29946,
29900,
13,
29903,
3912,
29906,
29896,
29918,
27047,
29918,
1529,
16033,
353,
29871,
29900,
29916,
4198,
8610,
13,
13,
29903,
3912,
29906,
29896,
29918,
2303,
3289,
11499,
29918,
4330,
3580,
29918,
29907,
5773,
353,
29871,
29900,
29916,
29943,
29941,
13,
29903,
3912,
29906,
29896,
29918,
2303,
3289,
11499,
29918,
29950,
5005,
29918,
29907,
5773,
353,
29871,
29900,
29916,
29943,
29945,
13,
13,
12648,
29918,
4330,
3580,
1001,
1299,
11499,
353,
29871,
29896,
29906,
29900,
13,
12648,
29918,
29950,
5005,
1367,
11937,
353,
29871,
29896,
29900,
29900,
13,
13,
13,
12863,
1535,
4297,
9527,
353,
518,
29906,
29953,
29892,
29906,
29941,
29892,
29906,
29900,
29892,
29896,
29955,
29892,
29896,
29946,
29892,
29896,
29896,
29892,
29947,
29892,
29945,
29962,
13,
16063,
333,
537,
4297,
9527,
353,
518,
29906,
29955,
29892,
29906,
29946,
29892,
29906,
29896,
29892,
29896,
29947,
29892,
29896,
29945,
29892,
29896,
29906,
29892,
29929,
29892,
29953,
29962,
13,
348,
3880,
20566,
29879,
353,
518,
29896,
29953,
29892,
29896,
29941,
29892,
29896,
29900,
29892,
29955,
29962,
13,
13,
12863,
1535,
3125,
353,
29871,
29906,
29945,
13,
16063,
333,
537,
3125,
353,
29871,
29906,
29906,
13,
13,
1753,
679,
29918,
12863,
1535,
7295,
13,
1678,
3593,
29889,
3539,
29918,
10389,
29898,
29903,
3912,
29906,
29896,
29918,
17744,
29892,
317,
3912,
29906,
29896,
29918,
2303,
3289,
11499,
29918,
4330,
3580,
29918,
29907,
5773,
29897,
13,
13,
1678,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
13,
1678,
5694,
29918,
1516,
29890,
353,
3593,
29889,
949,
29918,
10389,
313,
29903,
3912,
29906,
29896,
29918,
17744,
29897,
13,
1678,
396,
2158,
5694,
29918,
1516,
29890,
13,
1678,
5694,
29918,
3137,
29890,
353,
3593,
29889,
949,
29918,
10389,
313,
29903,
3912,
29906,
29896,
29918,
17744,
29897,
13,
1678,
396,
2158,
5694,
29918,
3137,
29890,
13,
1678,
5694,
29918,
305,
2039,
29885,
353,
3593,
29889,
949,
29918,
10389,
313,
29903,
3912,
29906,
29896,
29918,
17744,
29897,
13,
1678,
396,
2158,
5694,
29918,
305,
2039,
29885,
13,
268,
13,
1678,
10430,
353,
313,
7382,
29918,
1516,
29890,
3532,
29871,
29947,
29897,
718,
5694,
29918,
3137,
29890,
13,
1678,
396,
2158,
10430,
13,
1678,
10430,
7878,
317,
3912,
29906,
29896,
29918,
27047,
29918,
1529,
16033,
13,
1678,
396,
2158,
10430,
13,
1678,
10430,
334,
29922,
29871,
29896,
29955,
29945,
29889,
29955,
29906,
13,
1678,
396,
2158,
10430,
13,
1678,
10430,
847,
29922,
29871,
29896,
9314,
29896,
29953,
13,
1678,
396,
2158,
10430,
13,
1678,
10430,
22361,
29871,
29946,
29953,
29889,
29947,
29945,
13,
13,
1678,
736,
10430,
13,
13,
13,
1753,
679,
29918,
16063,
333,
537,
7295,
13,
1678,
3593,
29889,
3539,
29918,
10389,
29898,
29903,
3912,
29906,
29896,
29918,
17744,
29892,
317,
3912,
29906,
29896,
29918,
2303,
3289,
11499,
29918,
29950,
5005,
29918,
29907,
5773,
29897,
13,
13,
1678,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
13,
1678,
3165,
29918,
1516,
29890,
353,
3593,
29889,
949,
29918,
10389,
313,
29903,
3912,
29906,
29896,
29918,
17744,
29897,
13,
1678,
396,
2158,
5694,
29918,
1516,
29890,
13,
1678,
3165,
29918,
3137,
29890,
353,
3593,
29889,
949,
29918,
10389,
313,
29903,
3912,
29906,
29896,
29918,
17744,
29897,
13,
1678,
396,
2158,
5694,
29918,
3137,
29890,
13,
1678,
3165,
29918,
305,
2039,
29885,
353,
3593,
29889,
949,
29918,
10389,
313,
29903,
3912,
29906,
29896,
29918,
17744,
29897,
13,
1678,
396,
2158,
5694,
29918,
305,
2039,
29885,
13,
268,
13,
1678,
3165,
333,
537,
353,
313,
16063,
29918,
1516,
29890,
3532,
29871,
29947,
29897,
718,
3165,
29918,
3137,
29890,
13,
1678,
396,
2158,
10430,
13,
1678,
3165,
333,
537,
7878,
317,
3912,
29906,
29896,
29918,
27047,
29918,
1529,
16033,
13,
1678,
396,
2158,
10430,
13,
1678,
3165,
333,
537,
334,
29922,
29871,
29896,
29906,
29945,
29889,
29900,
13,
1678,
396,
2158,
10430,
13,
1678,
3165,
333,
537,
847,
29922,
29871,
29896,
9314,
29896,
29953,
13,
1678,
396,
2158,
10430,
13,
1678,
3165,
333,
537,
22361,
29871,
29953,
13,
13,
1678,
736,
3165,
333,
537,
13,
13,
13,
13,
29954,
2227,
29949,
29889,
842,
25442,
886,
29898,
8824,
29897,
13,
29954,
2227,
29949,
29889,
842,
8513,
29898,
29954,
2227,
29949,
29889,
5371,
29924,
29897,
13,
13,
13,
1454,
5331,
29918,
7050,
297,
10430,
4297,
9527,
29901,
13,
1678,
402,
2227,
29949,
29889,
14669,
29898,
839,
29918,
7050,
29892,
402,
2227,
29949,
29889,
12015,
29897,
13,
13,
1454,
5331,
29918,
16063,
297,
3165,
333,
537,
4297,
9527,
29901,
13,
1678,
402,
2227,
29949,
29889,
14669,
29898,
839,
29918,
16063,
29892,
402,
2227,
29949,
29889,
12015,
29897,
29871,
13,
13,
1454,
5331,
29918,
7050,
297,
10430,
4297,
9527,
29901,
13,
1678,
402,
2227,
29949,
29889,
4905,
29898,
839,
29918,
7050,
29892,
402,
2227,
29949,
29889,
27998,
29897,
29871,
13,
13,
1454,
5331,
29918,
16063,
297,
3165,
333,
537,
4297,
9527,
29901,
13,
1678,
402,
2227,
29949,
29889,
4905,
29898,
839,
29918,
16063,
29892,
402,
2227,
29949,
29889,
27998,
29897,
13,
13,
1454,
5331,
29918,
348,
3880,
297,
443,
3880,
20566,
29879,
29901,
13,
1678,
402,
2227,
29949,
29889,
14669,
29898,
839,
29918,
348,
3880,
29892,
402,
2227,
29949,
29889,
12015,
29897,
13,
1678,
402,
2227,
29949,
29889,
4905,
29898,
839,
29918,
348,
3880,
29892,
402,
2227,
29949,
29889,
27998,
29897,
13,
13,
29954,
2227,
29949,
29889,
14669,
29898,
12863,
1535,
3125,
29892,
402,
2227,
29949,
29889,
1177,
29892,
8206,
29918,
786,
29918,
3204,
29922,
29954,
2227,
29949,
29889,
7056,
29928,
29918,
4897,
29897,
13,
29954,
2227,
29949,
29889,
14669,
29898,
16063,
333,
537,
3125,
29892,
402,
2227,
29949,
29889,
1177,
29892,
8206,
29918,
786,
29918,
3204,
29922,
29954,
2227,
29949,
29889,
7056,
29928,
29918,
4897,
29897,
13,
13,
13,
12863,
1535,
20566,
29879,
353,
7431,
29898,
12863,
1535,
4297,
9527,
29897,
13,
16063,
333,
537,
20566,
29879,
353,
7431,
29898,
16063,
333,
537,
4297,
9527,
29897,
13,
13,
12863,
1535,
12596,
353,
938,
29898,
12648,
29918,
4330,
3580,
1001,
1299,
11499,
847,
10430,
20566,
29879,
29897,
448,
29871,
29896,
13,
16063,
333,
537,
12596,
353,
938,
29898,
12648,
29918,
29950,
5005,
1367,
11937,
847,
3165,
333,
537,
20566,
29879,
29897,
13,
13,
2202,
29901,
13,
1678,
3593,
353,
1560,
8262,
29889,
29903,
9486,
375,
29898,
29896,
29897,
13,
1678,
1550,
5852,
29901,
13,
4706,
931,
29889,
17059,
29898,
29906,
29897,
13,
4706,
10430,
353,
679,
29918,
12863,
1535,
580,
13,
4706,
3165,
333,
537,
353,
679,
29918,
16063,
333,
537,
580,
13,
308,
13,
4706,
1596,
376,
5776,
546,
1535,
338,
9162,
10430,
13,
4706,
1596,
376,
29950,
398,
333,
537,
338,
9162,
3165,
333,
537,
13,
308,
13,
308,
13,
4706,
565,
313,
29954,
2227,
29949,
29889,
2080,
29898,
12863,
1535,
3125,
22164,
13,
9651,
2594,
29918,
5563,
353,
938,
29898,
12863,
1535,
29914,
12863,
1535,
12596,
29897,
13,
9651,
363,
5331,
29918,
7382,
297,
3464,
29898,
29900,
29892,
2594,
29918,
5563,
1125,
13,
18884,
396,
2158,
5331,
29918,
7382,
13,
18884,
402,
2227,
29949,
29889,
4905,
29898,
12863,
1535,
4297,
9527,
29961,
839,
29918,
7382,
1402,
402,
2227,
29949,
29889,
29950,
6259,
29950,
29897,
13,
9651,
363,
5331,
29918,
7382,
297,
3464,
29898,
1646,
29918,
5563,
29892,
7431,
29898,
12863,
1535,
4297,
9527,
22164,
13,
18884,
402,
2227,
29949,
29889,
4905,
29898,
12863,
1535,
4297,
9527,
29961,
839,
29918,
7382,
1402,
402,
2227,
29949,
29889,
27998,
29897,
13,
4706,
1683,
29901,
13,
9651,
363,
5331,
29918,
7050,
297,
10430,
4297,
9527,
29901,
13,
18884,
402,
2227,
29949,
29889,
4905,
29898,
839,
29918,
7050,
29892,
402,
2227,
29949,
29889,
27998,
29897,
29871,
13,
13,
4706,
565,
313,
29954,
2227,
29949,
29889,
2080,
29898,
16063,
333,
537,
3125,
22164,
13,
9651,
2594,
29918,
5563,
353,
938,
29898,
16063,
333,
537,
29914,
16063,
333,
537,
12596,
29897,
13,
9651,
363,
5331,
29918,
7382,
297,
3464,
29898,
29900,
29892,
2594,
29918,
5563,
1125,
13,
18884,
396,
2158,
5331,
29918,
7382,
13,
18884,
402,
2227,
29949,
29889,
4905,
29898,
16063,
333,
537,
4297,
9527,
29961,
839,
29918,
7382,
1402,
402,
2227,
29949,
29889,
29950,
6259,
29950,
29897,
13,
9651,
363,
5331,
29918,
7382,
297,
3464,
29898,
1646,
29918,
5563,
29892,
7431,
29898,
16063,
333,
537,
4297,
9527,
22164,
13,
18884,
402,
2227,
29949,
29889,
4905,
29898,
16063,
333,
537,
4297,
9527,
29961,
839,
29918,
7382,
1402,
402,
2227,
29949,
29889,
27998,
29897,
13,
4706,
1683,
29901,
13,
9651,
363,
5331,
29918,
7050,
297,
3165,
333,
537,
4297,
9527,
29901,
13,
18884,
402,
2227,
29949,
29889,
4905,
29898,
839,
29918,
7050,
29892,
402,
2227,
29949,
29889,
27998,
29897,
29871,
13,
632,
13,
19499,
10663,
2392,
408,
313,
3127,
1217,
29892,
851,
2704,
1125,
13,
1678,
1596,
376,
29902,
29914,
29949,
1059,
3319,
29900,
29913,
1125,
426,
29896,
1836,
3967,
6480,
306,
29906,
29907,
4742,
1353,
297,
775,
1642,
4830,
29898,
3127,
1217,
29892,
851,
2704,
29897,
13,
19499,
7670,
3377,
4074,
6685,
29901,
13,
1678,
1596,
376,
2558,
3377,
4124,
6685,
24328,
2347,
29908,
13,
19499,
29901,
13,
1678,
1596,
376,
29965,
13996,
6021,
1059,
6160,
13,
1678,
12020,
13,
4951,
635,
29901,
13,
1678,
402,
2227,
29949,
29889,
14941,
786,
580,
13,
1678,
1596,
376,
1252,
11407,
7835,
29908,
13,
2
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.