Skip to content

Б12-514, Баринов Михаил#173

Open
dmemsm wants to merge 11 commits into
EvgrafovMichail:mainfrom
dmemsm:main
Open

Б12-514, Баринов Михаил#173
dmemsm wants to merge 11 commits into
EvgrafovMichail:mainfrom
dmemsm:main

Conversation

@dmemsm
Copy link
Copy Markdown

@dmemsm dmemsm commented Mar 6, 2026

No description provided.

@Avshugan Avshugan added the 514 label Mar 9, 2026
return 0, 0
pixels = image.flatten()
counts = np.zeros(256)
for 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.

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

counts[color] = np.sum(pixels == color)

result_color, result_count = 0, 0
for 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 вынести в константу, чтобы было сразу понятно, что вы имеете ввиду количество цветов, и еще вы далее используете 255, что является производной от этого числа

if matrix.shape[0] != matrix.shape[1] or matrix.shape[0] != vector.shape[0]:
raise ShapeMismatchError

if np.linalg.det(matrix) == 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 - это неправильно.
Во-вторых, использование детерменанта для определения сингулярности матрицы - это ошибка, так как при вычислении детерменанта из-за компьютерных ошибок вы можете получить любое число.

from matplotlib.animation import FuncAnimation


def update_frame(
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