Skip to content

Commit

Permalink
Use colour checks configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 23, 2024
1 parent 06f40cd commit 50f3efd
Show file tree
Hide file tree
Showing 56 changed files with 724 additions and 558 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ sigterm = True
exclude_lines =
pragma: no cover
if __name__ == .__main__.:
if TYPE_CHECKING:
pass
13 changes: 8 additions & 5 deletions colour_hdri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import colour
import numpy as np
from colour.hints import Any
from colour.utilities import is_matplotlib_installed
from colour.utilities.deprecation import ModuleAPI, build_API_changes
from colour.utilities.documentation import is_documentation_building
Expand Down Expand Up @@ -160,6 +159,10 @@
NodeWriteImage,
NodeWritePreviewImage,
)
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from colour.hints import Any

# Exposing "colour.plotting" sub-package if "Matplotlib" is available.
if is_matplotlib_installed():
Expand All @@ -172,7 +175,7 @@ class MockPlotting: # pragma: no cover
if the sub-package is accessed but *Matplotlib* is not installed.
"""

def __getattr__(self, attribute) -> Any:
def __getattr__(self, attribute: str) -> Any:
"""Return the value from the attribute with given name."""

is_matplotlib_installed(raise_exception=True)
Expand Down Expand Up @@ -327,7 +330,7 @@ def __getattr__(self, attribute) -> Any:
__major_version__ = "0"
__minor_version__ = "2"
__change_version__ = "5"
__version__ = ".".join((__major_version__, __minor_version__, __change_version__))
__version__ = f"{__major_version__}.{__minor_version__}.{__change_version__}"

try:
_version: str = (
Expand All @@ -339,7 +342,7 @@ def __getattr__(self, attribute) -> Any:
.strip()
.decode("utf-8")
)
except Exception:
except Exception: # noqa: BLE001
_version: str = __version__

colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES["colour-hdri"] = _version # pyright: ignore
Expand Down Expand Up @@ -378,7 +381,7 @@ def __getattr__(self, attribute) -> Any:
class colour_hdri(ModuleAPI):
"""Define a class acting like the *colour_hdri* module."""

def __getattr__(self, attribute) -> Any:
def __getattr__(self, attribute: str) -> Any:
"""Return the value from the attribute with given name."""

return super().__getattr__(attribute)
Expand Down
7 changes: 6 additions & 1 deletion colour_hdri/calibration/absolute_luminance.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@

from __future__ import annotations

import typing

import numpy as np
from colour import RGB_COLOURSPACES, RGB_Colourspace, RGB_luminance
from colour.hints import ArrayLike, NDArrayFloat

if typing.TYPE_CHECKING:
from colour.hints import ArrayLike, NDArrayFloat

from colour.utilities import as_float_array

__author__ = "Colour Developers"
Expand Down
25 changes: 16 additions & 9 deletions colour_hdri/calibration/debevec1997.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,30 @@

from __future__ import annotations

import typing
from functools import partial

import numpy as np
from colour.hints import (
Any,
ArrayLike,
Callable,
Dict,
NDArrayFloat,
Tuple,
)

if typing.TYPE_CHECKING:
from colour.hints import (
Any,
ArrayLike,
Callable,
Dict,
NDArrayFloat,
Tuple,
)

from colour.utilities import as_float_array, as_int_array, tstack

from colour_hdri.exposure import average_luminance
from colour_hdri.generation import weighting_function_Debevec1997
from colour_hdri.sampling import samples_Grossberg2003
from colour_hdri.utilities import ImageStack

if typing.TYPE_CHECKING:
from colour_hdri.utilities import ImageStack


__author__ = "Colour Developers"
__copyright__ = "Copyright 2015 Colour Developers"
Expand Down
6 changes: 3 additions & 3 deletions colour_hdri/calibration/tests/test_absolute_luminance.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TestUpperHemisphereIlluminanceLagarde2016:
upper_hemisphere_illuminance_Lagarde2016` definition unit tests methods.
"""

def test_upper_hemisphere_illuminance_Lagarde2016(self):
def test_upper_hemisphere_illuminance_Lagarde2016(self) -> None:
"""
Test :func:`colour_hdri.calibration.absolute_luminance.\
upper_hemisphere_illuminance_Lagarde2016` definition.
Expand Down Expand Up @@ -78,7 +78,7 @@ class TestUpperHemisphereIlluminanceWeightsLagarde2016:
methods.
"""

def test_upper_hemisphere_illuminance_weights_Lagarde2016(self):
def test_upper_hemisphere_illuminance_weights_Lagarde2016(self) -> None:
"""
Test :func:`colour_hdri.calibration.absolute_luminance.\
upper_hemisphere_illuminance_weights_Lagarde2016` definition.
Expand Down Expand Up @@ -134,7 +134,7 @@ class TestAbsoluteLuminanceCalibrationLagarde2016:
absolute_luminance_calibration_Lagarde2016` definition unit tests methods.
"""

def test_absolute_luminance_calibration_Lagarde2016(self):
def test_absolute_luminance_calibration_Lagarde2016(self) -> None:
"""
Test :func:`colour_hdri.calibration.absolute_luminance.\
absolute_luminance_calibration_Lagarde2016` definition.
Expand Down
9 changes: 6 additions & 3 deletions colour_hdri/calibration/tests/test_debevec1997.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from __future__ import annotations

import os
from typing import TYPE_CHECKING

import numpy as np
from colour.hints import List

from colour_hdri import ROOT_RESOURCES_TESTS
from colour_hdri.calibration import (
Expand All @@ -19,6 +19,9 @@
from colour_hdri.sampling import samples_Grossberg2003
from colour_hdri.utilities import ImageStack, filter_files

if TYPE_CHECKING:
from colour.hints import List

__author__ = "Colour Developers"
__copyright__ = "Copyright 2015 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
Expand Down Expand Up @@ -49,7 +52,7 @@ class TestGSolve:
unit tests methods.
"""

def test_g_solve(self):
def test_g_solve(self) -> None:
"""Test :func:`colour_hdri.calibration.debevec1997.g_solve` definition."""

image_stack = ImageStack.from_files(IMAGES_JPG)
Expand Down Expand Up @@ -91,7 +94,7 @@ class TestCameraResponseFunctionsDebevec1997:
camera_response_functions_Debevec1997` definition unit tests methods.
"""

def test_camera_response_function_Debevec1997(self):
def test_camera_response_function_Debevec1997(self) -> None:
"""
Test :func:`colour_hdri.calibration.debevec1997.\
camera_response_functions_Debevec1997` definition.
Expand Down
24 changes: 12 additions & 12 deletions colour_hdri/distortion/tests/test_vignette.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TestApplyRadialGradient:
definition unit tests methods.
"""

def test_apply_radial_gradient(self):
def test_apply_radial_gradient(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.apply_radial_gradient`
definition.
Expand Down Expand Up @@ -126,7 +126,7 @@ class TestParabolic2DFunction:
definition unit tests methods.
"""

def test_parabolic_2D_function(self):
def test_parabolic_2D_function(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.parabolic_2D_function`
definition.
Expand Down Expand Up @@ -198,7 +198,7 @@ class TestHyperbolicCosine2DFunction:
definition unit tests methods.
"""

def test_hyperbolic_cosine_2D_function(self):
def test_hyperbolic_cosine_2D_function(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.hyperbolic_cosine_2D_function`
definition.
Expand Down Expand Up @@ -270,7 +270,7 @@ class TestVignettePrincipalPoint:
definition unit tests methods.
"""

def test_vignette_principal_point(self):
def test_vignette_principal_point(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.vignette_principal_point`
definition.
Expand All @@ -289,7 +289,7 @@ class TestCharacteriseVignette2DFunction:
characterise_vignette_2D_function` definition unit tests methods.
"""

def test_characterise_vignette_2D_function(self):
def test_characterise_vignette_2D_function(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.\
characterise_vignette_2D_function` definition.
Expand Down Expand Up @@ -382,7 +382,7 @@ class TestCorrectVignette2DFunction:
definition unit tests methods.
"""

def test_correct_vignette_2D_function(self):
def test_correct_vignette_2D_function(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.correct_vignette_2D_function`
definition.
Expand Down Expand Up @@ -512,7 +512,7 @@ class TestCharacteriseVignetteBivariateSpline:
characterise_vignette_bivariate_spline` definition unit tests methods.
"""

def test_characterise_vignette_bivariate_spline(self):
def test_characterise_vignette_bivariate_spline(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.\
characterise_vignette_bivariate_spline` definition.
Expand Down Expand Up @@ -545,7 +545,7 @@ class TestCorrectVignetteBivariateSpline:
correct_vignette_bivariate_spline` definition unit tests methods.
"""

def test_correct_vignette_bivariate_spline(self):
def test_correct_vignette_bivariate_spline(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.\
correct_vignette_bivariate_spline` definition.
Expand Down Expand Up @@ -615,7 +615,7 @@ class TestRadialSamplingFunction:
definition unit tests methods.
"""

def test_radial_sampling_function(self):
def test_radial_sampling_function(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.radial_sampling_function`
definition.
Expand Down Expand Up @@ -826,7 +826,7 @@ class TestVignetteSamplingCoordinates:
definition unit tests methods.
"""

def test_vignette_sampling_coordinates(self):
def test_vignette_sampling_coordinates(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.\
vignette_sampling_coordinates` definition.
Expand Down Expand Up @@ -1013,7 +1013,7 @@ class TestCharacteriseVignetteRBF:
definition unit tests methods.
"""

def test_characterise_vignette_RBF(self):
def test_characterise_vignette_RBF(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.characterise_vignette_RBF`
definition.
Expand Down Expand Up @@ -1215,7 +1215,7 @@ class TestCorrectVignetteRBF:
definition unit tests methods.
"""

def test_correct_vignette_RBF(self):
def test_correct_vignette_RBF(self) -> None:
"""
Test :func:`colour_hdri.distortion.vignette.correct_vignette_RBF`
definition.
Expand Down
Loading

0 comments on commit 50f3efd

Please sign in to comment.