Skip to content

Commit

Permalink
Use Ruff format.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Jan 29, 2024
1 parent 7ac9710 commit 8ced7fa
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 84 deletions.
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ repos:
- id: flynt
args: [--verbose]
- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
rev: "5.13.2"
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.6"
rev: "v0.1.14"
hooks:
- id: ruff
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black
language_version: python3.9
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
Expand Down
5 changes: 3 additions & 2 deletions colour_visuals/daylight_locus.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ class VisualDaylightLocus(

def __init__(
self,
method: Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"]
| str = "CIE 1931",
method: (
Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] | str
) = "CIE 1931",
mireds: bool = False,
colour: ArrayLike | None = None,
opacity: float = 1,
Expand Down
58 changes: 33 additions & 25 deletions colour_visuals/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ class VisualSpectralLocus2D(

def __init__(
self,
cmfs: MultiSpectralDistributions
| str
| Sequence[
MultiSpectralDistributions | str
] = "CIE 1931 2 Degree Standard Observer",
method: Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"]
| str = "CIE 1931",
cmfs: (
MultiSpectralDistributions
| str
| Sequence[MultiSpectralDistributions | str]
) = "CIE 1931 2 Degree Standard Observer",
method: (
Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] | str
) = "CIE 1931",
labels: Sequence | None = None,
colour: ArrayLike | None = None,
opacity: float = 1,
Expand Down Expand Up @@ -308,9 +309,11 @@ def update(self):
str(label),
font_size=CONSTANTS_COLOUR_STYLE.font.size,
screen_space=True,
anchor="Center-Left"
if lines_w["normal"][::2][i, 0] >= 0
else "Center-Right",
anchor=(
"Center-Left"
if lines_w["normal"][::2][i, 0] >= 0
else "Center-Right"
),
),
gfx.TextMaterial(color=CONSTANTS_COLOUR_STYLE.colour.light),
)
Expand Down Expand Up @@ -437,11 +440,11 @@ class VisualSpectralLocus3D(

def __init__(
self,
cmfs: MultiSpectralDistributions
| str
| Sequence[
MultiSpectralDistributions | str
] = "CIE 1931 2 Degree Standard Observer",
cmfs: (
MultiSpectralDistributions
| str
| Sequence[MultiSpectralDistributions | str]
) = "CIE 1931 2 Degree Standard Observer",
model: LiteralColourspaceModel | str = "CIE xyY",
colour: ArrayLike | None = None,
opacity: float = 1,
Expand Down Expand Up @@ -584,13 +587,14 @@ class VisualChromaticityDiagram(

def __init__(
self,
cmfs: MultiSpectralDistributions
| str
| Sequence[
MultiSpectralDistributions | str
] = "CIE 1931 2 Degree Standard Observer",
method: Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"]
| str = "CIE 1931",
cmfs: (
MultiSpectralDistributions
| str
| Sequence[MultiSpectralDistributions | str]
) = "CIE 1931 2 Degree Standard Observer",
method: (
Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] | str
) = "CIE 1931",
colours: ArrayLike | None = None,
opacity: float = 1,
material: Type[gfx.MeshAbstractMaterial] = gfx.MeshBasicMaterial,
Expand Down Expand Up @@ -670,9 +674,13 @@ def update(self):

self._chromaticity_diagram = gfx.Mesh(
geometry,
self._type_material(color_mode="vertex", wireframe=self._wireframe)
if self._wireframe
else self._type_material(color_mode="vertex"),
(
self._type_material(
color_mode="vertex", wireframe=self._wireframe
)
if self._wireframe
else self._type_material(color_mode="vertex")
),
)
self.add(self._chromaticity_diagram)

Expand Down
5 changes: 3 additions & 2 deletions colour_visuals/planckian_locus.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ class VisualPlanckianLocus(

def __init__(
self,
method: Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"]
| str = "CIE 1931",
method: (
Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] | str
) = "CIE 1931",
labels: Sequence | None = None,
mireds: bool = False,
colour: ArrayLike | None = None,
Expand Down
5 changes: 3 additions & 2 deletions colour_visuals/pointer_gamut.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ class VisualPointerGamut2D(

def __init__(
self,
method: Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"]
| str = "CIE 1931",
method: (
Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] | str
) = "CIE 1931",
colour: ArrayLike | None = None,
opacity: float = 1,
thickness: float = 1,
Expand Down
31 changes: 20 additions & 11 deletions colour_visuals/rgb_colourspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@ class VisualRGBColourspace2D(

def __init__(
self,
colourspace: RGB_Colourspace
| str
| Sequence[RGB_Colourspace | LiteralRGBColourspace | str] = "sRGB",
method: Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"]
| str = "CIE 1931",
colourspace: (
RGB_Colourspace
| str
| Sequence[RGB_Colourspace | LiteralRGBColourspace | str]
) = "sRGB",
method: (
Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] | str
) = "CIE 1931",
colour: ArrayLike | None = None,
opacity: float = 1,
thickness: float = 1,
Expand Down Expand Up @@ -320,9 +323,11 @@ class VisualRGBColourspace3D(

def __init__(
self,
colourspace: RGB_Colourspace
| str
| Sequence[RGB_Colourspace | LiteralRGBColourspace | str] = "sRGB",
colourspace: (
RGB_Colourspace
| str
| Sequence[RGB_Colourspace | LiteralRGBColourspace | str]
) = "sRGB",
model: LiteralColourspaceModel | str = "CIE xyY",
colour: ArrayLike | None = None,
opacity: float = 1,
Expand Down Expand Up @@ -392,9 +397,13 @@ def update(self):
append_channel(colour, self._opacity)
),
),
self._type_material(color_mode="vertex", wireframe=self._wireframe)
if self._wireframe
else self._type_material(color_mode="vertex"),
(
self._type_material(
color_mode="vertex", wireframe=self._wireframe
)
if self._wireframe
else self._type_material(color_mode="vertex")
),
)
self.add(self._gamut)

Expand Down
8 changes: 5 additions & 3 deletions colour_visuals/rgb_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ class VisualRGBScatter3D(
def __init__(
self,
RGB: ArrayLike,
colourspace: RGB_Colourspace
| str
| Sequence[RGB_Colourspace | LiteralRGBColourspace | str] = "sRGB",
colourspace: (
RGB_Colourspace
| str
| Sequence[RGB_Colourspace | LiteralRGBColourspace | str]
) = "sRGB",
model: LiteralColourspaceModel | str = "CIE xyY",
colour: ArrayLike | None = None,
opacity: float = 1,
Expand Down
16 changes: 8 additions & 8 deletions colour_visuals/rosch_macadam.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ class VisualRoschMacAdam(

def __init__(
self,
cmfs: MultiSpectralDistributions
| str
| Sequence[
MultiSpectralDistributions | str
] = "CIE 1931 2 Degree Standard Observer",
illuminant: SpectralDistribution
| str
| Sequence[SpectralDistribution | str] = "E",
cmfs: (
MultiSpectralDistributions
| str
| Sequence[MultiSpectralDistributions | str]
) = "CIE 1931 2 Degree Standard Observer",
illuminant: (
SpectralDistribution | str | Sequence[SpectralDistribution | str]
) = "E",
model: LiteralColourspaceModel | str = "CIE xyY",
colour: ArrayLike | None = None,
opacity: float = 1,
Expand Down
8 changes: 5 additions & 3 deletions colour_visuals/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ def cmfs(
@cmfs.setter
def cmfs(
self,
value: MultiSpectralDistributions
| str
| Sequence[MultiSpectralDistributions | str],
value: (
MultiSpectralDistributions
| str
| Sequence[MultiSpectralDistributions | str]
),
):
"""Setter for the **self.cmfs** property."""

Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ exclude = '''
)/
'''

[tool.codespell]
skip = 'BIBLIOGRAPHY.bib,CONTRIBUTORS.rst'

[tool.flynt]
line_length=999

Expand Down Expand Up @@ -194,6 +197,9 @@ convention = "numpy"
"utilities/*" = ["EXE001", "INP"]
"utilities/unicode_to_ascii.py" = ["RUF001"]

[tool.ruff.format]
docstring-code-format = true

[build-system]
requires = [ "poetry_core>=1.0.0" ]
build-backend = "poetry.core.masonry.api"
42 changes: 21 additions & 21 deletions utilities/generate_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,44 @@

mpl.use("AGG")

import os # noqa: E402

import matplotlib.pyplot as plt # noqa: E402
import numpy as np # noqa: E402
import pygfx as gfx # noqa: E402
import pylinalg as la # noqa: E402
from colour.io import write_image # noqa: E402
from colour.plotting import colour_style, plot_image # noqa: E402
from colour.utilities import filter_warnings # noqa: E402
from wgpu.gui.offscreen import WgpuCanvas # noqa: E402

from colour_visuals.axes import VisualAxes # noqa: E402
from colour_visuals.daylight_locus import VisualDaylightLocus # noqa: E402
from colour_visuals.diagrams import ( # noqa: E402
import os

import matplotlib.pyplot as plt
import numpy as np
import pygfx as gfx
import pylinalg as la
from colour.io import write_image
from colour.plotting import colour_style, plot_image
from colour.utilities import filter_warnings
from wgpu.gui.offscreen import WgpuCanvas

from colour_visuals.axes import VisualAxes
from colour_visuals.daylight_locus import VisualDaylightLocus
from colour_visuals.diagrams import (
VisualChromaticityDiagram,
VisualChromaticityDiagramCIE1931,
VisualChromaticityDiagramCIE1960UCS,
VisualChromaticityDiagramCIE1976UCS,
VisualSpectralLocus2D,
VisualSpectralLocus3D,
)
from colour_visuals.grid import VisualGrid # noqa: E402
from colour_visuals.patterns import ( # noqa: E402
from colour_visuals.grid import VisualGrid
from colour_visuals.patterns import (
pattern_colour_wheel,
pattern_hue_stripes,
pattern_hue_swatches,
)
from colour_visuals.planckian_locus import VisualPlanckianLocus # noqa: E402
from colour_visuals.pointer_gamut import ( # noqa: E402
from colour_visuals.planckian_locus import VisualPlanckianLocus
from colour_visuals.pointer_gamut import (
VisualPointerGamut2D,
VisualPointerGamut3D,
)
from colour_visuals.rgb_colourspace import ( # noqa: E402
from colour_visuals.rgb_colourspace import (
VisualRGBColourspace2D,
VisualRGBColourspace3D,
)
from colour_visuals.rgb_scatter import VisualRGBScatter3D # noqa: E402
from colour_visuals.rosch_macadam import VisualRoschMacAdam # noqa: E402
from colour_visuals.rgb_scatter import VisualRGBScatter3D
from colour_visuals.rosch_macadam import VisualRoschMacAdam

__copyright__ = "Copyright 2023 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
Expand Down

0 comments on commit 8ced7fa

Please sign in to comment.