Skip to content

Commit

Permalink
Fix description attribute to be parsed as list of strings again.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMauderer committed Jan 29, 2025
1 parent a54e39c commit 7d7d648
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
8 changes: 2 additions & 6 deletions colour_clf_io/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,8 @@ def elements_as_text_list(
representation of a child element.
"""

if config.clf_namespace_prefix_mapping():
return xml.xpath( # pyright: ignore
f"clf:{name}/text()", namespaces=config.clf_namespace_prefix_mapping()
)

return xml.xpath(f"{name}/text()") # pyright: ignore
elements = child_elements(xml, name, config)
return [element.text for element in elements if element.text is not None]


def sliding_window(iterable: Iterable, n: int) -> Iterable:
Expand Down
24 changes: 12 additions & 12 deletions colour_clf_io/tests/test_clf_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_LUT1D_example(self) -> None:
assert node.name == "4 Value Lut"
assert node.in_bit_depth == colour_clf_io.values.BitDepth.i12
assert node.out_bit_depth == colour_clf_io.values.BitDepth.i12
assert node.description == "1D LUT - Turn 4 grey levels into 4 inverted codes"
assert node.description == ["1D LUT - Turn 4 grey levels into 4 inverted codes"]
np.testing.assert_array_almost_equal(
node.array.as_array(), np.array([3, 2, 1, 0])
)
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_LUT3D_example(self) -> None:
assert node.in_bit_depth == colour_clf_io.values.BitDepth.i12
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f16
assert node.interpolation == colour_clf_io.values.Interpolation3D.TRILINEAR
assert node.description == "3D LUT"
assert node.description == ["3D LUT"]
np.testing.assert_array_almost_equal(
node.array.as_array(),
np.array(
Expand Down Expand Up @@ -212,7 +212,7 @@ def test_matrix_example_1(self) -> None:
assert node.name == "AP0 to AP1"
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f16
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f16
assert node.description == "3x3 color space conversion from AP0 to AP1"
assert node.description == ["3x3 color space conversion from AP0 to AP1"]
np.testing.assert_array_almost_equal(
node.array.as_array(),
np.array(
Expand Down Expand Up @@ -252,7 +252,7 @@ def test_matrix_example_2(self) -> None:
assert node.name == "colorspace conversion"
assert node.in_bit_depth == colour_clf_io.values.BitDepth.i10
assert node.out_bit_depth == colour_clf_io.values.BitDepth.i10
assert node.description == " 3x4 Matrix , 4th column is offset "
assert node.description == [" 3x4 Matrix , 4th column is offset "]
np.testing.assert_array_almost_equal(
node.array.as_array(),
np.array(
Expand Down Expand Up @@ -306,7 +306,7 @@ def test_range_example(self) -> None:
assert node.name is None
assert node.in_bit_depth == colour_clf_io.values.BitDepth.i10
assert node.out_bit_depth == colour_clf_io.values.BitDepth.i10
assert node.description == "10-bit full range to SMPTE range"
assert node.description == ["10-bit full range to SMPTE range"]
assert node.min_in_value == 0.0
assert node.min_out_value == 64.0
assert node.max_out_value == 940.0
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_log_example_1(self) -> None:
assert node.name is None
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f16
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f16
assert node.description == "Base 10 Logarithm"
assert node.description == ["Base 10 Logarithm"]
assert node.style == colour_clf_io.values.LogStyle.LOG_10
assert node.log_params == []

Expand Down Expand Up @@ -364,7 +364,7 @@ def test_log_example_2(self) -> None:
assert node.name is None
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.description == "Linear to DJI D-Log"
assert node.description == ["Linear to DJI D-Log"]
assert node.style == colour_clf_io.values.LogStyle.CAMERA_LIN_TO_LOG
assert node.log_params[0].base is not None
np.testing.assert_allclose(node.log_params[0].base, 10.0)
Expand Down Expand Up @@ -405,7 +405,7 @@ def test_exponent_example_1(self) -> None:
assert node.name is None
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.description == "Basic 2.2 Gamma"
assert node.description == ["Basic 2.2 Gamma"]
assert node.style == colour_clf_io.values.ExponentStyle.BASIC_FWD
np.testing.assert_allclose(node.exponent_params[0].exponent, 2.2)

Expand Down Expand Up @@ -433,7 +433,7 @@ def test_exponent_example_2(self) -> None:
assert node.name is None
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.description == "EOTF (sRGB)"
assert node.description == ["EOTF (sRGB)"]
assert node.style, colour_clf_io.values.ExponentStyle.MON_CURVE_FWD
assert node.exponent_params[0].exponent is not None
np.testing.assert_allclose(node.exponent_params[0].exponent, 2.4)
Expand Down Expand Up @@ -464,7 +464,7 @@ def test_exponent_example_3(self) -> None:
assert node.name is None
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.description == "CIE L*"
assert node.description == ["CIE L*"]
assert node.style == colour_clf_io.values.ExponentStyle.MON_CURVE_REV
assert node.exponent_params[0].exponent is not None
np.testing.assert_allclose(node.exponent_params[0].exponent, 3.0)
Expand Down Expand Up @@ -495,7 +495,7 @@ def test_exponent_example_4(self) -> None:
assert node.name is None
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f32
assert node.description == "Rec. 709 OETF"
assert node.description == ["Rec. 709 OETF"]
assert node.style == colour_clf_io.values.ExponentStyle.MON_CURVE_REV
assert node.exponent_params[0].exponent is not None
np.testing.assert_allclose(node.exponent_params[0].exponent, 2.2222222222222222)
Expand Down Expand Up @@ -533,7 +533,7 @@ def test_ASC_CDL_example(self) -> None:
assert node.name is None
assert node.in_bit_depth == colour_clf_io.values.BitDepth.f16
assert node.out_bit_depth == colour_clf_io.values.BitDepth.f16
assert node.description == "scene 1 exterior look"
assert node.description == ["scene 1 exterior look"]
assert node.style == colour_clf_io.values.ASC_CDLStyle.FWD
assert node.sopnode is not None
assert node.sopnode.slope == (1.000000, 1.000000, 0.900000)
Expand Down

0 comments on commit 7d7d648

Please sign in to comment.