Skip to content

Commit b6217ab

Browse files
committed
Merge branch 'feature/v0.2.8' into develop
2 parents 7c93394 + 7107111 commit b6217ab

13 files changed

+367
-453
lines changed

.gitignore

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
# Common Files
12
*.egg-info
23
*.pyc
34
*.pyo
45
.DS_Store
56
.coverage*
6-
.idea
7+
uv.lock
8+
9+
# Common Directories
10+
.fleet/
11+
.idea/
12+
.ipynb_checkpoints/
13+
.python-version
14+
.vs/
15+
.vscode/
16+
.sandbox/
17+
build/
18+
dist/
19+
docs/_build/
20+
docs/generated/
21+
node_modules/
22+
references/
23+
724
__pycache__
8-
poetry.lock

.pre-commit-config.yaml

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,47 @@
11
repos:
2-
- repo: https://github.com/ikamensh/flynt/
3-
rev: '1.0.1'
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: "v5.0.0"
44
hooks:
5-
- id: flynt
6-
- repo: https://github.com/charliermarsh/ruff-pre-commit
7-
rev: 'v0.0.285'
5+
- id: check-added-large-files
6+
- id: check-case-conflict
7+
- id: check-merge-conflict
8+
- id: check-symlinks
9+
- id: check-yaml
10+
- id: debug-statements
11+
- id: end-of-file-fixer
12+
- id: mixed-line-ending
13+
- id: name-tests-test
14+
args: ["--pytest-test-first"]
15+
- id: requirements-txt-fixer
16+
- id: trailing-whitespace
17+
- repo: https://github.com/codespell-project/codespell
18+
rev: v2.3.0
819
hooks:
9-
- id: ruff
10-
- repo: https://github.com/psf/black
11-
rev: 23.7.0
20+
- id: codespell
21+
args: ["--ignore-words-list=socio-economic"]
22+
exclude: "CONTRIBUTORS.rst"
23+
- repo: https://github.com/PyCQA/isort
24+
rev: "5.13.2"
1225
hooks:
13-
- id: black
14-
language_version: python3.9
15-
- repo: https://github.com/keewis/blackdoc
16-
rev: v0.3.8
26+
- id: isort
27+
- repo: https://github.com/astral-sh/ruff-pre-commit
28+
rev: "v0.8.2"
1729
hooks:
18-
- id: blackdoc
19-
language_version: python3.9
30+
- id: ruff-format
31+
- id: ruff
32+
args: [--fix]
33+
- repo: https://github.com/adamchainz/blacken-docs
34+
rev: 1.19.1
35+
hooks:
36+
- id: blacken-docs
37+
language_version: python3.10
38+
- repo: https://github.com/pre-commit/mirrors-prettier
39+
rev: "v4.0.0-alpha.8"
40+
hooks:
41+
- id: prettier
42+
- repo: https://github.com/pre-commit/pygrep-hooks
43+
rev: "v1.10.0"
44+
hooks:
45+
- id: rst-backticks
46+
- id: rst-directive-colons
47+
- id: rst-inline-touching-normal

CODE_OF_CONDUCT.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,22 @@ In the interest of fostering an open and welcoming environment, we as contributo
88

99
Examples of behavior that contributes to creating a positive environment include:
1010

11-
* Using welcoming and inclusive language
12-
* Being respectful of differing viewpoints and experiences
13-
* Gracefully accepting constructive criticism
14-
* Focusing on what is best for the community
15-
* Showing empathy towards other community members
11+
- Using welcoming and inclusive language
12+
- Being respectful of differing viewpoints and experiences
13+
- Gracefully accepting constructive criticism
14+
- Focusing on what is best for the community
15+
- Showing empathy towards other community members
1616

1717
Examples of unacceptable behavior by participants include:
1818

19-
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20-
* Trolling, insulting/derogatory comments, and personal or political attacks
21-
* Public or private harassment
22-
* Publishing others’ private information, such as a physical or electronic address, without explicit permission
23-
* Other conduct which could reasonably be considered inappropriate in a professional setting
19+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
- Trolling, insulting/derogatory comments, and personal or political attacks
21+
- Public or private harassment
22+
- Publishing others’ private information, such as a physical or electronic address, without explicit permission
23+
- Other conduct which could reasonably be considered inappropriate in a professional setting
2424

2525
## Our Responsibilities
2626

27-
2827
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
2928

3029
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
@@ -35,7 +34,6 @@ This Code of Conduct applies within all project spaces, and it also applies when
3534

3635
## Enforcement
3736

38-
3937
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting Thomas Mansencal and Michael Mauderer via email at thomas@colour-science.org and michael@colour-science.org respectively. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
4038

4139
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project’s leadership.
@@ -46,6 +44,5 @@ This Code of Conduct is adapted from the Contributor Covenant, version 1.4, avai
4644

4745
For answers to common questions about this code of conduct, see [https://www.contributor-covenant.org/faq][faq].
4846

49-
5047
[homepage]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
51-
[faq]: https://www.contributor-covenant.org/faq
48+
[faq]: https://www.contributor-covenant.org/faq

CONTRIBUTORS.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Contributors
44
Colour - Dash
55
-------------
66

7-
- **Thomas Mansencal**, *Technology Supervisor @ Wētā FX*
7+
- **Thomas Mansencal**, *Principal Pipeline Programmer @ Epic Games*
88

99
Project coordination, writing.
10-
10+
1111
About
1212
-----
1313

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ The *Colour Developers* can be reached via different means:
5353
- `Email <mailto:colour-developers@colour-science.org>`__
5454
- `Facebook <https://www.facebook.com/python.colour.science>`__
5555
- `Gitter <https://gitter.im/colour-science/colour>`__
56-
- `Twitter <https://twitter.com/colour_science>`__
56+
- `X <https://x.com/colour_science>`__
57+
- `Bluesky <https://bsky.app/profile/colour-science.bsky.social>`__
5758

5859
About
5960
-----

app.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
===========
44
"""
55

6-
import dash
76
import os
8-
from colour.hints import Optional
9-
from flask import Flask
107

8+
import dash
9+
from flask import Flask
1110

1211
__author__ = "Colour Developers"
1312
__copyright__ = "Copyright 2018 Colour Developers"
@@ -20,10 +19,8 @@
2019

2120
__major_version__ = "0"
2221
__minor_version__ = "2"
23-
__change_version__ = "7"
24-
__version__ = ".".join(
25-
(__major_version__, __minor_version__, __change_version__)
26-
)
22+
__change_version__ = "8"
23+
__version__ = f"{__major_version__}.{__minor_version__}.{__change_version__}"
2724

2825
__all__ = ["SERVER", "SERVER_URL", "APP"]
2926

@@ -32,16 +29,16 @@
3229
*Flask* server hosting the *Dash* app.
3330
"""
3431

35-
SERVER_URL: Optional[str] = os.environ.get("COLOUR_DASH_SERVER")
32+
SERVER_URL: str | None = os.environ.get("COLOUR_DASH_SERVER")
3633
"""
3734
Server url used to construct permanent links for the individual apps.
3835
"""
3936

4037
APP: dash.Dash = dash.Dash(
4138
__application_name__,
42-
external_scripts=os.environ.get("COLOUR_DASH_JS", "").split(","),
43-
external_stylesheets=os.environ.get("COLOUR_DASH_CSS", "").split(","),
44-
server=SERVER, # pyright: ignore
39+
external_scripts=os.environ.get("COLOUR_DASH_JS", "").split(","), # pyright: ignore
40+
external_stylesheets=os.environ.get("COLOUR_DASH_CSS", "").split(","), # pyright: ignore
41+
server=SERVER,
4542
)
4643
"""
4744
*Dash* app.

apps/common.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
======
44
"""
55

6+
from __future__ import annotations
7+
8+
import typing
69
from io import StringIO
10+
711
from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS
812
from colour.colorimetry import CCS_ILLUMINANTS
13+
14+
if typing.TYPE_CHECKING:
15+
from colour.hints import ArrayLike, Dict, Iterable, List, NDArrayFloat
16+
917
from colour.io import LUTOperatorMatrix, write_LUT_SonySPImtx
1018
from colour.models import RGB_COLOURSPACES
1119
from colour.utilities import as_float_array
1220

13-
from colour.hints import ArrayLike, Dict, Iterable, List
14-
1521
__author__ = "Colour Developers"
1622
__copyright__ = "Copyright 2018 Colour Developers"
1723
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
@@ -50,9 +56,7 @@
5056

5157
OPTIONS_ILLUMINANTS: List[Dict] = [
5258
{"label": key, "value": key}
53-
for key in sorted(
54-
CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"].keys()
55-
)
59+
for key in sorted(CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"].keys())
5660
]
5761
"""
5862
*CIE 1931 2 Degree Standard Observer* illuminant options for a
@@ -69,17 +73,15 @@
6973
selected true
7074
xpos 0
7175
ypos 0
72-
}}"""[
73-
1:
74-
]
76+
}}"""[1:]
7577
"""
7678
*The Foundry Nuke* *ColorMatrix* node template.
7779
"""
7880

7981

8082
def nuke_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
8183
"""
82-
Format given matrix for usage in *The Foundry Nuke*, i.e. *TCL* code for
84+
Format given matrix for usage in *The Foundry Nuke*, i.e., *TCL* code for
8385
a *ColorMatrix* node.
8486
8587
Parameters
@@ -129,7 +131,9 @@ def spimtx_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
129131
string = StringIO()
130132

131133
write_LUT_SonySPImtx(
132-
LUTOperatorMatrix(M), string, decimals # pyright: ignore
134+
LUTOperatorMatrix(M),
135+
string, # pyright: ignore
136+
decimals,
133137
)
134138

135139
return string.getvalue()
@@ -151,15 +155,13 @@ def spimtx_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
151155
name: Linear {input_colourspace} to Linear {output_colourspace}
152156
children:
153157
- !<MatrixTransform> {{matrix: {matrix}}}
154-
"""[
155-
1:
156-
]
158+
"""[1:]
157159
"""
158160
*OpenColorIO* *ColorSpace* template.
159161
"""
160162

161163

162-
def matrix_3x3_to_4x4(M):
164+
def matrix_3x3_to_4x4(M: ArrayLike) -> NDArrayFloat:
163165
"""
164166
Convert given 3x3 matrix :math:`M` to a raveled 4x4 matrix.
165167

apps/rgb_colourspace_chromatically_adapted_primaries.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
===========================================================
44
"""
55

6+
from __future__ import annotations
7+
68
import sys
79
import urllib.parse
810
from contextlib import suppress
9-
from dash.dcc import Dropdown, Link, Location, Markdown, Slider
10-
from dash.dependencies import Input, Output
11-
from dash.html import A, Button, Code, Div, H3, H5, Li, Pre, Ul
1211
from urllib.parse import parse_qs, urlencode, urlparse
1312

1413
from colour.colorimetry import CCS_ILLUMINANTS
1514
from colour.models import RGB_COLOURSPACES, chromatically_adapted_primaries
1615
from colour.utilities import numpy_print_options
16+
from dash.dcc import Dropdown, Link, Location, Markdown, Slider
17+
from dash.dependencies import Input, Output
18+
from dash.html import H3, H5, A, Button, Code, Div, Li, Pre, Ul
1719

1820
from app import APP, SERVER_URL
1921
from apps.common import (
@@ -48,7 +50,7 @@
4850

4951
APP_PATH: str = f"/apps/{__name__.split('.')[-1]}"
5052
"""
51-
App path, i.e. app url.
53+
App path, i.e., app url.
5254
"""
5355

5456
APP_DESCRIPTION: str = (
@@ -67,7 +69,7 @@
6769
"""
6870

6971

70-
def _uid(id_):
72+
def _uid(id_: str) -> str:
7173
"""
7274
Generate a unique id for given id by appending the application *UID*.
7375
"""
@@ -78,9 +80,9 @@ def _uid(id_):
7880
STATE_DEFAULT = {
7981
"colourspace": OPTIONS_RGB_COLOURSPACE[0]["value"],
8082
"illuminant": OPTIONS_ILLUMINANTS[0]["value"],
81-
"chromatic_adaptation_transform": OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM[
82-
0
83-
]["value"],
83+
"chromatic_adaptation_transform": OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM[0][
84+
"value"
85+
],
8486
"formatter": "str",
8587
"decimals": 10,
8688
}
@@ -118,9 +120,7 @@ def _uid(id_):
118120
Dropdown(
119121
id=_uid("chromatic-adaptation-transform"),
120122
options=OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM,
121-
value=STATE_DEFAULT[
122-
"chromatic_adaptation_transform"
123-
],
123+
value=STATE_DEFAULT["chromatic_adaptation_transform"],
124124
clearable=False,
125125
className="app-widget",
126126
),
@@ -208,16 +208,14 @@ def _uid(id_):
208208
className="row",
209209
)
210210
"""
211-
App layout, i.e. :class:`Div` class instance.
211+
App layout, i.e., :class:`Div` class instance.
212212
213213
LAYOUT : Div
214214
"""
215215

216216

217217
@APP.callback(
218-
Output(
219-
component_id=_uid("primaries-output"), component_property="children"
220-
),
218+
Output(component_id=_uid("primaries-output"), component_property="children"),
221219
[
222220
Input(_uid("colourspace"), "value"),
223221
Input(_uid("illuminant"), "value"),
@@ -317,16 +315,14 @@ def value_from_query(value: str) -> str:
317315

318316
return STATE_DEFAULT[value.replace("-", "_")]
319317

320-
state = (
318+
return (
321319
value_from_query("colourspace"),
322320
value_from_query("illuminant"),
323321
value_from_query("chromatic-adaptation-transform"),
324322
value_from_query("formatter"),
325323
int(value_from_query("decimals")),
326324
)
327325

328-
return state
329-
330326

331327
@APP.callback(
332328
Output(_uid("url"), "search"),

0 commit comments

Comments
 (0)