Skip to content

Commit

Permalink
Merge pull request #2110 from pupil-labs/black-check
Browse files Browse the repository at this point in the history
Add GH Action to check black formatting
  • Loading branch information
papr authored Mar 9, 2021
2 parents 7eb0673 + 6d7ea43 commit b8b8010
Show file tree
Hide file tree
Showing 14 changed files with 382 additions and 230 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/black-check.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
12 changes: 0 additions & 12 deletions conftest.py

This file was deleted.

2 changes: 2 additions & 0 deletions deployment/find_opengl_bigsur.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
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":
return "/System/Library/Frameworks/OpenGL.framework/OpenGL"
else:
return _find_library_original(name)


ctypes.util.find_library = _find_library_patched

import OpenGL.GL
Expand Down
4 changes: 3 additions & 1 deletion pupil_src/launchables/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion pupil_src/tests/gaze_mapping/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 25 additions & 5 deletions pupil_src/tests/surface_tracker/fixtures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = [
Expand 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,
Expand Down
Loading

0 comments on commit b8b8010

Please sign in to comment.