diff --git a/.github/workflows/black-check.yml b/.github/workflows/black-check.yml new file mode 100644 index 0000000000..a373eaea16 --- /dev/null +++ b/.github/workflows/black-check.yml @@ -0,0 +1,26 @@ +# This is a basic workflow to help you get started with Actions + +name: Black Check + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ master ] + pull_request: + branches: [ master, develop ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - name: Black Check + # You may pin to the exact commit or the version. + uses: jpetrucciani/black-check@20.8b1 diff --git a/conftest.py b/conftest.py deleted file mode 100644 index 4d06112def..0000000000 --- a/conftest.py +++ /dev/null @@ -1,12 +0,0 @@ -""" -(*)~--------------------------------------------------------------------------- -Pupil - eye tracking platform -Copyright (C) 2012-2021 Pupil Labs - -Distributed under the terms of the GNU -Lesser General Public License (LGPL v3.0). -See COPYING and COPYING.LESSER for license details. ----------------------------------------------------------------------------~(*) -""" - -pytest_plugins = "pytester" diff --git a/deployment/find_opengl_bigsur.py b/deployment/find_opengl_bigsur.py index cc9801ad40..6b0a09182e 100755 --- a/deployment/find_opengl_bigsur.py +++ b/deployment/find_opengl_bigsur.py @@ -15,6 +15,7 @@ print("Attempting to import OpenGL using patched `ctypes.util.find_library`...") _find_library_original = ctypes.util.find_library + @functools.wraps(_find_library_original) def _find_library_patched(name): if name == "OpenGL": @@ -22,6 +23,7 @@ def _find_library_patched(name): else: return _find_library_original(name) + ctypes.util.find_library = _find_library_patched import OpenGL.GL diff --git a/pupil_src/launchables/world.py b/pupil_src/launchables/world.py index e8223b1319..361de0e69b 100644 --- a/pupil_src/launchables/world.py +++ b/pupil_src/launchables/world.py @@ -703,7 +703,9 @@ def window_should_update(): return next(window_update_timer) # trigger setup of window and gl sizes - g_pool.trigger_main_window_redraw = lambda: on_resize(main_window, *glfw.get_framebuffer_size(main_window)) + g_pool.trigger_main_window_redraw = lambda: on_resize( + main_window, *glfw.get_framebuffer_size(main_window) + ) g_pool.trigger_main_window_redraw() if session_settings.get("eye1_process_alive", True): diff --git a/pupil_src/tests/gaze_mapping/test_notifications.py b/pupil_src/tests/gaze_mapping/test_notifications.py index 25faea4208..3d7fab0ca2 100644 --- a/pupil_src/tests/gaze_mapping/test_notifications.py +++ b/pupil_src/tests/gaze_mapping/test_notifications.py @@ -36,7 +36,10 @@ def test_success_notification_serialization(): _test_notification_serialization( cls=cls, - valid_samples=[serialized_sample_1, serialized_sample_2,], + valid_samples=[ + serialized_sample_1, + serialized_sample_2, + ], invalid_samples=[ { "subject": "calibration.successful.xyz", diff --git a/pupil_src/tests/surface_tracker/fixtures/__init__.py b/pupil_src/tests/surface_tracker/fixtures/__init__.py index ab92f5b3f5..4ff9fe0c4f 100644 --- a/pupil_src/tests/surface_tracker/fixtures/__init__.py +++ b/pupil_src/tests/surface_tracker/fixtures/__init__.py @@ -40,23 +40,43 @@ surface_marker_aggregates_deserialized as surface_marker_aggregates_deserialized_v01_square, ) + def surface_pairs_v01_mixed() -> typing.Collection[typing.Tuple[Surface, dict]]: return (*surface_pairs_v01_apriltag(), *surface_pairs_v01_square()) + def surfaces_serialized_v01_mixed() -> typing.Collection[dict]: return (*surfaces_serialized_v01_apriltag(), *surfaces_serialized_v01_square()) + def surfaces_deserialized_v01_mixed() -> typing.Collection[Surface]: return (*surfaces_deserialized_v01_apriltag(), *surfaces_deserialized_v01_square()) -def surface_marker_aggregate_pairs_v01_mixed() -> typing.Collection[typing.Tuple[Surface_Marker_Aggregate, dict]]: - return (*surface_marker_aggregate_pairs_v01_apriltag(), *surface_marker_aggregate_pairs_v01_square()) + +def surface_marker_aggregate_pairs_v01_mixed() -> typing.Collection[ + typing.Tuple[Surface_Marker_Aggregate, dict] +]: + return ( + *surface_marker_aggregate_pairs_v01_apriltag(), + *surface_marker_aggregate_pairs_v01_square(), + ) + def surface_marker_aggregates_serialized_v01_mixed() -> typing.Collection[dict]: - return (*surface_marker_aggregates_serialized_v01_apriltag(), *surface_marker_aggregates_serialized_v01_square()) + return ( + *surface_marker_aggregates_serialized_v01_apriltag(), + *surface_marker_aggregates_serialized_v01_square(), + ) + + +def surface_marker_aggregates_deserialized_v01_mixed() -> typing.Collection[ + Surface_Marker_Aggregate +]: + return ( + *surface_marker_aggregates_deserialized_v01_apriltag(), + *surface_marker_aggregates_deserialized_v01_square(), + ) -def surface_marker_aggregates_deserialized_v01_mixed() -> typing.Collection[Surface_Marker_Aggregate]: - return (*surface_marker_aggregates_deserialized_v01_apriltag(), *surface_marker_aggregates_deserialized_v01_square()) from .fixtures_surface_definition_files import ( surface_definition_v00_dir, diff --git a/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_definition_files.py b/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_definition_files.py index 0babbc5337..0b96040e2a 100644 --- a/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_definition_files.py +++ b/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_definition_files.py @@ -59,7 +59,9 @@ def surface_definition_v01_after_update_dir() -> str: ##### PRIVATE -def _create_dir_with_surface_definition_file(file_name: str, serialized_surfaces: typing.Collection[dict]) -> str: +def _create_dir_with_surface_definition_file( + file_name: str, serialized_surfaces: typing.Collection[dict] +) -> str: root_dir = os.path.join(tempfile.gettempdir(), str(uuid.uuid4())) file_path = os.path.join(root_dir, file_name) diff --git a/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v00_square.py b/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v00_square.py index b0b7273573..aeb116df00 100644 --- a/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v00_square.py +++ b/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v00_square.py @@ -15,7 +15,10 @@ from surface_tracker.surface import Surface from surface_tracker.surface_online import Surface_Online from surface_tracker.surface_offline import Surface_Offline -from surface_tracker.surface_marker_aggregate import Surface_Marker_Aggregate, Surface_Marker_UID +from surface_tracker.surface_marker_aggregate import ( + Surface_Marker_Aggregate, + Surface_Marker_UID, +) __all__ = [ @@ -29,125 +32,151 @@ def surface_pairs() -> typing.Collection[typing.Tuple[Surface, dict]]: - return ( - (SURFACE_V00_DESERIALIZED, SURFACE_V00_SERIALIZED), - ) + return ((SURFACE_V00_DESERIALIZED, SURFACE_V00_SERIALIZED),) + def surfaces_serialized() -> typing.Collection[dict]: return tuple(s for d, s in surface_pairs()) + def surfaces_deserialized() -> typing.Collection[Surface]: return tuple(d for d, s in surface_pairs()) -def surface_marker_aggregate_pairs() -> typing.Collection[typing.Tuple[Surface_Marker_Aggregate, dict]]: + +def surface_marker_aggregate_pairs() -> typing.Collection[ + typing.Tuple[Surface_Marker_Aggregate, dict] +]: return ( - (SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_0_DIST, SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_0_DIST), - (SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_1_DIST, SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_1_DIST), - (SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_0_UNDIST), - (SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_1_UNDIST, SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_1_UNDIST), + ( + SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_0_DIST, + SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_0_DIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_1_DIST, + SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_1_DIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_0_UNDIST, + SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_0_UNDIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_1_UNDIST, + SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_1_UNDIST, + ), ) + def surface_marker_aggregates_serialized() -> typing.Collection[dict]: return tuple(s for d, s in surface_marker_aggregate_pairs()) -def surface_marker_aggregates_deserialized() -> typing.Collection[Surface_Marker_Aggregate]: - return tuple(d for d, s in surface_marker_aggregate_pairs()) +def surface_marker_aggregates_deserialized() -> typing.Collection[ + Surface_Marker_Aggregate +]: + return tuple(d for d, s in surface_marker_aggregate_pairs()) ##### PRIVATE SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_0_UNDIST = { - 'id': 7, - 'verts_uv': [ - [2.0279725503600556e-14, -2.0718593602363743e-14], - [0.09232430905103683, 0.0054827057756483555], - [0.09320462495088577, 0.07479614019393921], - [0.008808332495391369, 0.07134716212749481] - ] + "id": 7, + "verts_uv": [ + [2.0279725503600556e-14, -2.0718593602363743e-14], + [0.09232430905103683, 0.0054827057756483555], + [0.09320462495088577, 0.07479614019393921], + [0.008808332495391369, 0.07134716212749481], + ], } SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_1_UNDIST = { - 'id': 57, - 'verts_uv': [ - [0.9255635738372803, 0.9278208017349243], - [0.9941799640655518, 0.928483784198761], - [0.9941900372505188, 0.9999602437019348], - [0.9251440763473511, 0.998592734336853] - ] + "id": 57, + "verts_uv": [ + [0.9255635738372803, 0.9278208017349243], + [0.9941799640655518, 0.928483784198761], + [0.9941900372505188, 0.9999602437019348], + [0.9251440763473511, 0.998592734336853], + ], } SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_0_DIST = { - 'id': 7, - 'verts_uv': [ - [1.9851928125457982e-14, -1.923472062778219e-14], - [0.060702838003635406, -0.004638743586838245], - [0.05217646434903145, 0.06511983275413513], - [-0.009258653968572617, 0.06691507995128632] - ] + "id": 7, + "verts_uv": [ + [1.9851928125457982e-14, -1.923472062778219e-14], + [0.060702838003635406, -0.004638743586838245], + [0.05217646434903145, 0.06511983275413513], + [-0.009258653968572617, 0.06691507995128632], + ], } SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_1_DIST = { - 'id': 57, - 'verts_uv': [ - [0.9114755799300843, 0.9409661768393776], - [0.9818958957355025, 0.9379570537747127], - [0.9800677671918846, 1.005555440640987], - [0.909855488690773, 1.0082552654603305] - ] + "id": 57, + "verts_uv": [ + [0.9114755799300843, 0.9409661768393776], + [0.9818958957355025, 0.9379570537747127], + [0.9800677671918846, 1.005555440640987], + [0.909855488690773, 1.0082552654603305], + ], } SURFACE_V00_SERIALIZED = { - 'name': 'surface_v00', - 'real_world_size': {'x': 1.0, 'y': 1.0}, - 'reg_markers': [ + "name": "surface_v00", + "real_world_size": {"x": 1.0, "y": 1.0}, + "reg_markers": [ SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_1_UNDIST, ], - 'registered_markers_dist': [ + "registered_markers_dist": [ SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_0_DIST, SURFACE_MARKER_AGGREGATE_V00_SERIALIZED_1_DIST, ], - 'build_up_status': 1.0, - 'deprecated': False + "build_up_status": 1.0, + "deprecated": False, } SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_0_UNDIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("legacy:7"), - verts_uv=np.asarray([ - [2.0279725503600556e-14, -2.0718593602363743e-14], - [0.09232430905103683, 0.0054827057756483555], - [0.09320462495088577, 0.07479614019393921], - [0.008808332495391369, 0.07134716212749481] - ]) + verts_uv=np.asarray( + [ + [2.0279725503600556e-14, -2.0718593602363743e-14], + [0.09232430905103683, 0.0054827057756483555], + [0.09320462495088577, 0.07479614019393921], + [0.008808332495391369, 0.07134716212749481], + ] + ), ) SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_1_UNDIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("legacy:57"), - verts_uv=np.asarray([ - [0.9255635738372803, 0.9278208017349243], - [0.9941799640655518, 0.928483784198761], - [0.9941900372505188, 0.9999602437019348], - [0.9251440763473511, 0.998592734336853] - ]) + verts_uv=np.asarray( + [ + [0.9255635738372803, 0.9278208017349243], + [0.9941799640655518, 0.928483784198761], + [0.9941900372505188, 0.9999602437019348], + [0.9251440763473511, 0.998592734336853], + ] + ), ) SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_0_DIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("legacy:7"), - verts_uv=np.asarray([ - [1.9851928125457982e-14, -1.923472062778219e-14], - [0.060702838003635406, -0.004638743586838245], - [0.05217646434903145, 0.06511983275413513], - [-0.009258653968572617, 0.06691507995128632] - ]) + verts_uv=np.asarray( + [ + [1.9851928125457982e-14, -1.923472062778219e-14], + [0.060702838003635406, -0.004638743586838245], + [0.05217646434903145, 0.06511983275413513], + [-0.009258653968572617, 0.06691507995128632], + ] + ), ) SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_1_DIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("legacy:57"), - verts_uv=np.asarray([ - [0.9114755799300843, 0.9409661768393776], - [0.9818958957355025, 0.9379570537747127], - [0.9800677671918846, 1.005555440640987], - [0.909855488690773, 1.0082552654603305] - ]) + verts_uv=np.asarray( + [ + [0.9114755799300843, 0.9409661768393776], + [0.9818958957355025, 0.9379570537747127], + [0.9800677671918846, 1.005555440640987], + [0.909855488690773, 1.0082552654603305], + ] + ), ) SURFACE_V00_DESERIALIZED = Surface_Offline( name="surface_v00", - real_world_size={'x': 1.0, 'y': 1.0}, + real_world_size={"x": 1.0, "y": 1.0}, marker_aggregates_undist=[ SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V00_DESERIALIZED_1_UNDIST, diff --git a/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v01_apriltag.py b/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v01_apriltag.py index ebd0f9a724..89d017f172 100644 --- a/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v01_apriltag.py +++ b/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v01_apriltag.py @@ -15,7 +15,10 @@ from surface_tracker.surface import Surface from surface_tracker.surface_online import Surface_Online from surface_tracker.surface_offline import Surface_Offline -from surface_tracker.surface_marker_aggregate import Surface_Marker_Aggregate, Surface_Marker_UID +from surface_tracker.surface_marker_aggregate import ( + Surface_Marker_Aggregate, + Surface_Marker_UID, +) __all__ = [ @@ -29,29 +32,47 @@ def surface_pairs() -> typing.Collection[typing.Tuple[Surface, dict]]: - return ( - (SURFACE_V01_APRILTAG_DESERIALIZED, SURFACE_V01_APRILTAG_SERIALIZED), - ) + return ((SURFACE_V01_APRILTAG_DESERIALIZED, SURFACE_V01_APRILTAG_SERIALIZED),) + def surfaces_serialized() -> typing.Collection[dict]: return tuple(s for d, s in surface_pairs()) + def surfaces_deserialized() -> typing.Collection[Surface]: return tuple(d for d, s in surface_pairs()) -def surface_marker_aggregate_pairs() -> typing.Collection[typing.Tuple[Surface_Marker_Aggregate, dict]]: +def surface_marker_aggregate_pairs() -> typing.Collection[ + typing.Tuple[Surface_Marker_Aggregate, dict] +]: return ( - (SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_0_DIST, SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_0_DIST), - (SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_1_DIST, SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_1_DIST), - (SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_0_UNDIST), - (SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_1_UNDIST, SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_1_UNDIST), + ( + SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_0_DIST, + SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_0_DIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_1_DIST, + SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_1_DIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_0_UNDIST, + SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_0_UNDIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_1_UNDIST, + SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_1_UNDIST, + ), ) + def surface_marker_aggregates_serialized() -> typing.Collection[dict]: return tuple(s for d, s in surface_marker_aggregate_pairs()) -def surface_marker_aggregates_deserialized() -> typing.Collection[Surface_Marker_Aggregate]: + +def surface_marker_aggregates_deserialized() -> typing.Collection[ + Surface_Marker_Aggregate +]: return tuple(d for d, s in surface_marker_aggregate_pairs()) @@ -59,96 +80,104 @@ def surface_marker_aggregates_deserialized() -> typing.Collection[Surface_Marker SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_0_UNDIST = { - 'uid': 'apriltag_v3:tag36h11:72', - 'verts_uv': [ + "uid": "apriltag_v3:tag36h11:72", + "verts_uv": [ [0.9084336161613464, 0.9975847005844116], [0.908658504486084, 0.8936676979064941], [1.000919222831726, 0.8954850435256958], - [1.0, 1.0] - ] + [1.0, 1.0], + ], } SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_1_UNDIST = { - 'uid': 'apriltag_v3:tag36h11:8', - 'verts_uv': [ + "uid": "apriltag_v3:tag36h11:8", + "verts_uv": [ [0.008291917853057384, 0.12046175450086594], [0.0049503217451274395, 0.016743427142500877], [0.0993560180068016, 0.01397931668907404], - [0.09943299740552902, 0.11729079484939575] - ] + [0.09943299740552902, 0.11729079484939575], + ], } SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_0_DIST = { - 'uid': 'apriltag_v3:tag36h11:72', - 'verts_uv': [ + "uid": "apriltag_v3:tag36h11:72", + "verts_uv": [ [0.9030435085296631, 1.0059881210327148], [0.9017457962036133, 0.8991504907608032], [0.9998528361320496, 0.8934420347213745], - [1.0, 1.0] - ] + [1.0, 1.0], + ], } SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_1_DIST = { - 'uid': 'apriltag_v3:tag36h11:8', - 'verts_uv': [ + "uid": "apriltag_v3:tag36h11:8", + "verts_uv": [ [-0.01220057875846362, 0.11509560622293023], [0.0014339334968873486, 0.015284867423122411], [0.08342891010320912, 0.0064126273309583], - [0.07023519482627806, 0.10786793886342823] - ] + [0.07023519482627806, 0.10786793886342823], + ], } SURFACE_V01_APRILTAG_SERIALIZED = { - 'version': 1, - 'name': 'apriltag_surface_v01', - 'real_world_size': {'x': 1.0, 'y': 1.0}, - 'reg_markers': [ + "version": 1, + "name": "apriltag_surface_v01", + "real_world_size": {"x": 1.0, "y": 1.0}, + "reg_markers": [ SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_1_UNDIST, ], - 'registered_markers_dist': [ + "registered_markers_dist": [ SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_0_DIST, SURFACE_MARKER_AGGREGATE_V01_APRILTAG_SERIALIZED_1_DIST, ], - 'build_up_status': 1.0, - 'deprecated': False + "build_up_status": 1.0, + "deprecated": False, } SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_0_UNDIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("apriltag_v3:tag36h11:72"), - verts_uv=np.asarray([ - [0.9084336161613464, 0.9975847005844116], - [0.908658504486084, 0.8936676979064941], - [1.000919222831726, 0.8954850435256958], - [1.0, 1.0] - ]) + verts_uv=np.asarray( + [ + [0.9084336161613464, 0.9975847005844116], + [0.908658504486084, 0.8936676979064941], + [1.000919222831726, 0.8954850435256958], + [1.0, 1.0], + ] + ), ) SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_1_UNDIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("apriltag_v3:tag36h11:8"), - verts_uv=np.asarray([ - [0.008291917853057384, 0.12046175450086594], - [0.0049503217451274395, 0.016743427142500877], - [0.0993560180068016, 0.01397931668907404], - [0.09943299740552902, 0.11729079484939575] - ]) + verts_uv=np.asarray( + [ + [0.008291917853057384, 0.12046175450086594], + [0.0049503217451274395, 0.016743427142500877], + [0.0993560180068016, 0.01397931668907404], + [0.09943299740552902, 0.11729079484939575], + ] + ), ) SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_0_DIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("apriltag_v3:tag36h11:72"), - verts_uv=np.asarray([ - [0.9030435085296631, 1.0059881210327148], - [0.9017457962036133, 0.8991504907608032], - [0.9998528361320496, 0.8934420347213745], - [1.0, 1.0] - ]) + verts_uv=np.asarray( + [ + [0.9030435085296631, 1.0059881210327148], + [0.9017457962036133, 0.8991504907608032], + [0.9998528361320496, 0.8934420347213745], + [1.0, 1.0], + ] + ), ) SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_1_DIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("apriltag_v3:tag36h11:8"), - verts_uv=np.asarray([ - [-0.01220057875846362, 0.11509560622293023], - [0.0014339334968873486, 0.015284867423122411], - [0.08342891010320912, 0.0064126273309583], - [0.07023519482627806, 0.10786793886342823] - ]) + verts_uv=np.asarray( + [ + [-0.01220057875846362, 0.11509560622293023], + [0.0014339334968873486, 0.015284867423122411], + [0.08342891010320912, 0.0064126273309583], + [0.07023519482627806, 0.10786793886342823], + ] + ), ) SURFACE_V01_APRILTAG_DESERIALIZED = Surface_Offline( name="apriltag_surface_v01", - real_world_size={'x': 1.0, 'y': 1.0}, + real_world_size={"x": 1.0, "y": 1.0}, marker_aggregates_undist=[ SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V01_APRILTAG_DESERIALIZED_1_UNDIST, diff --git a/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v01_square.py b/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v01_square.py index 949568af29..54a71f86eb 100644 --- a/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v01_square.py +++ b/pupil_src/tests/surface_tracker/fixtures/fixtures_surface_v01_square.py @@ -15,7 +15,10 @@ from surface_tracker.surface import Surface from surface_tracker.surface_online import Surface_Online from surface_tracker.surface_offline import Surface_Offline -from surface_tracker.surface_marker_aggregate import Surface_Marker_Aggregate, Surface_Marker_UID +from surface_tracker.surface_marker_aggregate import ( + Surface_Marker_Aggregate, + Surface_Marker_UID, +) __all__ = [ @@ -29,125 +32,151 @@ def surface_pairs() -> typing.Collection[typing.Tuple[Surface, dict]]: - return ( - (SURFACE_V01_SQUARE_DESERIALIZED, SURFACE_V01_SQUARE_SERIALIZED), - ) + return ((SURFACE_V01_SQUARE_DESERIALIZED, SURFACE_V01_SQUARE_SERIALIZED),) + def surfaces_serialized() -> typing.Collection[dict]: return tuple(s for d, s in surface_pairs()) + def surfaces_deserialized() -> typing.Collection[Surface]: return tuple(d for d, s in surface_pairs()) -def surface_marker_aggregate_pairs() -> typing.Collection[typing.Tuple[Surface_Marker_Aggregate, dict]]: +def surface_marker_aggregate_pairs() -> typing.Collection[ + typing.Tuple[Surface_Marker_Aggregate, dict] +]: return ( - (SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_0_DIST, SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_0_DIST), - (SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_1_DIST, SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_1_DIST), - (SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_0_UNDIST), - (SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_1_UNDIST, SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_1_UNDIST), + ( + SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_0_DIST, + SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_0_DIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_1_DIST, + SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_1_DIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_0_UNDIST, + SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_0_UNDIST, + ), + ( + SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_1_UNDIST, + SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_1_UNDIST, + ), ) + def surface_marker_aggregates_serialized() -> typing.Collection[dict]: return tuple(s for d, s in surface_marker_aggregate_pairs()) -def surface_marker_aggregates_deserialized() -> typing.Collection[Surface_Marker_Aggregate]: + +def surface_marker_aggregates_deserialized() -> typing.Collection[ + Surface_Marker_Aggregate +]: return tuple(d for d, s in surface_marker_aggregate_pairs()) ##### PRIVATE SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_0_UNDIST = { - 'uid': 'legacy:7', - 'verts_uv': [ + "uid": "legacy:7", + "verts_uv": [ [1.4891731985457006e-14, -1.675372893802235e-14], [0.07250381261110306, -0.000125938662677072], [0.07127536088228226, 0.06990551203489304], - [-0.00038871169090270996, 0.07084081321954727] - ] + [-0.00038871169090270996, 0.07084081321954727], + ], } SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_1_UNDIST = { - 'uid': 'legacy:57', - 'verts_uv': [ + "uid": "legacy:57", + "verts_uv": [ [0.9311530590057373, 0.9295246005058289], [1.000424861907959, 0.9302592873573303], [1.0, 1.0], - [0.9305340051651001, 0.9993915557861328] - ] + [0.9305340051651001, 0.9993915557861328], + ], } SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_0_DIST = { - 'uid': 'legacy:7', - 'verts_uv': [ + "uid": "legacy:7", + "verts_uv": [ [1.1920822368235908e-14, -1.7095567718611662e-14], [0.06276015192270279, -0.0030732755549252033], [0.0531853586435318, 0.06535717844963074], - [-0.010146145708858967, 0.06841480731964111] - ] + [-0.010146145708858967, 0.06841480731964111], + ], } SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_1_DIST = { - 'uid': 'legacy:57', - 'verts_uv': [ + "uid": "legacy:57", + "verts_uv": [ [0.9263750910758972, 0.9360179901123047], [0.9989929795265198, 0.9325454235076904], [1.0, 1.0], - [0.9276587963104248, 1.0039196014404297] - ] + [0.9276587963104248, 1.0039196014404297], + ], } SURFACE_V01_SQUARE_SERIALIZED = { - 'version': 1, - 'name': 'square_surface_v01', - 'real_world_size': {'x': 1.0, 'y': 1.0}, - 'reg_markers': [ + "version": 1, + "name": "square_surface_v01", + "real_world_size": {"x": 1.0, "y": 1.0}, + "reg_markers": [ SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_1_UNDIST, ], - 'registered_markers_dist': [ + "registered_markers_dist": [ SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_0_DIST, SURFACE_MARKER_AGGREGATE_V01_SQUARE_SERIALIZED_1_DIST, ], - 'build_up_status': 1.0, - 'deprecated': False + "build_up_status": 1.0, + "deprecated": False, } SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_0_UNDIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("legacy:7"), - verts_uv=np.asarray([ - [1.4891731985457006e-14, -1.675372893802235e-14], - [0.07250381261110306, -0.000125938662677072], - [0.07127536088228226, 0.06990551203489304], - [-0.00038871169090270996, 0.07084081321954727] - ]) + verts_uv=np.asarray( + [ + [1.4891731985457006e-14, -1.675372893802235e-14], + [0.07250381261110306, -0.000125938662677072], + [0.07127536088228226, 0.06990551203489304], + [-0.00038871169090270996, 0.07084081321954727], + ] + ), ) SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_1_UNDIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("legacy:57"), - verts_uv=np.asarray([ - [0.9311530590057373, 0.9295246005058289], - [1.000424861907959, 0.9302592873573303], - [1.0, 1.0], - [0.9305340051651001, 0.9993915557861328] - ]) + verts_uv=np.asarray( + [ + [0.9311530590057373, 0.9295246005058289], + [1.000424861907959, 0.9302592873573303], + [1.0, 1.0], + [0.9305340051651001, 0.9993915557861328], + ] + ), ) SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_0_DIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("legacy:7"), - verts_uv=np.asarray([ - [1.1920822368235908e-14, -1.7095567718611662e-14], - [0.06276015192270279, -0.0030732755549252033], - [0.0531853586435318, 0.06535717844963074], - [-0.010146145708858967, 0.06841480731964111] - ]) + verts_uv=np.asarray( + [ + [1.1920822368235908e-14, -1.7095567718611662e-14], + [0.06276015192270279, -0.0030732755549252033], + [0.0531853586435318, 0.06535717844963074], + [-0.010146145708858967, 0.06841480731964111], + ] + ), ) SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_1_DIST = Surface_Marker_Aggregate( uid=Surface_Marker_UID("legacy:57"), - verts_uv=np.asarray([ - [0.9263750910758972, 0.9360179901123047], - [0.9989929795265198, 0.9325454235076904], - [1.0, 1.0], - [0.9276587963104248, 1.0039196014404297] - ]) + verts_uv=np.asarray( + [ + [0.9263750910758972, 0.9360179901123047], + [0.9989929795265198, 0.9325454235076904], + [1.0, 1.0], + [0.9276587963104248, 1.0039196014404297], + ] + ), ) SURFACE_V01_SQUARE_DESERIALIZED = Surface_Offline( name="square_surface_v01", - real_world_size={'x': 1.0, 'y': 1.0}, + real_world_size={"x": 1.0, "y": 1.0}, marker_aggregates_undist=[ SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_0_UNDIST, SURFACE_MARKER_AGGREGATE_V01_SQUARE_DESERIALIZED_1_UNDIST, diff --git a/pupil_src/tests/surface_tracker/test_surface_marker.py b/pupil_src/tests/surface_tracker/test_surface_marker.py index b11fb7cdab..50c6cda8c1 100644 --- a/pupil_src/tests/surface_tracker/test_surface_marker.py +++ b/pupil_src/tests/surface_tracker/test_surface_marker.py @@ -12,9 +12,21 @@ import pytest import itertools -from surface_tracker.surface_marker import Surface_Marker, Surface_Marker_Type, Surface_Marker_TagID -from surface_tracker.surface_marker import create_surface_marker_uid, parse_surface_marker_type, parse_surface_marker_tag_id, parse_surface_marker_tag_family -from surface_tracker.surface_marker import _Apriltag_V3_Marker_Detection, _Square_Marker_Detection +from surface_tracker.surface_marker import ( + Surface_Marker, + Surface_Marker_Type, + Surface_Marker_TagID, +) +from surface_tracker.surface_marker import ( + create_surface_marker_uid, + parse_surface_marker_type, + parse_surface_marker_tag_id, + parse_surface_marker_tag_family, +) +from surface_tracker.surface_marker import ( + _Apriltag_V3_Marker_Detection, + _Square_Marker_Detection, +) def test_surface_marker_from_raw_detection(): diff --git a/pupil_src/tests/surface_tracker/test_surface_serializer.py b/pupil_src/tests/surface_tracker/test_surface_serializer.py index ecefa6d0c1..288e7dea67 100644 --- a/pupil_src/tests/surface_tracker/test_surface_serializer.py +++ b/pupil_src/tests/surface_tracker/test_surface_serializer.py @@ -23,7 +23,6 @@ surface_pairs_v00_square, surface_pairs_v01_apriltag, surface_pairs_v01_square, - surface_marker_aggregate_pairs_v00_square, surface_marker_aggregate_pairs_v01_apriltag, surface_marker_aggregate_pairs_v01_square, @@ -51,7 +50,9 @@ def _test_surface_serializer_with_surfaces(serializer, surface_pairs): assert Surface.property_equality(deserialization_result, deserialized_surface) -def _test_surface_serializer_with_surface_marker_aggregates(serializer, aggregate_pairs): +def _test_surface_serializer_with_surface_marker_aggregates( + serializer, aggregate_pairs +): assert isinstance(serializer, _Surface_Serializer_Base) assert len(aggregate_pairs) > 0 @@ -60,41 +61,42 @@ def _test_surface_serializer_with_surface_marker_aggregates(serializer, aggregat assert isinstance(deserialized_aggregate, Surface_Marker_Aggregate) assert isinstance(serialized_aggregate, dict) - serialization_result = serializer.dict_from_surface_marker_aggregate(deserialized_aggregate) + serialization_result = serializer.dict_from_surface_marker_aggregate( + deserialized_aggregate + ) assert serialization_result == serialized_aggregate - deserialization_result = serializer.surface_marker_aggregate_from_dict(serialized_aggregate) + deserialization_result = serializer.surface_marker_aggregate_from_dict( + serialized_aggregate + ) assert deserialization_result == deserialized_aggregate def test_surface_serializer_V00(): _test_surface_serializer_with_surfaces( - serializer=_Surface_Serializer_V00(), - surface_pairs=surface_pairs_v00_square() + serializer=_Surface_Serializer_V00(), surface_pairs=surface_pairs_v00_square() ) _test_surface_serializer_with_surface_marker_aggregates( serializer=_Surface_Serializer_V00(), - aggregate_pairs=surface_marker_aggregate_pairs_v00_square() + aggregate_pairs=surface_marker_aggregate_pairs_v00_square(), ) def test_surface_serializer_V01_square(): _test_surface_serializer_with_surfaces( - serializer=_Surface_Serializer_V01(), - surface_pairs=surface_pairs_v01_square() + serializer=_Surface_Serializer_V01(), surface_pairs=surface_pairs_v01_square() ) _test_surface_serializer_with_surface_marker_aggregates( serializer=_Surface_Serializer_V01(), - aggregate_pairs=surface_marker_aggregate_pairs_v01_square() + aggregate_pairs=surface_marker_aggregate_pairs_v01_square(), ) def test_surface_serializer_V01_apriltag(): _test_surface_serializer_with_surfaces( - serializer=_Surface_Serializer_V01(), - surface_pairs=surface_pairs_v01_apriltag() + serializer=_Surface_Serializer_V01(), surface_pairs=surface_pairs_v01_apriltag() ) _test_surface_serializer_with_surface_marker_aggregates( serializer=_Surface_Serializer_V01(), - aggregate_pairs=surface_marker_aggregate_pairs_v01_apriltag() + aggregate_pairs=surface_marker_aggregate_pairs_v01_apriltag(), ) diff --git a/pupil_src/tests/test_stdlib_utils.py b/pupil_src/tests/test_stdlib_utils.py index 34168103e3..5c5c691be9 100644 --- a/pupil_src/tests/test_stdlib_utils.py +++ b/pupil_src/tests/test_stdlib_utils.py @@ -21,7 +21,15 @@ def test_unique(): assert list(unique(arr, key=lambda _: 0)) == [1] assert list(unique(arr, key=lambda _: 0, select=lambda old, new: new)) == [0] - assert list(unique(arr, select=lambda old, new: old*10 + new)) == [11, 222, 3, 44, 5, 6, 0] + assert list(unique(arr, select=lambda old, new: old * 10 + new)) == [ + 11, + 222, + 3, + 44, + 5, + 6, + 0, + ] def test_operators(): @@ -29,7 +37,7 @@ def test_operators(): assert is_none(None) == True assert is_not_none(None) == False - things = [0, 5, [], [1,2,3], "", "abc"] + things = [0, 5, [], [1, 2, 3], "", "abc"] for thing in things: assert is_none(thing) == False diff --git a/pupil_src/tests/video_capture/common.py b/pupil_src/tests/video_capture/common.py index 16f370b8a4..96cca8785b 100644 --- a/pupil_src/tests/video_capture/common.py +++ b/pupil_src/tests/video_capture/common.py @@ -12,11 +12,11 @@ import os broken_data = os.path.join( - os.path.dirname( - os.path.abspath(__file__)), 'data/broken/eye0.mp4') + os.path.dirname(os.path.abspath(__file__)), "data/broken/eye0.mp4" +) multiple_data = os.path.join( - os.path.dirname( - os.path.abspath(__file__)), 'data/multiple/eye0.mp4') + os.path.dirname(os.path.abspath(__file__)), "data/multiple/eye0.mp4" +) single_data = os.path.join( - os.path.dirname( - os.path.abspath(__file__)), 'data/single/eye0.mp4') + os.path.dirname(os.path.abspath(__file__)), "data/single/eye0.mp4" +)