Skip to content

Б12-514 , Косицына Таисия#137

Open
isan0tbella wants to merge 7 commits into
EvgrafovMichail:mainfrom
isan0tbella:hw
Open

Б12-514 , Косицына Таисия#137
isan0tbella wants to merge 7 commits into
EvgrafovMichail:mainfrom
isan0tbella:hw

Conversation

@isan0tbella
Copy link
Copy Markdown

No description provided.

@Avshugan Avshugan added the 514 label Mar 9, 2026
) -> np.ndarray:
# ваш код
return image
if kernel_size % 2 == 0 or kernel_size < 1:
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 b in range(j):
result[a, b] = np.mean(newimage[a : a + kernel_size, b : b + kernel_size])

else:
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, так код был бы проще

vector: np.ndarray,
) -> tuple[np.ndarray | None, np.ndarray | None]: ...
) -> tuple[np.ndarray | None, np.ndarray | None]:
i, j = matrix.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.

i, j чаще используются для индексов. Для размеров обычно используются n, m, rows, cols, size и т.д.

) -> np.ndarray: ...
) -> np.ndarray:
m = Vs.shape[0]
p, k = Vj.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.

Когда так моного одно буквенных переменных, то становится сложно понимать код, лучше тогда использовать Vj_rows, Vj_cols или что-то подобное, чтобы было понятно, что размеры именно для Vj

needs = costs @ demand_expected

mask = needs > resource_amounts
if np.any(mask):
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(mask)

) -> 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.

Функции в 120 строк кода лучше разделять на несколько функций, а то падает читаемость кода.
Так еще и много повторящегося кода.

before_part = content.split('"before"')[1].split('"after"')[0]
after_part = content.split('"after"')[1]

before[0] = before_part.count('"I"') - before_part.count('"IV"')
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.

А зачем вычитать четвертое? Это не надо было делать

before_part = content.split('"before"')[1].split('"after"')[0]
after_part = content.split('"after"')[1]

before[0] = before_part.count('"I"') - before_part.count('"IV"')
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 matplotlib.pyplot as plt
import numpy as np

before = [0]*4
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.

Лучше было бы вынести код в фукнцию

after = [0]*4
file_path = 'D:/GitHub/python_mipt_dafe_tasks/solutions/sem02/lesson07/data/medic_data.json'
with open(file_path, 'r') as file:
content = file.read()
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.

В билиотеке json есть функции для парсинга файлов .json


if modulation is None:
return f
else:
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.

else не нужен

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.

Не работает с большим лабиринтом

{
"cell_type": "markdown",
"id": "828e423a",
"cell_type": "code",
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 можно было использовать аргумент inplace=True

{
"cell_type": "markdown",
"id": "828e423a",
"cell_type": "code",
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.

В части 3, как будто можно было сделать циклом и код был бы проще и не было столько повторений одного и того же кода

{
"cell_type": "markdown",
"id": "828e423a",
"cell_type": "code",
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.

В части 7 можно было бы сделать

mask_survived = titanic_data["survived"] == 1
res = titanic_data.loc[mask_survived, "embark_town"].value_counts()

Так не пришлось бы отдельно брать для каждого пункта.
Еще как вариант: можно было бы взять уникальные значения пунктов и сделать по ним цикл.

{
"cell_type": "markdown",
"id": "828e423a",
"cell_type": "code",
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.

Аналогично 7

"metadata": {},
"source": [
"Какие выводы вы можете сделать о выживших пассажирах Титаника? "
"Вывод: все выжившие пассажиры Титаника в итоге умерли. Статистика бессильна, от судьбы не уплывёшь (даже на двери). Как в пункте назначения."
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