Skip to content

Commit f47109d

Browse files
committed
Merge branch 'release/v0.2.1'
2 parents 38fbf13 + 4402417 commit f47109d

File tree

9 files changed

+387
-158
lines changed

9 files changed

+387
-158
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
repos:
2-
- repo: https://github.com/asottile/pyupgrade
3-
rev: v3.2.2
4-
hooks:
5-
- id: pyupgrade
6-
args: [--py39-plus]
72
- repo: https://github.com/ikamensh/flynt/
83
rev: '0.77'
94
hooks:
105
- id: flynt
6+
- repo: https://github.com/charliermarsh/ruff-pre-commit
7+
rev: 'v0.0.239'
8+
hooks:
9+
- id: ruff
1110
- repo: https://github.com/psf/black
1211
rev: 22.10.0
1312
hooks:
@@ -18,14 +17,3 @@ repos:
1817
hooks:
1918
- id: blackdoc
2019
language_version: python3.9
21-
- repo: https://github.com/PyCQA/flake8
22-
rev: 6.0.0
23-
hooks:
24-
- id: flake8
25-
- repo: https://github.com/pycqa/pydocstyle
26-
rev: 6.1.1
27-
hooks:
28-
- id: pydocstyle
29-
args:
30-
- --convention=numpy
31-
- --add-ignore=D104,D200,D202,D205,D301,D400

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
__major_version__ = "0"
2222
__minor_version__ = "2"
23-
__change_version__ = "0"
23+
__change_version__ = "1"
2424
__version__ = ".".join(
2525
(__major_version__, __minor_version__, __change_version__)
2626
)

apps/common.py

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

6+
from io import StringIO
67
from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS
78
from colour.colorimetry import CCS_ILLUMINANTS
9+
from colour.io import LUTOperatorMatrix, write_LUT_SonySPImtx
810
from colour.models import RGB_COLOURSPACES
911
from colour.utilities import as_float_array
1012

@@ -18,14 +20,17 @@
1820
__status__ = "Production"
1921

2022
__all__ = [
21-
"RGB_COLOURSPACE_OPTIONS",
22-
"CHROMATIC_ADAPTATION_TRANSFORM_OPTIONS",
23-
"ILLUMINANTS_OPTIONS",
24-
"NUKE_COLORMATRIX_NODE_TEMPLATE",
23+
"OPTIONS_RGB_COLOURSPACE",
24+
"OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM",
25+
"OPTIONS_ILLUMINANTS",
26+
"TEMPLATE_NUKE_NODE_COLORMATRIX",
2527
"nuke_format_matrix",
28+
"spimtx_format_matrix",
29+
"TEMPLATE_OCIO_COLORSPACE",
30+
"matrix_3x3_to_4x4",
2631
]
2732

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

37-
CHROMATIC_ADAPTATION_TRANSFORM_OPTIONS: List[Dict] = [
42+
OPTIONS_CHROMATIC_ADAPTATION_TRANSFORM: List[Dict] = [
3843
{"label": key, "value": key}
3944
for key in sorted(CHROMATIC_ADAPTATION_TRANSFORMS.keys())
4045
]
@@ -43,7 +48,7 @@
4348
instance.
4449
"""
4550

46-
ILLUMINANTS_OPTIONS: List[Dict] = [
51+
OPTIONS_ILLUMINANTS: List[Dict] = [
4752
{"label": key, "value": key}
4853
for key in sorted(
4954
CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"].keys()
@@ -54,13 +59,13 @@
5459
:class:`Dropdown`class instance.
5560
"""
5661

57-
NUKE_COLORMATRIX_NODE_TEMPLATE: str = """
62+
TEMPLATE_NUKE_NODE_COLORMATRIX: str = """
5863
ColorMatrix {{
5964
inputs 0
6065
matrix {{
61-
{0}
66+
{matrix}
6267
}}
63-
name "{1}"
68+
name "{name}"
6469
selected true
6570
xpos 0
6671
ypos 0
@@ -102,3 +107,74 @@ def pretty(x: Iterable) -> str:
102107
tcl += f" {{{pretty(M[2])}}}"
103108

104109
return tcl
110+
111+
112+
def spimtx_format_matrix(M: ArrayLike, decimals: int = 10) -> str:
113+
"""
114+
Format given matrix as a *Sony* *.spimtx* *LUT* formatted matrix.
115+
116+
Parameters
117+
----------
118+
M
119+
Matrix to format.
120+
decimals
121+
Decimals to use when formatting the matrix.
122+
123+
Returns
124+
-------
125+
:class:`str`
126+
*Sony* *.spimtx* *LUT* formatted matrix.
127+
"""
128+
129+
string = StringIO()
130+
131+
write_LUT_SonySPImtx(LUTOperatorMatrix(M), string, decimals)
132+
133+
return string.getvalue()
134+
135+
136+
TEMPLATE_OCIO_COLORSPACE = """
137+
- !<ColorSpace>
138+
name: Linear {name}
139+
aliases: []
140+
family: Utility
141+
equalitygroup: ""
142+
bitdepth: 32f
143+
description: |
144+
Convert from {input_colourspace} to Linear {output_colourspace}
145+
isdata: false
146+
encoding: scene-linear
147+
allocation: uniform
148+
from_scene_reference: !<GroupTransform>
149+
name: {input_colourspace} to Linear {output_colourspace}
150+
children:
151+
- !<MatrixTransform> {{matrix: {matrix}}}
152+
"""[
153+
1:
154+
]
155+
"""
156+
*OpenColorIO* *ColorSpace* template.
157+
"""
158+
159+
160+
def matrix_3x3_to_4x4(M):
161+
"""
162+
Convert given 3x3 matrix :math:`M` to a raveled 4x4 matrix.
163+
164+
Parameters
165+
----------
166+
M : array_like
167+
3x3 matrix :math:`M` to convert.
168+
169+
Returns
170+
-------
171+
list
172+
Raveled 4x4 matrix.
173+
"""
174+
175+
import numpy as np
176+
177+
M_I = np.identity(4)
178+
M_I[:3, :3] = M
179+
180+
return np.ravel(M_I)

0 commit comments

Comments
 (0)