Skip to content

Commit b053af7

Browse files
committed
Move colour_clf_io.ExponentStyle, colour_clf_io.LogStyle and colour_clf_io.RangeStyle enumerations to colour_clf_io.values module.
1 parent 17400ec commit b053af7

File tree

6 files changed

+206
-207
lines changed

6 files changed

+206
-207
lines changed

colour_clf_io/__init__.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@
3131
Array,
3232
CalibrationInfo,
3333
ExponentParams,
34-
ExponentStyle,
3534
Info,
3635
LogParams,
37-
LogStyle,
38-
RangeStyle,
3936
SatNode,
4037
SOPNode,
4138
)
@@ -51,11 +48,14 @@
5148
Range,
5249
)
5350
from .values import (
54-
ASC_CDL_Style,
51+
ASC_CDLStyle,
5552
BitDepth,
5653
Channel,
54+
ExponentStyle,
5755
Interpolation1D,
5856
Interpolation3D,
57+
LogStyle,
58+
RangeStyle,
5959
)
6060

6161
__author__ = "Colour Developers"
@@ -68,14 +68,11 @@
6868
__all__ = [
6969
"Array",
7070
"CalibrationInfo",
71-
"ExponentParams",
72-
"ExponentStyle",
71+
"SOPNode",
72+
"SatNode",
7373
"Info",
7474
"LogParams",
75-
"LogStyle",
76-
"RangeStyle",
77-
"SatNode",
78-
"SOPNode",
75+
"ExponentParams",
7976
]
8077
__all__ += ["ProcessList"]
8178
__all__ += [
@@ -89,11 +86,14 @@
8986
"Range",
9087
]
9188
__all__ += [
92-
"ASC_CDL_Style",
9389
"BitDepth",
9490
"Channel",
9591
"Interpolation1D",
9692
"Interpolation3D",
93+
"RangeStyle",
94+
"LogStyle",
95+
"ExponentStyle",
96+
"ASC_CDLStyle",
9797
]
9898

9999
__application_name__ = "Colour - CLF IO"

colour_clf_io/elements.py

-173
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from __future__ import annotations
1010

11-
import enum
1211
import typing
1312
from dataclasses import dataclass
1413

@@ -42,9 +41,6 @@
4241
__all__ = [
4342
"Array",
4443
"CalibrationInfo",
45-
"RangeStyle",
46-
"LogStyle",
47-
"ExponentStyle",
4844
"SOPNode",
4945
"SatNode",
5046
"Info",
@@ -232,175 +228,6 @@ def from_xml(
232228
return CalibrationInfo(**attributes)
233229

234230

235-
class RangeStyle(enum.Enum):
236-
"""
237-
Represent the valid values of the *style* attribute of a
238-
:class:`colour_clf_io.Range` *Process Node*.
239-
240-
Attributes
241-
----------
242-
- :attr:`~colour_clf_io.RangeStyle.CLAMP`
243-
- :attr:`~colour_clf_io.RangeStyle.NO_CLAMP`
244-
245-
References
246-
----------
247-
- https://docs.acescentral.com/specifications/clf/#range
248-
"""
249-
250-
CLAMP = "Clamp"
251-
"""
252-
Clamping is applied upon the result of the scale and offset expressed by
253-
the result of the non-clamping Range equation."""
254-
255-
NO_CLAMP = "noClamp"
256-
"""
257-
Scale and offset is applied without clamping (i.e., values below
258-
minOutValue or above maxOutValue are preserved).
259-
"""
260-
261-
262-
class LogStyle(enum.Enum):
263-
"""
264-
Represent the valid values of the *style* attribute of a
265-
:class:`colour_clf_io.Log` *Process Node*.
266-
267-
Attributes
268-
----------
269-
- :attr:`~colour_clf_io.LogStyle.LOG_10`
270-
- :attr:`~colour_clf_io.LogStyle.ANTI_LOG_10`
271-
- :attr:`~colour_clf_io.LogStyle.LOG_2`
272-
- :attr:`~colour_clf_io.LogStyle.ANTI_LOG_2`
273-
- :attr:`~colour_clf_io.LogStyle.LIN_TO_LOG`
274-
- :attr:`~colour_clf_io.LogStyle.LOG_TO_LIN`
275-
- :attr:`~colour_clf_io.LogStyle.CAMERA_LIN_TO_LOG`
276-
- :attr:`~colour_clf_io.LogStyle.CAMERA_LOG_TO_LIN`
277-
278-
References
279-
----------
280-
- https://docs.acescentral.com/specifications/clf/#processList
281-
"""
282-
283-
LOG_10 = "log10"
284-
"""Apply a base 10 logarithm."""
285-
286-
ANTI_LOG_10 = "antiLog10"
287-
"""Apply a base 10 anti-logarithm."""
288-
289-
LOG_2 = "log2"
290-
"""Apply a base 2 logarithm."""
291-
292-
ANTI_LOG_2 = "antiLog2"
293-
"""Apply a base 2 anti-logarithm."""
294-
295-
LIN_TO_LOG = "linToLog"
296-
"""Apply a logarithm."""
297-
298-
LOG_TO_LIN = "logToLin"
299-
"""Apply an anti-logarithm."""
300-
301-
CAMERA_LIN_TO_LOG = "cameraLinToLog"
302-
"""
303-
Apply a piecewise function with logarithmic and linear segments on linear
304-
values, converting them to non-linear values.
305-
"""
306-
307-
CAMERA_LOG_TO_LIN = "cameraLogToLin"
308-
"""
309-
Applies a piecewise function with logarithmic and linear segments on
310-
non-linear values, converting them to linear values.
311-
"""
312-
313-
314-
class ExponentStyle(enum.Enum):
315-
"""
316-
Represent the valid values of the *style* attribute of a
317-
:class:`colour_clf_io.Exponent` *Process Node*.
318-
319-
Attributes
320-
----------
321-
- :attr:`~colour_clf_io.ExponentStyle.BASIC_FWD`
322-
- :attr:`~colour_clf_io.ExponentStyle.BASIC_REV`
323-
- :attr:`~colour_clf_io.ExponentStyle.BASIC_MIRROR_FWD`
324-
- :attr:`~colour_clf_io.ExponentStyle.BASIC_MIRROR_REV`
325-
- :attr:`~colour_clf_io.ExponentStyle.BASIC_PASS_THRU_FWD`
326-
- :attr:`~colour_clf_io.ExponentStyle.BASIC_PASS_THRU_REV`
327-
- :attr:`~colour_clf_io.ExponentStyle.MON_CURVE_FWD`
328-
- :attr:`~colour_clf_io.ExponentStyle.MON_CURVE_REV`
329-
- :attr:`~colour_clf_io.ExponentStyle.MON_CURVE_MIRROR_FWD`
330-
- :attr:`~colour_clf_io.ExponentStyle.MON_CURVE_MIRROR_REV`
331-
332-
References
333-
----------
334-
- https://docs.acescentral.com/specifications/clf/#exponent
335-
"""
336-
337-
BASIC_FWD = "basicFwd"
338-
"""
339-
Apply a power law using the exponent value specified in the ExponentParams
340-
element.
341-
"""
342-
343-
BASIC_REV = "basicRev"
344-
"""
345-
Apply a power law using the exponent value specified in the ExponentParams
346-
element.
347-
"""
348-
349-
BASIC_MIRROR_FWD = "basicMirrorFwd"
350-
"""
351-
Apply a basic power law using the exponent value specified in the
352-
ExponentParams element for values greater than or equal to zero and mirror
353-
the function for values less than zero (i.e., rotationally symmetric around
354-
the origin).
355-
"""
356-
357-
BASIC_MIRROR_REV = "basicMirrorRev"
358-
"""
359-
Apply a basic power law using the exponent value specified in the
360-
ExponentParams element for values greater than or equal to zero and mirror
361-
the function for values less than zero (i.e., rotationally symmetric around
362-
the origin).
363-
"""
364-
365-
BASIC_PASS_THRU_FWD = "basicPassThruFwd" # noqa: S105
366-
"""
367-
Apply a basic power law using the exponent value specified in the
368-
ExponentParams element for values greater than or equal to zero and passes
369-
values less than zero unchanged.
370-
"""
371-
372-
BASIC_PASS_THRU_REV = "basicPassThruRev" # noqa: S105
373-
"""
374-
Apply a basic power law using the exponent value specified in the
375-
ExponentParams element for values greater than or equal to zero and passes
376-
values less than zero unchanged.
377-
"""
378-
379-
MON_CURVE_FWD = "monCurveFwd"
380-
"""
381-
Apply a power law function with a linear segment near the origin.
382-
"""
383-
384-
MON_CURVE_REV = "monCurveRev"
385-
"""
386-
Apply a power law function with a linear segment near the origin.
387-
"""
388-
389-
MON_CURVE_MIRROR_FWD = "monCurveMirrorFwd"
390-
"""
391-
Apply a power law function with a linear segment near the origin and
392-
mirror the function for values less than zero (i.e., rotationally symmetric
393-
around the origin).
394-
"""
395-
396-
MON_CURVE_MIRROR_REV = "monCurveMirrorRev"
397-
"""
398-
Apply a power law function with a linear segment near the origin and mirror
399-
the function for values less than zero (i.e., rotationally symmetric around
400-
the origin).
401-
"""
402-
403-
404231
@dataclass
405232
class SOPNode(XMLParsable):
406233
"""

colour_clf_io/process_nodes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
from colour_clf_io.elements import (
2020
Array,
2121
ExponentParams,
22-
ExponentStyle,
2322
LogParams,
24-
LogStyle,
25-
RangeStyle,
2623
SatNode,
2724
SOPNode,
2825
)
@@ -39,10 +36,13 @@
3936
sliding_window,
4037
)
4138
from colour_clf_io.values import (
42-
ASC_CDL_Style,
39+
ASC_CDLStyle,
4340
BitDepth,
41+
ExponentStyle,
4442
Interpolation1D,
4543
Interpolation3D,
44+
LogStyle,
45+
RangeStyle,
4646
)
4747

4848
__author__ = "Colour Developers"
@@ -677,7 +677,7 @@ class ASC_CDL(ProcessNode):
677677
- https://docs.acescentral.com/specifications/clf/#asc_cdl
678678
"""
679679

680-
style: ASC_CDL_Style
680+
style: ASC_CDLStyle
681681
sopnode: SOPNode | None
682682
sat_node: SatNode | None
683683

@@ -717,7 +717,7 @@ def from_xml(
717717
return None
718718

719719
super_args = ProcessNode.parse_attributes(xml, config)
720-
style = ASC_CDL_Style(xml.get("style"))
720+
style = ASC_CDLStyle(xml.get("style"))
721721
sop_node = SOPNode.from_xml(child_element(xml, "SOPNode", config), config) # pyright: ignore
722722
sat_node = SatNode.from_xml(child_element(xml, "SatNode", config), config) # pyright: ignore
723723

colour_clf_io/tests/test_clf_parsing.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def test_log_example_1(self) -> None:
335335
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f16
336336
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f16
337337
assert node.description == "Base 10 Logarithm"
338-
assert node.style == colour_clf_io.elements.LogStyle.LOG_10
338+
assert node.style == colour_clf_io.values.LogStyle.LOG_10
339339
assert node.log_params == []
340340

341341
def test_log_example_2(self) -> None:
@@ -365,7 +365,7 @@ def test_log_example_2(self) -> None:
365365
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
366366
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
367367
assert node.description == "Linear to DJI D-Log"
368-
assert node.style == colour_clf_io.elements.LogStyle.CAMERA_LIN_TO_LOG
368+
assert node.style == colour_clf_io.values.LogStyle.CAMERA_LIN_TO_LOG
369369
assert node.log_params[0].base is not None
370370
np.testing.assert_allclose(node.log_params[0].base, 10.0)
371371
assert node.log_params[0].log_side_slope is not None
@@ -406,7 +406,7 @@ def test_exponent_example_1(self) -> None:
406406
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
407407
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
408408
assert node.description == "Basic 2.2 Gamma"
409-
assert node.style == colour_clf_io.elements.ExponentStyle.BASIC_FWD
409+
assert node.style == colour_clf_io.values.ExponentStyle.BASIC_FWD
410410
np.testing.assert_allclose(node.exponent_params[0].exponent, 2.2)
411411

412412
def test_exponent_example_2(self) -> None:
@@ -434,7 +434,7 @@ def test_exponent_example_2(self) -> None:
434434
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
435435
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
436436
assert node.description == "EOTF (sRGB)"
437-
assert node.style, colour_clf_io.elements.ExponentStyle.MON_CURVE_FWD
437+
assert node.style, colour_clf_io.values.ExponentStyle.MON_CURVE_FWD
438438
assert node.exponent_params[0].exponent is not None
439439
np.testing.assert_allclose(node.exponent_params[0].exponent, 2.4)
440440
assert node.exponent_params[0].offset is not None
@@ -465,7 +465,7 @@ def test_exponent_example_3(self) -> None:
465465
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
466466
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
467467
assert node.description == "CIE L*"
468-
assert node.style == colour_clf_io.elements.ExponentStyle.MON_CURVE_REV
468+
assert node.style == colour_clf_io.values.ExponentStyle.MON_CURVE_REV
469469
assert node.exponent_params[0].exponent is not None
470470
np.testing.assert_allclose(node.exponent_params[0].exponent, 3.0)
471471
assert node.exponent_params[0].offset is not None
@@ -496,7 +496,7 @@ def test_exponent_example_4(self) -> None:
496496
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
497497
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
498498
assert node.description == "Rec. 709 OETF"
499-
assert node.style == colour_clf_io.elements.ExponentStyle.MON_CURVE_REV
499+
assert node.style == colour_clf_io.values.ExponentStyle.MON_CURVE_REV
500500
assert node.exponent_params[0].exponent is not None
501501
np.testing.assert_allclose(node.exponent_params[0].exponent, 2.2222222222222222)
502502
assert node.exponent_params[0].offset is not None
@@ -534,7 +534,7 @@ def test_ASC_CDL_example(self) -> None:
534534
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f16
535535
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f16
536536
assert node.description == "scene 1 exterior look"
537-
assert node.style == colour_clf_io.values.ASC_CDL_Style.FWD
537+
assert node.style == colour_clf_io.values.ASC_CDLStyle.FWD
538538
assert node.sopnode is not None
539539
assert node.sopnode.slope == (1.000000, 1.000000, 0.900000)
540540
assert node.sopnode.offset == (-0.030000, -0.020000, 0.000000)

0 commit comments

Comments
 (0)