Skip to content

Б12-514 Макаров Матвей#172

Open
korolinakila wants to merge 33 commits into
EvgrafovMichail:mainfrom
korolinakila:main
Open

Б12-514 Макаров Матвей#172
korolinakila wants to merge 33 commits into
EvgrafovMichail:mainfrom
korolinakila:main

Conversation

@korolinakila
Copy link
Copy Markdown

No description provided.

@Avshugan Avshugan added the 514 label Mar 9, 2026
azimuth = np.arctan2(ordinates, abscissa)
inclination = np.arccos(applicates / distances)

return tuple(distances, azimuth, inclination) No newline at end of file
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.

У меня не работает, если у вас иначе покажите после семинара

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

Не проходит ruff format

@@ -6,14 +6,24 @@ class ShapeMismatchError(Exception):


def convert_from_sphere(
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.

Не проходит ruff format

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
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.where нельзя было использовать

def pad_image(image: np.ndarray, pad_size: int) -> np.ndarray:
# ваш код
return image
if pad_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.

Не проходит тесты

raise ValueError("threshold must be positive")

return 0, 0
counts = 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.

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

max_pixels = 0
best_color = 0

for current_color in range(256):
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 вынести в константу, чтобы было сразу понятно, что вы имеете ввиду количество цветов, и еще вы несколько раз используетее это число

return (None, None)

ort_proj, ort_cond = [], []
for base in matrix:
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.

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

raise ShapeMismatchError

required_resources = costs @ demand_expected
for i in range(len(required_resources)):
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.all

raise ShapeMismatchError

det = np.linalg.det(matrix)
if abs(det) < 1e-10:
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.

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

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

) -> None:
# ваш код
pass
if abscissa.shape[0] != ordinates.shape[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.

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


def get_counts(tier_list, stages_list):
arr = np.array(tier_list)
return np.array([np.sum(arr == stage) for stage in stages_list])
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.

Почему бы не использовать 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:
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 base_signal
return modulation(t) * base_signal

figure, axis = plt.subplots(figsize=(12, 6))
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.

Сложно читать татие большие блоки кода

"id": "d7b00711",
"metadata": {},
"outputs": [],
"outputs": [
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, как будто можно было сделать циклом и код был бы проще и не было столько повторений одного и того же кода

"id": "d7b00711",
"metadata": {},
"outputs": [],
"outputs": [
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 и 9 уж слишком длинные строки, лучше все-таки ограничится 4-5 операциями в строку (ну или меньше)

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