diff --git a/field.py b/field.py index 6fec4010dd7009e6ea3815abba549d36c9cc9f49..b9b6648cf7a4de325314ab397828a91ae7d6378f 100644 --- a/field.py +++ b/field.py @@ -573,6 +573,7 @@ def offset_component_to_direction_string(coordinate_id: int, value: int) -> str: >>> offset_component_to_direction_string(1, 2) '2N' """ + assert 0 <= coordinate_id < 3, "Works only for at most 3D arrays" name_components = (('W', 'E'), # west, east ('S', 'N'), # south, north ('B', 'T')) # bottom, top @@ -600,6 +601,8 @@ def offset_to_direction_string(offsets: Sequence[int]) -> str: >>> offset_to_direction_string(([-3, 0, -2])) '2B3W' """ + if len(offsets) > 3: + return str(offsets) names = ["", "", ""] for i in range(len(offsets)): names[i] = offset_component_to_direction_string(i, offsets[i])