Skip to content

Commit

Permalink
Merge branch 'release/v0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Feb 3, 2023
2 parents 38fbf13 + 4402417 commit f47109d
Show file tree
Hide file tree
Showing 9 changed files with 387 additions and 158 deletions.
20 changes: 4 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/ikamensh/flynt/
rev: '0.77'
hooks:
- id: flynt
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.239'
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
Expand All @@ -18,14 +17,3 @@ repos:
hooks:
- id: blackdoc
language_version: python3.9
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
args:
- --convention=numpy
- --add-ignore=D104,D200,D202,D205,D301,D400
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

__major_version__ = "0"
__minor_version__ = "2"
__change_version__ = "0"
__change_version__ = "1"
__version__ = ".".join(
(__major_version__, __minor_version__, __change_version__)
)
Expand Down
96 changes: 86 additions & 10 deletions apps/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
======
"""

from io import StringIO
from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS
from colour.colorimetry import CCS_ILLUMINANTS
from colour.io import LUTOperatorMatrix, write_LUT_SonySPImtx
from colour.models import RGB_COLOURSPACES
from colour.utilities import as_float_array

Expand All @@ -18,14 +20,17 @@
__status__ = "Production"

__all__ = [
"RGB_COLOURSPACE_OPTIONS",
"CHROMATIC_ADAPTATION_TRANSFORM_OPTIONS",
"ILLUMINANTS_OPTIONS",
"NUKE_COLORMATRIX_NODE_TEMPLATE",
"OPTIONS_RGB_COLOURSPACE",
"OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM",
"OPTIONS_ILLUMINANTS",
"TEMPLATE_NUKE_NODE_COLORMATRIX",
"nuke_format_matrix",
"spimtx_format_matrix",
"TEMPLATE_OCIO_COLORSPACE",
"matrix_3x3_to_4x4",
]

RGB_COLOURSPACE_OPTIONS: List[Dict] = [
OPTIONS_RGB_COLOURSPACE: List[Dict] = [
{"label": key, "value": key}
for key in sorted(RGB_COLOURSPACES.keys())
if key not in ("aces", "adobe1998", "prophoto")
Expand All @@ -34,7 +39,7 @@
*RGB* colourspace options for a :class:`Dropdown` class instance.
"""

CHROMATIC_ADAPTATION_TRANSFORM_OPTIONS: List[Dict] = [
OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM: List[Dict] = [
{"label": key, "value": key}
for key in sorted(CHROMATIC_ADAPTATION_TRANSFORMS.keys())
]
Expand All @@ -43,7 +48,7 @@
instance.
"""

ILLUMINANTS_OPTIONS: List[Dict] = [
OPTIONS_ILLUMINANTS: List[Dict] = [
{"label": key, "value": key}
for key in sorted(
CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"].keys()
Expand All @@ -54,13 +59,13 @@
:class:`Dropdown`class instance.
"""

NUKE_COLORMATRIX_NODE_TEMPLATE: str = """
TEMPLATE_NUKE_NODE_COLORMATRIX: str = """
ColorMatrix {{
inputs 0
matrix {{
{0}
{matrix}
}}
name "{1}"
name "{name}"
selected true
xpos 0
ypos 0
Expand Down Expand Up @@ -102,3 +107,74 @@ def pretty(x: Iterable) -> str:
tcl += f" {{{pretty(M[2])}}}"

return tcl


def spimtx_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
"""
Format given matrix as a *Sony* *.spimtx* *LUT* formatted matrix.
Parameters
----------
M
Matrix to format.
decimals
Decimals to use when formatting the matrix.
Returns
-------
:class:`str`
*Sony* *.spimtx* *LUT* formatted matrix.
"""

string = StringIO()

write_LUT_SonySPImtx(LUTOperatorMatrix(M), string, decimals)

return string.getvalue()


TEMPLATE_OCIO_COLORSPACE = """
- !<ColorSpace>
name: Linear {name}
aliases: []
family: Utility
equalitygroup: ""
bitdepth: 32f
description: |
Convert from {input_colourspace} to Linear {output_colourspace}
isdata: false
encoding: scene-linear
allocation: uniform
from_scene_reference: !<GroupTransform>
name: {input_colourspace} to Linear {output_colourspace}
children:
- !<MatrixTransform> {{matrix: {matrix}}}
"""[
1:
]
"""
*OpenColorIO* *ColorSpace* template.
"""


def matrix_3x3_to_4x4(M):
"""
Convert given 3x3 matrix :math:`M` to a raveled 4x4 matrix.
Parameters
----------
M : array_like
3x3 matrix :math:`M` to convert.
Returns
-------
list
Raveled 4x4 matrix.
"""

import numpy as np

M_I = np.identity(4)
M_I[:3, :3] = M

return np.ravel(M_I)
Loading

0 comments on commit f47109d

Please sign in to comment.