Skip to content

Commit

Permalink
[BugFix] Fixing descriptions of inversed NamedTransforms (#117)
Browse files Browse the repository at this point in the history
* Fixing descriptions of inversed NamedTransforms

Generate the transform description based on the transform's direction.

Resolves: #111

Signed-off-by: Allison Moon <147774452+ajymoonILM@users.noreply.github.com>

* Update addressing KelSolaar's review:
- changing function args from `inverse_direction` (bool) to `direction` (str)

Signed-off-by: Allison Moon <147774452+ajymoonILM@users.noreply.github.com>

* Update addressing KelSolaar's review:
- Case-insensitive check of `direction` args

Signed-off-by: Allison Moon <147774452+ajymoonILM@users.noreply.github.com>

---------

Signed-off-by: Allison Moon <147774452+ajymoonILM@users.noreply.github.com>
  • Loading branch information
ajymoonILM committed Oct 18, 2023
1 parent 1abd145 commit 1dc869d
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions opencolorio_config_aces/config/cg/generate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def clf_transform_to_description(
clf_transform,
describe=DescriptionStyle.LONG_UNION,
amf_components=None,
direction="Forward",
):
"""
Generate the *OpenColorIO* `Colorspace` or `NamedTransform` description for
Expand All @@ -180,6 +181,10 @@ def clf_transform_to_description(
amf_components : mapping, optional
*ACES* *AMF* components used to extend the *ACES* *CTL* transform
description.
direction : str, optional
Direction of transform -- determines order of transform descriptors.
{"Forward", "Reverse"}
Default: "Forward" (i.e., assume 'Forward' direction)
Returns
-------
Expand All @@ -200,10 +205,16 @@ def clf_transform_to_description(
DescriptionStyle.SHORT_UNION,
):
if clf_transform.description is not None:
description.append(
f"Convert {clf_transform.input_descriptor} "
f"to {clf_transform.output_descriptor}"
)
if direction.lower() == "forward":
description.append(
f"Convert {clf_transform.output_descriptor} "
f"to {clf_transform.input_descriptor}"
)
else:
description.append(
f"Convert {clf_transform.input_descriptor} "
f"to {clf_transform.output_descriptor}"
)
elif describe in ( # noqa: SIM102
DescriptionStyle.OPENCOLORIO,
DescriptionStyle.LONG,
Expand Down Expand Up @@ -389,9 +400,6 @@ def clf_transform_to_named_transform(
signature = {
"name": clf_transform_to_colorspace_name(clf_transform),
"family": clf_transform_to_family(clf_transform),
"description": clf_transform_to_description(
clf_transform, describe, amf_components
),
}

file_transform = {
Expand All @@ -401,8 +409,14 @@ def clf_transform_to_named_transform(
}
if is_reference(clf_transform.source):
signature["inverse_transform"] = file_transform
signature["description"] = clf_transform_to_description(
clf_transform, describe, amf_components, direction="Reverse"
)
else:
signature["forward_transform"] = file_transform
signature["description"] = clf_transform_to_description(
clf_transform, describe, amf_components, direction="Forward"
)

signature.update(kwargs)

Expand Down

0 comments on commit 1dc869d

Please sign in to comment.