Б12-514 , Косицына Таисия#137
Conversation
| ) -> np.ndarray: | ||
| # ваш код | ||
| return image | ||
| if kernel_size % 2 == 0 or kernel_size < 1: |
| for b in range(j): | ||
| result[a, b] = np.mean(newimage[a : a + kernel_size, b : b + kernel_size]) | ||
|
|
||
| else: |
There was a problem hiding this comment.
Можно было без if, так код был бы проще
| vector: np.ndarray, | ||
| ) -> tuple[np.ndarray | None, np.ndarray | None]: ... | ||
| ) -> tuple[np.ndarray | None, np.ndarray | None]: | ||
| i, j = matrix.shape |
There was a problem hiding this comment.
i, j чаще используются для индексов. Для размеров обычно используются n, m, rows, cols, size и т.д.
| ) -> np.ndarray: ... | ||
| ) -> np.ndarray: | ||
| m = Vs.shape[0] | ||
| p, k = Vj.shape |
There was a problem hiding this comment.
Когда так моного одно буквенных переменных, то становится сложно понимать код, лучше тогда использовать Vj_rows, Vj_cols или что-то подобное, чтобы было понятно, что размеры именно для Vj
| needs = costs @ demand_expected | ||
|
|
||
| mask = needs > resource_amounts | ||
| if np.any(mask): |
There was a problem hiding this comment.
А почему не так?!
return not np.any(mask)| ) -> None: | ||
| # ваш код | ||
| pass | ||
| if abscissa.shape != ordinates.shape: |
There was a problem hiding this comment.
Функции в 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"') |
There was a problem hiding this comment.
А зачем вычитать четвертое? Это не надо было делать
| 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"') |
There was a problem hiding this comment.
Ну такой повторяющийся код лучше было бы делать в цикле
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
|
|
||
| before = [0]*4 |
There was a problem hiding this comment.
Лучше было бы вынести код в фукнцию
| 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() |
There was a problem hiding this comment.
В билиотеке json есть функции для парсинга файлов .json
|
|
||
| if modulation is None: | ||
| return f | ||
| else: |
| from matplotlib.animation import FuncAnimation | ||
|
|
||
|
|
||
| def animate_wave_algorithm( |
There was a problem hiding this comment.
Не работает с большим лабиринтом
| { | ||
| "cell_type": "markdown", | ||
| "id": "828e423a", | ||
| "cell_type": "code", |
There was a problem hiding this comment.
В части 2 можно было использовать аргумент inplace=True
| { | ||
| "cell_type": "markdown", | ||
| "id": "828e423a", | ||
| "cell_type": "code", |
There was a problem hiding this comment.
В части 3, как будто можно было сделать циклом и код был бы проще и не было столько повторений одного и того же кода
| { | ||
| "cell_type": "markdown", | ||
| "id": "828e423a", | ||
| "cell_type": "code", |
There was a problem hiding this comment.
В части 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", |
| "metadata": {}, | ||
| "source": [ | ||
| "Какие выводы вы можете сделать о выживших пассажирах Титаника? " | ||
| "Вывод: все выжившие пассажиры Титаника в итоге умерли. Статистика бессильна, от судьбы не уплывёшь (даже на двери). Как в пункте назначения." |
There was a problem hiding this comment.
Жаль конечно этих добряков. :(
No description provided.