Skip to content

Commit

Permalink
named_axis: improve doc string of _prettify_named_axes
Browse files Browse the repository at this point in the history
  • Loading branch information
pfackeldey committed Oct 8, 2024
1 parent f515ea7 commit 413c86c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/awkward/_namedaxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def _prettify_named_axes(
maxlen: None | int = None,
) -> str:
"""
Prettifies the named axes for better readability.
This function takes a named axis mapping and returns a string representation of the mapping.
The axis names are sorted in ascending order of their corresponding integer values.
If the axis name is a valid Python identifier, it is represented as is.
Otherwise, it is represented as a JSON string.
Args:
named_axis (AxisMapping): The named axis mapping to prettify.
delimiter (str, optional): The delimiter to use between items in the output string. Defaults to ", ".
maxlen (None | int, optional): The maximum length of the output string. If the string exceeds this length, it is truncated and ends with "...". Defaults to None.
Returns:
str: The prettified string representation of the named axis mapping.
Expand All @@ -65,6 +65,10 @@ def _prettify_named_axes(
'x:0, y:1, z:2'
>>> _prettify_named_axes({"x": 0, "y": 1, "$": 2})
'x:0, y:1, "$":2'
>>> _prettify_named_axes({"x": 0, "y": 1, "z": 2}, delimiter="; ")
'x:0; y:1; z:2'
>>> _prettify_named_axes({"foo": 0, "bar": 1, "baz": 2}, maxlen=17)
'foo:0, bar:1, ...'
"""

def _prettify(ax: AxisName) -> str:
Expand Down

0 comments on commit 413c86c

Please sign in to comment.