Skip to content

Commit

Permalink
Various message fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ansaminard committed Dec 9, 2024
1 parent ed1677f commit 9c30b8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/ansys/sound/core/sound_composer/source_harmonics.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __str__(self) -> str:
f"{self.source_control.control.time_freq_support.time_frequencies.data[-1]} s"
)
else:
str_source_control = "Not set"
str_source_control = "Not set/valid"

return f"Harmonics source: {str_source}\nSource control: {str_source_control}"

Expand Down Expand Up @@ -170,10 +170,11 @@ def source_harmonics(self, source: FieldsContainer):
support_data = source.get_support("control_parameter_1")
support_properties = support_data.available_field_supported_properties()
support_values = support_data.field_support_by_property(support_properties[0])
if len(support_values) < 1:
if len(support_values) != len(source):
raise PyAnsysSoundException(
"Control data in the specified harmonics source must contain at least "
"one element."
"Harmonics source must contain the same number of order levels and associated "
"control parameter values (the number of fields should be the same as the "
"number of support values, in the provided DPF fields container)."
)

self.__source_harmonics = source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
EXP_ORDER_LEVEL03_REF = 3.041734453290701e-05
EXP_ORDER_LEVEL03_PA = 3.041734453290701e-05
EXP_ORDER_LEVEL03_XML = 5.632353957971172e-19
EXP_STR_NOT_SET = "Harmonics source: Not set\nSource control: Not set"
EXP_STR_NOT_SET = "Harmonics source: Not set\nSource control: Not set/valid"
EXP_STR_ALL_SET = (
"Harmonics source: ''\n"
"\tNumber of orders: 5\n"
Expand Down Expand Up @@ -193,7 +193,11 @@ def test_source_harmonics_properties_exceptions(dpf_sound_test_server):
fc_source_harmonics = source_harmonics_obj.source_harmonics
with pytest.raises(
PyAnsysSoundException,
match="Control data in the specified harmonics source must contain at least one element.",
match=(
"Harmonics source must contain the same number of order levels and associated control "
"parameter values \\(the number of fields should be the same as the number of support "
"values, in the provided DPF fields container\\)."
),
):
source_harmonics_obj.source_harmonics = fc_source_harmonics

Expand Down Expand Up @@ -227,7 +231,7 @@ def test_source_harmonics_is_source_control_valid(dpf_sound_test_server):
assert source_harmonics_obj.is_source_control_valid() is True


def test_source_specrum_load_source_harmonics(dpf_sound_test_server):
def test_source_harmonics_load_source_harmonics(dpf_sound_test_server):
"""Test SourceHarmonics load_source_harmonics method."""
source_harmonics_obj = SourceHarmonics()

Expand Down

0 comments on commit 9c30b8e

Please sign in to comment.