Skip to content

Commit

Permalink
adds lenient to symmetry_mode handling
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Feb 28, 2024
1 parent bd21e28 commit 9e6b9c4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions dcm/dcm_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ def calculate_sub_segments(
parent_segment: DonutSegment,
level_name: str,
symmetry_mode: str,
elements: List[CompetenceElement]
elements: List[CompetenceElement],
lenient:bool=True
) -> Dict[str, DonutSegment]:
"""
Calculates and returns a dictionary of DonutSegment objects for a given level in the Competence Tree.
Expand All @@ -371,7 +372,7 @@ def calculate_sub_segments(
level_name: The name of the level (e.g., 'aspect', 'area', 'facet') for which sub-segments are being calculated.
symmetry_mode: The symmetry mode ('symmetric' or 'asymmetric') affecting segment calculation.
elements: A list of CompetenceElement instances at the current level.
lenient (bool): if True symmetry mode will be adjusted to count in case there are no values
Returns:
A dictionary where keys are element paths and values are DonutSegment instances representing each element's segment in the visualization.
"""
Expand Down Expand Up @@ -403,7 +404,13 @@ def calculate_sub_segments(
min_value = value

if total == 0 and num_zero_none_values == len(elements):
raise ValueError("All element values are 0 or None, cannot divide segment.")
if not lenient:
raise ValueError("All element values are 0 or None, cannot divide segment.")
else:
# robust reaction on issue
symmetry_mode="count"
num_zero_none_values=0
total = len(elements)

# Correct handling when all values are not 0/None
# and therefore min_value was not updated
Expand Down

0 comments on commit 9e6b9c4

Please sign in to comment.