Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pyrecest/evaluation/get_axis_label.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
def _normalize_manifold_name(manifold_name):
if not isinstance(manifold_name, str) or not manifold_name.strip():
raise ValueError("manifold_name must be a non-empty string")
return manifold_name.strip().lower()


def get_axis_label(manifold_name):
normalized_name = manifold_name.lower()
normalized_name = _normalize_manifold_name(manifold_name)

if "circlesymm" in normalized_name:
error_label = "Error in radian"
Expand Down
10 changes: 10 additions & 0 deletions tests/test_axis_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ def test_specific_manifolds_are_not_shadowed_by_generic_substrings(
)
def test_generic_manifold_axis_labels_are_preserved(manifold_name, expected_label):
assert get_axis_label(manifold_name) == expected_label


@pytest.mark.parametrize("manifold_name", [None, "", " "])
def test_axis_label_rejects_invalid_manifold_names(manifold_name):
with pytest.raises(ValueError, match="manifold_name must be a non-empty string"):
get_axis_label(manifold_name)


def test_axis_label_strips_manifold_name_whitespace():
assert get_axis_label(" hypersphere ") == "Error (orthodromic distance) in radian"
Loading