Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fe2a5fd
Solution
korolinakila Sep 29, 2025
96304bd
Merge branch 'EvgrafovMichail:main' into main
korolinakila Oct 4, 2025
1b1fb87
Matvey Makar
korolinakila Oct 9, 2025
78911a9
Makarov Matvey
korolinakila Oct 10, 2025
d869a86
Merge branch 'EvgrafovMichail:main' into main
korolinakila Oct 11, 2025
e28a0cd
Makarov Matvey 514
korolinakila Oct 17, 2025
7e874d9
Merge branch 'EvgrafovMichail:main' into main
korolinakila Oct 23, 2025
c4cff89
Makarov514
korolinakila Oct 23, 2025
73ea62f
Merge branch 'EvgrafovMichail:main' into main
korolinakila Oct 30, 2025
51b9329
B12-514 Makarov Matvey
korolinakila Nov 1, 2025
c34ac49
Merge branch 'EvgrafovMichail:main' into main
korolinakila Nov 13, 2025
b563b4b
Makarov514
korolinakila Nov 14, 2025
e574924
Makarov514
korolinakila Nov 15, 2025
916e044
Merge branch 'EvgrafovMichail:main' into main
korolinakila Nov 20, 2025
0afa7d9
HW1
korolinakila Nov 30, 2025
ab0d325
HW1
korolinakila Nov 30, 2025
faadf42
Merge branch 'EvgrafovMichail:main' into main
korolinakila Dec 4, 2025
477ecf3
lesson11
korolinakila Dec 7, 2025
87c4d9e
Merge branch 'EvgrafovMichail:main' into main
korolinakila Dec 9, 2025
0cc503c
lesson12
korolinakila Dec 11, 2025
d1c3c73
Б12-514 Макаров Матвей
korolinakila Mar 6, 2026
3f7bba1
Update task1.py
korolinakila Mar 6, 2026
b5e32b3
Merge branch 'EvgrafovMichail:main' into main
korolinakila Mar 12, 2026
f9ae41a
lesson4 dz
korolinakila Mar 13, 2026
a4e7bf6
Merge branch 'EvgrafovMichail:main' into main
korolinakila Mar 20, 2026
cae656b
dz lesson 3
korolinakila Mar 20, 2026
3c9c9e5
Merge branch 'EvgrafovMichail:main' into main
korolinakila Apr 10, 2026
5895704
hw lesson7
korolinakila Apr 10, 2026
69786b1
Merge branch 'EvgrafovMichail:main' into main
korolinakila Apr 15, 2026
dafa96e
dz 8
korolinakila Apr 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\Users\\Matvey\\gcc\\bin\\gcc.exe",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"C_Cpp.errorSquiggles": "enabled"
}
80 changes: 77 additions & 3 deletions homeworks/sem01/hw1/aggregate_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"voice_bot",
}


def aggregate_segmentation(
segmentation_data: list[dict[str, str | float | None]],
) -> tuple[dict[str, dict[str, dict[str, str | float]]], list[str]]:
Expand All @@ -24,5 +23,80 @@ def aggregate_segmentation(
Список `audio_id` (str), которые требуют переразметки.
"""

# ваш код
return {}, []
valid_data = {}
audio_ids_with_errors = tuple()
segment_cache = {}



for segment in segmentation_data:

if "segment_id" not in segment or segment["segment_id"] is None:
continue

if "audio_id" not in segment or segment["audio_id"] is None:
continue

audio_id = segment["audio_id"]
segment_id = segment["segment_id"]


is_valid = True


if not isinstance(segment_id, str):
is_valid = False
if not isinstance(audio_id, str):
is_valid = False


type_val = segment.get("type")
start_val = segment.get("segment_start")
end_val = segment.get("segment_end")

none_count = 0
for i in [type_val, start_val, end_val]:
if i is None:
none_count += 1

if none_count == 1 or none_count == 2:

is_valid = False
elif none_count == 0:

if not isinstance(type_val, str):
is_valid = False
elif type_val not in ALLOWED_TYPES:
is_valid = False

if not isinstance(start_val, float):
is_valid = False
if not isinstance(end_val, float):
is_valid = False


if not is_valid:
audio_ids_with_errors = tuple(list(audio_ids_with_errors) + [audio_id])
else:
if none_count == 0:
if audio_id not in valid_data:
valid_data[audio_id] = {}

valid_data[audio_id][segment_id] = {
"start": start_val,
"end": end_val,
"type": type_val
}
elif none_count == 3:
if audio_id not in valid_data:
valid_data[audio_id] = {}




for audio_id in list(valid_data.keys()):
if audio_id in audio_ids_with_errors:
del valid_data[audio_id]


return valid_data, audio_ids_with_errors
46 changes: 44 additions & 2 deletions homeworks/sem01/hw1/backoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,47 @@ def backoff(
ValueError, если были переданы невозможные аргументы.
"""

# ваш код
pass
if retry_amount < 1 or retry_amount > 100:
raise ValueError("retry_amount должен быть в диапазоне от 1 до 100")

if timeout_start <= 0 or timeout_start >= 10:
raise ValueError("timeout_start должен быть в диапазоне (0, 10)")

if timeout_max <= 0 or timeout_max >= 10:
raise ValueError("timeout_max должен быть в диапазоне (0, 10)")

if backoff_scale <= 0 or backoff_scale >= 10:
raise ValueError("backoff_scale должен быть в диапазоне (0, 10)")

if not backoff_triggers:
raise ValueError("backoff_triggers не может быть пустым")

def decorator(func: Callable[P, R]) -> Callable[P, R]:
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
last_exception = None
current_timeout = timeout_start

for trying in range(retry_amount):
try:
return func(*args, **kwargs)
except Exception as e:
last_exception = e

should_retry = any(isinstance(e, trigger) for trigger in backoff_triggers)

if not should_retry or trying == retry_amount - 1:

raise last_exception

jitter = uniform(0, 0.5)
total_sleep_time = min(current_timeout + jitter, timeout_max)

sleep(total_sleep_time)

current_timeout = min(current_timeout * backoff_scale, timeout_max)

raise last_exception

return wrapper

return decorator
69 changes: 67 additions & 2 deletions homeworks/sem01/hw1/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,70 @@ def lru_cache(capacity: int) -> Callable[[Callable[P, R]], Callable[P, R]]:
для получения целого числа.
ValueError, если после округления capacity - число, меньшее 1.
"""
# ваш код
pass
try:
capacity = round(capacity)
except (TypeError, ValueError) as e:
raise TypeError

if capacity < 1:
raise ValueError

def decorator(func: Callable[P, R]) -> Callable[P, R]:
class Node:
def __init__(self, key, value):
self.key = key
self.value = value
self.prev = None
self.next = None

cache = {}
head = Node(None, None)
tail = Node(None, None)
head.next = tail
tail.prev = head

def remove_node(node: Node):
"""Удаляет узел из двусвязного списка"""
prev_node = node.prev
next_node = node.next
prev_node.next = next_node
next_node.prev = prev_node

def add_to_front(node: Node):
"""Добавляет узел в начало списка (после head)"""
first_node = head.next
head.next = node
node.prev = head
node.next = first_node
first_node.prev = node

def move_to_front(node: Node):
"""Перемещает узел в начало списка"""
remove_node(node)
add_to_front(node)

def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
key = (args, tuple(sorted(kwargs.items())))

if key in cache:
node = cache[key]
move_to_front(node)
return node.value
else:
result = func(*args, **kwargs)

new_node = Node(key, result)

if len(cache) >= capacity:
lru_node = tail.prev
remove_node(lru_node)
del cache[lru_node.key]

add_to_front(new_node)
cache[key] = new_node

return result

return wrapper

return decorator
16 changes: 14 additions & 2 deletions homeworks/sem01/hw1/convert_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,17 @@ def convert_exceptions_to_api_compitable_ones(
Декоратор для непосредственного использования.
"""

# ваш код
pass
def decorator(func: Callable[P, R]) -> Callable[P, R]:
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
try:
return func(*args, **kwargs)
except Exception as e:
for exception_type, api_exception in exception_to_api_exception.items():
if isinstance(e, exception_type):
raise api_exception()

raise

return wrapper

return decorator
Loading
Loading