-
Notifications
You must be signed in to change notification settings - Fork 2
433 aspect ratio check #756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
HadronCollider
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Подтяните изменения из ветки dev
- Новые критерии импортируются в модуле https://github.com/moevm/document_insight_system/blob/master/app/main/checks/presentation_checks/__init__.py (для презентаций в своём), чтобы они могли быть использованы в системе - сейчас в запущенной системе к ним нет доступа и они не используются (= не могут быть запущены для документов)
- При нестандартных значениях возможен забавный результат (но проверка работает верно)
| description = "" | ||
| id = 'pres_aspect_ratio_check' | ||
|
|
||
| def __init__(self, file_info, correct_ratios=["4:3", "16:9"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вспомните про неизменяемость объектов и работу значений по умолчанию - к счастью, в коде значение correct_ratios никак не меняется, т.е. непредвиденных результатов не будет, но лучше изменить на кортеж или None (при этом подавать в конструктор могут и список)
| self.correct_ratios = [Ratio(*map(int, x.split(':'))) for x in correct_ratios] | ||
|
|
||
| def __is_correct_ratio(self, aspect_ratio: Ratio): | ||
| return any(aspect_ratio == ratio for ratio in self.correct_ratios) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Для проверки вхождения aspect_ratio в self.correct_ratios достаточно конструкции
in - При использовании множества (set) проверка вхождения будет быстрее (
O(1)), чем линейный поиск в списке (O(n))

Задача #433