From 7d7d6488f045528858baac38816aecc7a5875f97 Mon Sep 17 00:00:00 2001 From: Michael Mauderer Date: Wed, 29 Jan 2025 14:24:13 +0000 Subject: [PATCH] Fix description attribute to be parsed as list of strings again. --- colour_clf_io/parsing.py | 8 ++------ colour_clf_io/tests/test_clf_parsing.py | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/colour_clf_io/parsing.py b/colour_clf_io/parsing.py index a0fb131..33675c4 100644 --- a/colour_clf_io/parsing.py +++ b/colour_clf_io/parsing.py @@ -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: diff --git a/colour_clf_io/tests/test_clf_parsing.py b/colour_clf_io/tests/test_clf_parsing.py index 43a98be..84e2c97 100644 --- a/colour_clf_io/tests/test_clf_parsing.py +++ b/colour_clf_io/tests/test_clf_parsing.py @@ -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]) ) @@ -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( @@ -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( @@ -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( @@ -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 @@ -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 == [] @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)