Skip to content

Massively sped up Flake tests #142

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

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@
color=always
max-line-length=120
; Auto generated
exclude=src/gen/
; Linebreak before binary operator
; Allow default value other than "..."
; Allow imports at the bottom of file
ignore=W503,Y015,E402
exclude=src/gen/, typings/cv2-stubs/__init__.pyi
ignore=
W503, ; Linebreak before binary operator
Y015, ; Allow default value other than "..."
E402, ; Allow imports at the bottom of file
Y026, ; Not using typing_extensions
per-file-ignores=
; allow ... on same line as def
; ???
; Docstrings in type stubs
; Function bodys contain other than just ... (eg: raise)
; Single quote docstrings
typings/cv2-stubs/__init__.pyi: Q000,N8, E704,E501, Y021,Y010,Q002

; Quotes
__init__.pyi:Q000
; Naming conventions can't be controlled for external libraries
__init__.pyi: Q000,N8
; PyQt methods
ignore-names=closeEvent,paintEvent,keyPressEvent,mousePressEvent,mouseMoveEvent,mouseReleaseEvent
; McCabe max-complexity is also taken care of by Pylint and doesn't fail teh build there
; McCabe max-complexity is also taken care of by Pylint and doesn't fail the build there
; So this is the hard limit
max-complexity=32
inline-quotes="
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
pip install -r "scripts/requirements.txt"
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py*')
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py')
Flake8:
runs-on: windows-latest
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dist/

# Dev settings
*.pkl
settings.toml
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
"python.linting.pylintCategorySeverity.refactor": "Warning",
"python.linting.flake8Enabled": true,
"python.linting.flake8CategorySeverity.E": "Warning",
// Pyflakes
"python.linting.flake8CategorySeverity.F": "Warning",
// PEP8 Naming convention
"python.linting.flake8CategorySeverity.N": "Warning",
// PYI
"python.linting.flake8CategorySeverity.Y": "Warning",
// PyRight obsoletes mypy
"python.linting.mypyEnabled": false,
// Is already wrapped by Flake8, prospector and pylama
Expand Down
25 changes: 13 additions & 12 deletions PyInstaller/hooks/hook-cv2.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# ------------------------------------------------------------------
# Copyright (c) 2020 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------
# https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-cv2.py
"""
Copyright (c) 2020 PyInstaller Development Team.

This file is distributed under the terms of the GNU General Public
License (version 2.0 or later).

The full license is available in LICENSE.GPL.txt, distributed with
this software.

SPDX-License-Identifier: GPL-2.0-or-later

https://github.com/pyinstaller/pyinstaller-hooks-contrib/blob/master/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-cv2.py
"""

from PyInstaller.utils.hooks import collect_dynamic_libs, collect_data_files

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ This program can be used to automatically start, split, and reset your preferred

### Comparison Method

- There are three comparison methods to choose from: L2 Norm, Histograms, and pHash.
- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (or pHash).
- L2 Norm: This method should be fine to use for most cases. it finds the difference between each pixel, squares it, and sums it over the entire image and takes the square root. This is very fast but is a problem if your image is high frequency. Any translational movement or rotation can cause similarity to be very different.
- Histograms: An explanation on Histograms comparison can be found [here](https://mpatacchiola.github.io/blog/2016/11/12/the-simplest-classifier-histogram-intersection.html). This is a great method to use if you are using several masked images.
- pHash: An explanation on pHash comparison can be found [here](http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html). It is highly recommended to NOT use pHash if you use masked images. It is very inaccurate.
- Perceptual Hash: An explanation on pHash comparison can be found [here](http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html). It is highly recommended to NOT use pHash if you use masked images. It is very inaccurate.

### Full Content Rendering

Expand Down Expand Up @@ -116,7 +116,6 @@ This program can be used to automatically start, split, and reset your preferred
- {d} dummy split image. When matched, it moves to the next image without hitting your split hotkey.
- {b} split when similarity goes below the threshold rather than above. When a split image filename has this flag, the split image similarity will go above the threshold, do nothing, and then split the next time the similarity goes below the threshold.
- {p} pause flag. When a split image filename has this flag, it will hit your pause hotkey rather than your split hokey.
- A pause flag and a dummy flag `{pd}` cannot be used together
- Filename examples:
- `001_SplitName_(0.9)_[10].png` is a split image with a threshold of 0.9 and a pause time of 10 seconds.
- `002_SplitName_(0.9)_[10]_{d}.png` is the second split image with a threshold of 0.9, pause time of 10, and is a dummy split.
Expand Down Expand Up @@ -156,9 +155,9 @@ Given these splits: 1 dummy, 2 normal, 3 dummy, 4 dummy, 5 normal, 6 normal.
In this situation you would have only 3 splits in LiveSplit/wsplit (even though there are 6 split images, only 3 are "real" splits). This basically results in 3 groups of splits: 1st split is images 1 and 2. 2nd split is images 3, 4 and 5. 3rd split is image 6.

- If you are in the 1st or 2nd image and press the skip key, it will end up on the 3rd image
- If you are in the 3rd, 4th or 5th image and press the undo key, it will end up on the 1st image
- If you are in the 3rd, 4th or 5th image and press the undo key, it will end up on the 2nd image
- If you are in the 3rd, 4th or 5th image and press the skip key, it will end up on the 6th image
- If you are in the 6th image and press the undo key, it will end up on the 3rd image
- If you are in the 6th image and press the undo key, it will end up on the 5th image

### Loop Split Images

Expand Down
23 changes: 16 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,26 @@ aggressive = 3
[tool.pyright]
pythonPlatform = "Windows"
typeCheckingMode = "strict"
# Extra strict
reportImplicitStringConcatenation="error"
reportCallInDefaultInitializer="error"
reportMissingSuperCall="none" # False positives on base classes
reportPropertyTypeMismatch="error"
reportUninitializedInstanceVariable="error"
reportUnnecessaryTypeIgnoreComment="error"
reportUnusedCallResult="none"
ignore = [
# Auto generated
"src/gen/",
# We expect stub files to be incomplete or contain useless statements as they're external
# We expect stub files to be incomplete or contain useless statements
"typings/",
]
reportMissingTypeStubs = "information"
# Type stubs may not be completable
reportMissingTypeStubs = "warning"
# False positives with TYPE_CHECKING
reportImportCycles = "information"
# PyQt .connect
reportFunctionMemberAccess = "information"
# False positives with PyQt .connect. pylint(no-member) works instead
reportFunctionMemberAccess = "none"
# Extra runtime safety
reportUnnecessaryComparison = "warning"
# Flake8 does a better job
Expand All @@ -37,7 +46,7 @@ reportUnknownMemberType = "none"
# https://pylint.pycqa.org/en/latest/technical_reference/features.html
[tool.pylint.REPORTS]
# Just like default but any error will make drop to 9 or less
evaluation = "10.0 - error - ((float(warning * 10 + refactor + convention) / statement) * 10)"
evaluation = "10.0 - error - ((float((warning + convention) * 10 + refactor ) / statement) * 10)"
[tool.pylint.MASTER]
fail-under = 9.0
# https://pylint.pycqa.org/en/latest/technical_reference/extensions.html
Expand Down Expand Up @@ -68,8 +77,8 @@ load-plugins = [
ignore-paths = [
# Auto generated
"^src/gen/.*$",
# We expect stub files to be incomplete or contain useless statements as they're external
"^typings/.*$",
# We expect stub files to be incomplete or contain useless statements
"^.*\\.pyi$",
]
# No need to mention the fixmes
disable = ["fixme"]
Expand Down
61 changes: 41 additions & 20 deletions res/design.ui
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>main_window</class>
<widget class="QMainWindow" name="main_window">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
Expand Down Expand Up @@ -37,7 +37,7 @@
<string>AutoSplit</string>
</property>
<property name="windowIcon">
<iconset resource="../../Auto-Split/res/resources.qrc">
<iconset resource="resources.qrc">
<normaloff>:/resources/icon.ico</normaloff>:/resources/icon.ico</iconset>
</property>
<property name="whatsThis">
Expand Down Expand Up @@ -93,6 +93,9 @@
</property>
</widget>
<widget class="QPushButton" name="reset_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>650</x>
Expand All @@ -108,7 +111,10 @@
<string>Reset</string>
</property>
</widget>
<widget class="QPushButton" name="undo_button">
<widget class="QPushButton" name="undo_split_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>650</x>
Expand All @@ -124,7 +130,10 @@
<string>Undo</string>
</property>
</widget>
<widget class="QPushButton" name="skip_button">
<widget class="QPushButton" name="skip_split_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>712</x>
Expand Down Expand Up @@ -196,6 +205,9 @@
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="current_split_image">
<property name="geometry">
Expand All @@ -212,6 +224,9 @@
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="current_image_label">
<property name="geometry">
Expand Down Expand Up @@ -265,7 +280,7 @@
</rect>
</property>
<property name="text">
<string>9999</string>
<string/>
</property>
</widget>
<widget class="QSpinBox" name="width_spinbox">
Expand Down Expand Up @@ -332,7 +347,7 @@
</rect>
</property>
<property name="text">
<string>Image Filename</string>
<string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand Down Expand Up @@ -507,7 +522,7 @@
</rect>
</property>
<property name="text">
<string>Window Name</string>
<string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand All @@ -516,8 +531,8 @@
<widget class="QLabel" name="image_loop_label">
<property name="geometry">
<rect>
<x>450</x>
<y>309</y>
<x>451</x>
<y>313</y>
<width>67</width>
<height>20</height>
</rect>
Expand Down Expand Up @@ -796,8 +811,8 @@
<widget class="QLabel" name="start_image_status_label">
<property name="geometry">
<rect>
<x>450</x>
<y>345</y>
<x>449</x>
<y>344</y>
<width>98</width>
<height>16</height>
</rect>
Expand All @@ -809,8 +824,8 @@
<widget class="QLabel" name="start_image_status_value_label">
<property name="geometry">
<rect>
<x>551</x>
<y>345</y>
<x>550</x>
<y>344</y>
<width>98</width>
<height>16</height>
</rect>
Expand All @@ -822,17 +837,20 @@
<widget class="QLabel" name="image_loop_value_label">
<property name="geometry">
<rect>
<x>519</x>
<y>309</y>
<x>520</x>
<y>313</y>
<width>131</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>x/x</string>
<string>N/A</string>
</property>
</widget>
<widget class="QPushButton" name="previous_image_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>449</x>
Expand All @@ -852,6 +870,9 @@
</property>
</widget>
<widget class="QPushButton" name="next_image_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>744</x>
Expand All @@ -874,8 +895,8 @@
<zorder>select_region_button</zorder>
<zorder>start_auto_splitter_button</zorder>
<zorder>reset_button</zorder>
<zorder>undo_button</zorder>
<zorder>skip_button</zorder>
<zorder>undo_split_button</zorder>
<zorder>skip_split_button</zorder>
<zorder>check_fps_button</zorder>
<zorder>fps_label</zorder>
<zorder>current_image_label</zorder>
Expand Down Expand Up @@ -1027,7 +1048,7 @@
<tabstop>height_spinbox</tabstop>
</tabstops>
<resources>
<include location="../../Auto-Split/res/resources.qrc"/>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>
Loading