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 8e78eed commit 3b5afca
Show file tree
Hide file tree
Showing 18 changed files with 265 additions and 242 deletions.
4 changes: 2 additions & 2 deletions colour_visuals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
__major_version__ = "0"
__minor_version__ = "1"
__change_version__ = "0"
__version__ = ".".join((__major_version__, __minor_version__, __change_version__))
__version__ = f"{__major_version__}.{__minor_version__}.{__change_version__}"

try:
_version: str = (
Expand All @@ -119,7 +119,7 @@
.strip()
.decode("utf-8")
)
except Exception:
except Exception: # noqa: BLE001
_version: str = __version__

colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES["colour-visuals"] = _version # pyright: ignore
Expand Down
17 changes: 11 additions & 6 deletions colour_visuals/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@

from __future__ import annotations

import typing

import numpy as np
import pygfx as gfx
from colour.hints import LiteralColourspaceModel

if typing.TYPE_CHECKING:
from colour.hints import LiteralColourspaceModel

from colour.models import COLOURSPACE_MODELS_AXIS_LABELS
from colour.plotting import (
CONSTANTS_COLOUR_STYLE,
Expand Down Expand Up @@ -91,7 +96,7 @@ def __init__(
self,
model: LiteralColourspaceModel | str = "CIE xyY",
size: int = 1,
):
) -> None:
super().__init__()

self._axes_helper = None
Expand All @@ -105,7 +110,7 @@ def __init__(

self.update()

def update(self):
def update(self) -> None:
"""Update the visual."""

if self._is_update_blocked:
Expand Down Expand Up @@ -156,7 +161,7 @@ def update(self):
screen_space=True,
anchor="Middle-Center",
),
gfx.TextMaterial(color=np.array([1, 0, 0])),
gfx.TextMaterial(color=np.array([1, 0, 0])), # pyright: ignore
)
self._x_text.local.position = np.array([1 * self._size * 1.05, 0, 0])
self.add(self._x_text)
Expand All @@ -169,7 +174,7 @@ def update(self):
screen_space=True,
anchor="Middle-Center",
),
gfx.TextMaterial(color=np.array([0, 1, 0])),
gfx.TextMaterial(color=np.array([0, 1, 0])), # pyright: ignore
)
self._y_text.local.position = np.array([0, 1 * self._size * 1.05, 0])
self.add(self._y_text)
Expand All @@ -182,7 +187,7 @@ def update(self):
screen_space=True,
anchor="Middle-Center",
),
gfx.TextMaterial(color=np.array([0, 0, 1])),
gfx.TextMaterial(color=np.array([0, 0, 1])), # pyright: ignore
)
self._z_text.local.position = np.array([0, 0, 1 * self._size * 1.05])
self.add(self._z_text)
Expand Down
23 changes: 14 additions & 9 deletions colour_visuals/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
from __future__ import annotations

import re
import typing

import numpy as np
from colour.graph import convert
from colour.hints import (
ArrayLike,
DType,
LiteralColourspaceModel,
NDArray,
Tuple,
Type,
)

if typing.TYPE_CHECKING:
from colour.hints import (
Any,
ArrayLike,
DType,
LiteralColourspaceModel,
NDArray,
Tuple,
Type,
)

from colour.models import COLOURSPACE_MODELS_DOMAIN_RANGE_SCALE_1_TO_REFERENCE
from colour.utilities import full, optional

Expand Down Expand Up @@ -56,7 +61,7 @@ def XYZ_to_colourspace_model(
illuminant: ArrayLike,
model: LiteralColourspaceModel | str = "CIE xyY",
normalise_model: bool | None = None,
**kwargs,
**kwargs: Any,
) -> NDArray:
"""
Convert from *CIE XYZ* tristimulus values to given colourspace model while
Expand Down
20 changes: 13 additions & 7 deletions colour_visuals/daylight_locus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@

from __future__ import annotations

import typing

import numpy as np
import pygfx as gfx
from colour.hints import (
ArrayLike,
Literal,
)

if typing.TYPE_CHECKING:
from colour.hints import (
ArrayLike,
Literal,
)


from colour.plotting import (
lines_daylight_locus,
)
Expand Down Expand Up @@ -117,7 +123,7 @@ def __init__(
colour: ArrayLike | None = None,
opacity: float = 1,
thickness: float = 1,
):
) -> None:
super().__init__()

self._daylight_locus = None
Expand Down Expand Up @@ -156,12 +162,12 @@ def mireds(
return self._mireds

@mireds.setter
def mireds(self, value: bool):
def mireds(self, value: bool) -> None:
"""Setter for the **self.mireds** property."""

self._mireds = value

def update(self):
def update(self) -> None:
"""Update the visual."""

if self._is_update_blocked:
Expand Down
43 changes: 24 additions & 19 deletions colour_visuals/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

from __future__ import annotations

import typing

import numpy as np
import pygfx as gfx
from colour.algebra import euclidean_distance, normalise_maximum
from colour.colorimetry import MultiSpectralDistributions
from colour.hints import (
Any,
ArrayLike,
Literal,
LiteralColourspaceModel,
Expand Down Expand Up @@ -65,6 +67,9 @@
visual_property,
)

if typing.TYPE_CHECKING:
from colour.colorimetry import MultiSpectralDistributions

__author__ = "Colour Developers"
__copyright__ = "Copyright 2023 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
Expand Down Expand Up @@ -168,7 +173,7 @@ def __init__(
colour: ArrayLike | None = None,
opacity: float = 1,
thickness: float = 1,
):
) -> None:
super().__init__()

self._spectral_locus = None
Expand Down Expand Up @@ -209,15 +214,15 @@ def labels(
return self._labels

@labels.setter
def labels(self, value: Sequence | None):
def labels(self, value: Sequence | None) -> None:
"""Setter for the **self.labels** property."""

self._labels = cast(
Sequence,
optional(value, LABELS_CHROMATICITY_DIAGRAM_DEFAULT[self._method]),
)

def update(self):
def update(self) -> None:
"""Update the visual."""

if self._is_update_blocked:
Expand Down Expand Up @@ -437,8 +442,8 @@ def __init__(
colour: ArrayLike | None = None,
opacity: float = 1,
thickness: float = 1,
**kwargs,
):
**kwargs: Any,
) -> None:
super().__init__()

self._spectral_locus = None
Expand All @@ -453,7 +458,7 @@ def __init__(

self.update()

def update(self):
def update(self) -> None:
"""Update the visual."""

if self._is_update_blocked:
Expand Down Expand Up @@ -583,7 +588,7 @@ def __init__(
material: Type[gfx.MeshAbstractMaterial] = gfx.MeshBasicMaterial,
wireframe: bool = False,
samples: int = 64,
):
) -> None:
super().__init__()

self._chromaticity_diagram = None
Expand All @@ -599,7 +604,7 @@ def __init__(

self.update()

def update(self):
def update(self) -> None:
"""Update the visual."""

if self._is_update_blocked:
Expand Down Expand Up @@ -677,7 +682,7 @@ class MixinPropertyKwargsVisualSpectralLocus:
kwargs_visual_spectral_locus`
"""

def __init__(self):
def __init__(self) -> None:
self._spectral_locus = None
self._kwargs_visual_spectral_locus = {}

Expand All @@ -703,7 +708,7 @@ def kwargs_visual_spectral_locus(self) -> dict:
return self._kwargs_visual_spectral_locus

@kwargs_visual_spectral_locus.setter
def kwargs_visual_spectral_locus(self, value: dict):
def kwargs_visual_spectral_locus(self, value: dict) -> None:
"""
Setter for the **self.kwargs_visual_spectral_locus** property.
"""
Expand All @@ -725,7 +730,7 @@ class MixinPropertyKwargsVisualChromaticityDiagram:
MixinPropertyKwargsVisualChromaticityDiagram.kwargs_visual_chromaticity_diagram`
"""

def __init__(self):
def __init__(self) -> None:
self._chromaticity_diagram = None
self._kwargs_visual_chromaticity_diagram = {}

Expand All @@ -751,7 +756,7 @@ def kwargs_visual_chromaticity_diagram(self) -> dict:
return self._kwargs_visual_chromaticity_diagram

@kwargs_visual_chromaticity_diagram.setter
def kwargs_visual_chromaticity_diagram(self, value: dict):
def kwargs_visual_chromaticity_diagram(self, value: dict) -> None:
"""
Setter for the **self.kwargs_visual_chromaticity_diagram** property.
"""
Expand Down Expand Up @@ -823,7 +828,7 @@ def __init__(
self,
kwargs_visual_spectral_locus: dict | None = None,
kwargs_visual_chromaticity_diagram: dict | None = None,
):
) -> None:
super().__init__()

if kwargs_visual_spectral_locus is None:
Expand All @@ -841,7 +846,7 @@ def __init__(
self.kwargs_visual_spectral_locus = kwargs_visual_spectral_locus
self.kwargs_visual_chromaticity_diagram = kwargs_visual_chromaticity_diagram

def update(self):
def update(self) -> None:
"""Update the visual."""


Expand Down Expand Up @@ -906,7 +911,7 @@ def __init__(
self,
kwargs_visual_spectral_locus: dict | None = None,
kwargs_visual_chromaticity_diagram: dict | None = None,
):
) -> None:
super().__init__()

if kwargs_visual_spectral_locus is None:
Expand All @@ -930,7 +935,7 @@ def __init__(
self.kwargs_visual_spectral_locus = kwargs_visual_spectral_locus
self.kwargs_visual_chromaticity_diagram = kwargs_visual_chromaticity_diagram

def update(self):
def update(self) -> None:
"""Update the visual."""


Expand Down Expand Up @@ -995,7 +1000,7 @@ def __init__(
self,
kwargs_visual_spectral_locus: dict | None = None,
kwargs_visual_chromaticity_diagram: dict | None = None,
):
) -> None:
super().__init__()

if kwargs_visual_spectral_locus is None:
Expand All @@ -1019,7 +1024,7 @@ def __init__(
self.kwargs_visual_spectral_locus = kwargs_visual_spectral_locus
self.kwargs_visual_chromaticity_diagram = kwargs_visual_chromaticity_diagram

def update(self):
def update(self) -> None:
"""Update the visual."""


Expand Down
Loading

0 comments on commit 3b5afca

Please sign in to comment.