Skip to content

Б12-514 Рябоконь Илья#189

Open
Fork3141592 wants to merge 17 commits into
EvgrafovMichail:mainfrom
Fork3141592:main
Open

Б12-514 Рябоконь Илья#189
Fork3141592 wants to merge 17 commits into
EvgrafovMichail:mainfrom
Fork3141592:main

Conversation

@Fork3141592
Copy link
Copy Markdown

Исправление недочётов

@Fork3141592
Copy link
Copy Markdown
Author

Прошу также обратить внимание, что этот commit из ветки main, а первый commit по этому заданию был сделан с ветки work_place (ещё до 12, там просто всё поломалось и пришлось на основной ветке всё исправлять)

@Avshugan Avshugan added the 514 label Mar 16, 2026
) -> np.ndarray:
# ваш код
return image
if kernel_size < 1 or kernel_size % 2 == 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Есть решение быстрее

window = padded_image[i : i + kernel_size, j : j + kernel_size]
result[i, j] = np.mean(window)

elif image.ndim == 3:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было без if, чтобы решение было проще


for i in range(height):
for j in range(width):
for k in range(channel):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было избавится от последнего for, просто указав axis у np.mean

raise ValueError("threshold must be positive")

return 0, 0
pixels = image.flatten()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Есть np.unique, которая быстрее


return 0, 0
pixels = image.flatten()
zeros = np.zeros(256, dtype=np.int64)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше было бы 256 вынести в константу, чтобы было сразу понятно, что вы имеете ввиду количество цветов, и еще вы несколько раз используетее это число

raise ShapeMismatchError

det = np.linalg.det(matrix)
if det == 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Во-первых, как вы можете помнить из первого семестра, делать == между 2 числами float - это не правильно.
Во-вторых, использование детерменанта для определения сингулярности матрицы - это ошибка, так как при вычислении детерменанта из-за компьютерных ошибок вы можете получить любое число.

I_K = np.eye(K)
revers_bracket = I_K + composition

if np.linalg.det(revers_bracket) == 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ошибка описана выше

) -> bool:
M, N = costs.shape

if costs.ndim != 2 or len(resource_amounts) != M or len(demand_expected) != N:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вместо len лучше использовать .shape, все-таки мы в numpy


resources_needed = costs @ demand_expected

if np.any(resources_needed > resource_amounts):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему не так?!

return not np.any(resources_needed > resource_amounts):

) -> None:
# ваш код
pass
if abscissa.shape != ordinates.shape:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Слишком большая функция получилась, тяжело читать код. Так еще и много повторяющегося кода

import numpy as np


def visualize_mitral_regurgitation(json_path: str = "medic_data.json") -> None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Слишком большая функция получилась, тяжело читать код.

from matplotlib.animation import FuncAnimation


def animate_wave_algorithm(
Copy link
Copy Markdown
Collaborator

@Avshugan Avshugan May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не дождался результата для большого лабиринта

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лично у меня лабиринт считался 1.5 минуты, после чего создавался gif-файл. Отрисовывался дольше, т.к. 2 кадра в секунду.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я ждал 2 минуты на оба лабиринта (вместе запускал)

from matplotlib.animation import FuncAnimation


def animate_wave_algorithm(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функции в 90 строк кода усложняют его понимание, лучше делить такие функции на несколько поменьше

from matplotlib.animation import FuncAnimation


def animate_wave_algorithm(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Объединять вычисления и отрисовку в одной функции не стоит

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants