Б12-514 Макаров Матвей#172
Conversation
| azimuth = np.arctan2(ordinates, abscissa) | ||
| inclination = np.arccos(applicates / distances) | ||
|
|
||
| return tuple(distances, azimuth, inclination) No newline at end of file |
There was a problem hiding this comment.
У меня не работает, если у вас иначе покажите после семинара
| ordinates: np.ndarray, | ||
| applicates: np.ndarray, | ||
| ) -> tuple[np.ndarray, np.ndarray, np.ndarray]: ... | ||
| def convert_to_sphere(abscissa: np.ndarray, ordinates: np.ndarray, applicates: np.ndarray, |
| @@ -6,14 +6,24 @@ class ShapeMismatchError(Exception): | |||
|
|
|||
|
|
|||
| def convert_from_sphere( | |||
| maximum = (ordinates[1:-1] > ordinates[:-2]) & (ordinates[1:-1] > ordinates[2:]) | ||
| minimum = (ordinates[1:-1] < ordinates[:-2]) & (ordinates[1:-1] < ordinates[2:]) | ||
|
|
||
| maxima_inds = np.where(maximum)[0] + 1 |
There was a problem hiding this comment.
np.where нельзя было использовать
| def pad_image(image: np.ndarray, pad_size: int) -> np.ndarray: | ||
| # ваш код | ||
| return image | ||
| if pad_size < 1: |
| raise ValueError("threshold must be positive") | ||
|
|
||
| return 0, 0 | ||
| counts = np.zeros(256, dtype=np.int64) |
There was a problem hiding this comment.
Есть np.unique, которая быстрее
| max_pixels = 0 | ||
| best_color = 0 | ||
|
|
||
| for current_color in range(256): |
There was a problem hiding this comment.
Лучше было бы 256 вынести в константу, чтобы было сразу понятно, что вы имеете ввиду количество цветов, и еще вы несколько раз используетее это число
| return (None, None) | ||
|
|
||
| ort_proj, ort_cond = [], [] | ||
| for base in matrix: |
| raise ShapeMismatchError | ||
|
|
||
| required_resources = costs @ demand_expected | ||
| for i in range(len(required_resources)): |
| raise ShapeMismatchError | ||
|
|
||
| det = np.linalg.det(matrix) | ||
| if abs(det) < 1e-10: |
There was a problem hiding this comment.
Использование детерменанта для определения сингулярности матрицы - это ошибка, так как при вычислении детерменанта из-за компьютерных ошибок вы можете получить любое число.
| demand_expected: np.ndarray, | ||
| ) -> bool: ... | ||
| def can_satisfy_demand(costs: np.ndarray,resource_amounts: np.ndarray,demand_expected: np.ndarray,) -> bool: | ||
| if costs.shape[0] != len(resource_amounts) or costs.shape[1] != len(demand_expected): |
There was a problem hiding this comment.
Зачем где-то len? Сделали бы все через .shape
| ) -> None: | ||
| # ваш код | ||
| pass | ||
| if abscissa.shape[0] != ordinates.shape[0]: |
There was a problem hiding this comment.
Слишком большая функция получилась, тяжело читать код. Так еще и много повторяющегося кода
|
|
||
| def get_counts(tier_list, stages_list): | ||
| arr = np.array(tier_list) | ||
| return np.array([np.sum(arr == stage) for stage in stages_list]) |
There was a problem hiding this comment.
Почему бы не использовать tier_list.count?
| ) -> FuncAnimation: | ||
| # ваш код | ||
| return FuncAnimation() | ||
| def create_modulation_animation(modulation, fc, num_frames, plot_duration, time_step=0.001, animation_step=0.01,save_path="") -> FuncAnimation: |
There was a problem hiding this comment.
Нет названия графика, легенды, подписей к осям
| return base_signal | ||
| return modulation(t) * base_signal | ||
|
|
||
| figure, axis = plt.subplots(figsize=(12, 6)) |
There was a problem hiding this comment.
Сложно читать татие большие блоки кода
| "id": "d7b00711", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "outputs": [ |
There was a problem hiding this comment.
В части 3, как будто можно было сделать циклом и код был бы проще и не было столько повторений одного и того же кода
| "id": "d7b00711", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "outputs": [ |
There was a problem hiding this comment.
В частах 3 и 9 уж слишком длинные строки, лучше все-таки ограничится 4-5 операциями в строку (ну или меньше)
No description provided.