Skip to content

Commit

Permalink
Merge branch 'feature/v0.2.8' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Jan 9, 2025
2 parents 7c93394 + 7107111 commit b6217ab
Show file tree
Hide file tree
Showing 13 changed files with 367 additions and 453 deletions.
20 changes: 18 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
# Common Files
*.egg-info
*.pyc
*.pyo
.DS_Store
.coverage*
.idea
uv.lock

# Common Directories
.fleet/
.idea/
.ipynb_checkpoints/
.python-version
.vs/
.vscode/
.sandbox/
build/
dist/
docs/_build/
docs/generated/
node_modules/
references/

__pycache__
poetry.lock
56 changes: 42 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
repos:
- repo: https://github.com/ikamensh/flynt/
rev: '1.0.1'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v5.0.0"
hooks:
- id: flynt
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.285'
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: name-tests-test
args: ["--pytest-test-first"]
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.7.0
- id: codespell
args: ["--ignore-words-list=socio-economic"]
exclude: "CONTRIBUTORS.rst"
- repo: https://github.com/PyCQA/isort
rev: "5.13.2"
hooks:
- id: black
language_version: python3.9
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.2"
hooks:
- id: blackdoc
language_version: python3.9
- id: ruff-format
- id: ruff
args: [--fix]
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.1
hooks:
- id: blacken-docs
language_version: python3.10
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
25 changes: 11 additions & 14 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@ In the interest of fostering an open and welcoming environment, we as contributo

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

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

Examples of unacceptable behavior by participants include:

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

## Our Responsibilities


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.

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.
Expand All @@ -35,7 +34,6 @@ This Code of Conduct applies within all project spaces, and it also applies when

## Enforcement


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.

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.
Expand All @@ -46,6 +44,5 @@ This Code of Conduct is adapted from the Contributor Covenant, version 1.4, avai

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


[homepage]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[faq]: https://www.contributor-covenant.org/faq
[faq]: https://www.contributor-covenant.org/faq
4 changes: 2 additions & 2 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Contributors
Colour - Dash
-------------

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

Project coordination, writing.

About
-----

Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ The *Colour Developers* can be reached via different means:
- `Email <mailto:colour-developers@colour-science.org>`__
- `Facebook <https://www.facebook.com/python.colour.science>`__
- `Gitter <https://gitter.im/colour-science/colour>`__
- `Twitter <https://twitter.com/colour_science>`__
- `X <https://x.com/colour_science>`__
- `Bluesky <https://bsky.app/profile/colour-science.bsky.social>`__

About
-----
Expand Down
19 changes: 8 additions & 11 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
===========
"""

import dash
import os
from colour.hints import Optional
from flask import Flask

import dash
from flask import Flask

__author__ = "Colour Developers"
__copyright__ = "Copyright 2018 Colour Developers"
Expand All @@ -20,10 +19,8 @@

__major_version__ = "0"
__minor_version__ = "2"
__change_version__ = "7"
__version__ = ".".join(
(__major_version__, __minor_version__, __change_version__)
)
__change_version__ = "8"
__version__ = f"{__major_version__}.{__minor_version__}.{__change_version__}"

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

Expand All @@ -32,16 +29,16 @@
*Flask* server hosting the *Dash* app.
"""

SERVER_URL: Optional[str] = os.environ.get("COLOUR_DASH_SERVER")
SERVER_URL: str | None = os.environ.get("COLOUR_DASH_SERVER")
"""
Server url used to construct permanent links for the individual apps.
"""

APP: dash.Dash = dash.Dash(
__application_name__,
external_scripts=os.environ.get("COLOUR_DASH_JS", "").split(","),
external_stylesheets=os.environ.get("COLOUR_DASH_CSS", "").split(","),
server=SERVER, # pyright: ignore
external_scripts=os.environ.get("COLOUR_DASH_JS", "").split(","), # pyright: ignore
external_stylesheets=os.environ.get("COLOUR_DASH_CSS", "").split(","), # pyright: ignore
server=SERVER,
)
"""
*Dash* app.
Expand Down
30 changes: 16 additions & 14 deletions apps/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
======
"""

from __future__ import annotations

import typing
from io import StringIO

from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS
from colour.colorimetry import CCS_ILLUMINANTS

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

from colour.io import LUTOperatorMatrix, write_LUT_SonySPImtx
from colour.models import RGB_COLOURSPACES
from colour.utilities import as_float_array

from colour.hints import ArrayLike, Dict, Iterable, List

__author__ = "Colour Developers"
__copyright__ = "Copyright 2018 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
Expand Down Expand Up @@ -50,9 +56,7 @@

OPTIONS_ILLUMINANTS: List[Dict] = [
{"label": key, "value": key}
for key in sorted(
CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"].keys()
)
for key in sorted(CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"].keys())
]
"""
*CIE 1931 2 Degree Standard Observer* illuminant options for a
Expand All @@ -69,17 +73,15 @@
selected true
xpos 0
ypos 0
}}"""[
1:
]
}}"""[1:]
"""
*The Foundry Nuke* *ColorMatrix* node template.
"""


def nuke_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
"""
Format given matrix for usage in *The Foundry Nuke*, i.e. *TCL* code for
Format given matrix for usage in *The Foundry Nuke*, i.e., *TCL* code for
a *ColorMatrix* node.
Parameters
Expand Down Expand Up @@ -129,7 +131,9 @@ def spimtx_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
string = StringIO()

write_LUT_SonySPImtx(
LUTOperatorMatrix(M), string, decimals # pyright: ignore
LUTOperatorMatrix(M),
string, # pyright: ignore
decimals,
)

return string.getvalue()
Expand All @@ -151,15 +155,13 @@ def spimtx_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
name: Linear {input_colourspace} to Linear {output_colourspace}
children:
- !<MatrixTransform> {{matrix: {matrix}}}
"""[
1:
]
"""[1:]
"""
*OpenColorIO* *ColorSpace* template.
"""


def matrix_3x3_to_4x4(M):
def matrix_3x3_to_4x4(M: ArrayLike) -> NDArrayFloat:
"""
Convert given 3x3 matrix :math:`M` to a raveled 4x4 matrix.
Expand Down
32 changes: 14 additions & 18 deletions apps/rgb_colourspace_chromatically_adapted_primaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
===========================================================
"""

from __future__ import annotations

import sys
import urllib.parse
from contextlib import suppress
from dash.dcc import Dropdown, Link, Location, Markdown, Slider
from dash.dependencies import Input, Output
from dash.html import A, Button, Code, Div, H3, H5, Li, Pre, Ul
from urllib.parse import parse_qs, urlencode, urlparse

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

from app import APP, SERVER_URL
from apps.common import (
Expand Down Expand Up @@ -48,7 +50,7 @@

APP_PATH: str = f"/apps/{__name__.split('.')[-1]}"
"""
App path, i.e. app url.
App path, i.e., app url.
"""

APP_DESCRIPTION: str = (
Expand All @@ -67,7 +69,7 @@
"""


def _uid(id_):
def _uid(id_: str) -> str:
"""
Generate a unique id for given id by appending the application *UID*.
"""
Expand All @@ -78,9 +80,9 @@ def _uid(id_):
STATE_DEFAULT = {
"colourspace": OPTIONS_RGB_COLOURSPACE[0]["value"],
"illuminant": OPTIONS_ILLUMINANTS[0]["value"],
"chromatic_adaptation_transform": OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM[
0
]["value"],
"chromatic_adaptation_transform": OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM[0][
"value"
],
"formatter": "str",
"decimals": 10,
}
Expand Down Expand Up @@ -118,9 +120,7 @@ def _uid(id_):
Dropdown(
id=_uid("chromatic-adaptation-transform"),
options=OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM,
value=STATE_DEFAULT[
"chromatic_adaptation_transform"
],
value=STATE_DEFAULT["chromatic_adaptation_transform"],
clearable=False,
className="app-widget",
),
Expand Down Expand Up @@ -208,16 +208,14 @@ def _uid(id_):
className="row",
)
"""
App layout, i.e. :class:`Div` class instance.
App layout, i.e., :class:`Div` class instance.
LAYOUT : Div
"""


@APP.callback(
Output(
component_id=_uid("primaries-output"), component_property="children"
),
Output(component_id=_uid("primaries-output"), component_property="children"),
[
Input(_uid("colourspace"), "value"),
Input(_uid("illuminant"), "value"),
Expand Down Expand Up @@ -317,16 +315,14 @@ def value_from_query(value: str) -> str:

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

state = (
return (
value_from_query("colourspace"),
value_from_query("illuminant"),
value_from_query("chromatic-adaptation-transform"),
value_from_query("formatter"),
int(value_from_query("decimals")),
)

return state


@APP.callback(
Output(_uid("url"), "search"),
Expand Down
Loading

0 comments on commit b6217ab

Please sign in to comment.