Skip to content

Commit 1dc869d

Browse files
authored
[BugFix] Fixing descriptions of inversed NamedTransforms (#117)
* Fixing descriptions of inversed NamedTransforms Generate the transform description based on the transform's direction. Resolves: #111 Signed-off-by: Allison Moon <[email protected]> * Update addressing KelSolaar's review: - changing function args from `inverse_direction` (bool) to `direction` (str) Signed-off-by: Allison Moon <[email protected]> * Update addressing KelSolaar's review: - Case-insensitive check of `direction` args Signed-off-by: Allison Moon <[email protected]> --------- Signed-off-by: Allison Moon <[email protected]>
1 parent 1abd145 commit 1dc869d

File tree

1 file changed

+21
-7
lines changed
  • opencolorio_config_aces/config/cg/generate

1 file changed

+21
-7
lines changed

opencolorio_config_aces/config/cg/generate/config.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def clf_transform_to_description(
165165
clf_transform,
166166
describe=DescriptionStyle.LONG_UNION,
167167
amf_components=None,
168+
direction="Forward",
168169
):
169170
"""
170171
Generate the *OpenColorIO* `Colorspace` or `NamedTransform` description for
@@ -180,6 +181,10 @@ def clf_transform_to_description(
180181
amf_components : mapping, optional
181182
*ACES* *AMF* components used to extend the *ACES* *CTL* transform
182183
description.
184+
direction : str, optional
185+
Direction of transform -- determines order of transform descriptors.
186+
{"Forward", "Reverse"}
187+
Default: "Forward" (i.e., assume 'Forward' direction)
183188
184189
Returns
185190
-------
@@ -200,10 +205,16 @@ def clf_transform_to_description(
200205
DescriptionStyle.SHORT_UNION,
201206
):
202207
if clf_transform.description is not None:
203-
description.append(
204-
f"Convert {clf_transform.input_descriptor} "
205-
f"to {clf_transform.output_descriptor}"
206-
)
208+
if direction.lower() == "forward":
209+
description.append(
210+
f"Convert {clf_transform.output_descriptor} "
211+
f"to {clf_transform.input_descriptor}"
212+
)
213+
else:
214+
description.append(
215+
f"Convert {clf_transform.input_descriptor} "
216+
f"to {clf_transform.output_descriptor}"
217+
)
207218
elif describe in ( # noqa: SIM102
208219
DescriptionStyle.OPENCOLORIO,
209220
DescriptionStyle.LONG,
@@ -389,9 +400,6 @@ def clf_transform_to_named_transform(
389400
signature = {
390401
"name": clf_transform_to_colorspace_name(clf_transform),
391402
"family": clf_transform_to_family(clf_transform),
392-
"description": clf_transform_to_description(
393-
clf_transform, describe, amf_components
394-
),
395403
}
396404

397405
file_transform = {
@@ -401,8 +409,14 @@ def clf_transform_to_named_transform(
401409
}
402410
if is_reference(clf_transform.source):
403411
signature["inverse_transform"] = file_transform
412+
signature["description"] = clf_transform_to_description(
413+
clf_transform, describe, amf_components, direction="Reverse"
414+
)
404415
else:
405416
signature["forward_transform"] = file_transform
417+
signature["description"] = clf_transform_to_description(
418+
clf_transform, describe, amf_components, direction="Forward"
419+
)
406420

407421
signature.update(kwargs)
408422

0 commit comments

Comments
 (0)