Skip to content

Commit

Permalink
fix doc strings and remove obsolete functions in _namedaxis.py module
Browse files Browse the repository at this point in the history
  • Loading branch information
pfackeldey committed Sep 23, 2024
1 parent c970d06 commit f5f9495
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 63 deletions.
42 changes: 0 additions & 42 deletions src/awkward/_namedaxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ def _get_named_axis(
return {}


def _supports_named_axis(ctx: MaybeSupportsNamedAxis | AttrsNamedAxisMapping) -> bool:
"""Check if the given ctx supports named axis.
Args:
ctx (SupportsNamedAxis or AttrsNamedAxisMapping): The ctx to check.
Returns:
bool: True if the ctx supports named axis, False otherwise.
"""
return bool(_get_named_axis(ctx))


def _make_positional_axis_tuple(n: int) -> tuple[int, ...]:
"""
Generates a positional axis tuple of length n.
Expand Down Expand Up @@ -112,8 +100,6 @@ def _is_valid_named_axis(axis: AxisName) -> bool:
Examples:
>>> _is_valid_named_axis("x")
True
>>> _is_valid_named_axis(NamedAxisMarker())
True
>>> _is_valid_named_axis(1)
False
"""
Expand Down Expand Up @@ -288,9 +274,6 @@ def _set_named_axis_to_attrs(
# - "remove one" (_remove_named_axis): Remove the named axis from the output array, e.g.: `ak.sum`
# - "add one" (_add_named_axis): Add a new named axis to the output array, e.g.: `ak.concatenate, ak.singletons` (not clear yet...)
# - "unify" (_unify_named_axis): Unify the named axis in the output array given two input arrays, e.g.: `__add__`
# - "collapse" (_collapse_named_axis): Collapse multiple named axis to None in the output array, e.g.: `ak.flatten`
# - "permute" (_permute_named_axis): Permute the named axis in the output array, e.g.: `ak.transpose` (does this exist?)
# - "contract" (_contract_named_axis): Contract the named axis in the output array, e.g.: `matmul` (does this exist?)


def _keep_named_axis(
Expand Down Expand Up @@ -525,13 +508,6 @@ def _add_named_axis(
return out


def _permute_named_axis(
axis: int,
named_axis: AxisTuple,
) -> AxisTuple:
raise NotImplementedError()


def _unify_named_axis(
named_axis1: AxisMapping,
named_axis2: AxisMapping,
Expand Down Expand Up @@ -602,24 +578,6 @@ def _get_axis_name(
return unified_named_axis


def _collapse_named_axis(
named_axis: AxisMapping,
axis: tuple[int, ...] | int | None,
) -> AxisMapping:
"""
Determines the new named axis after collapsing the specified axis. This is useful, for example,
when applying a flatten operation along an axis.
Args:
axis (tuple[int, ...] | int | None): The index of the axis to collapse. If None, all axes are collapsed.
named_axis (AxisMapping): The current named axis.
Returns:
AxisMapping: The new named axis after collapsing the specified axis.
"""
raise NotImplementedError()


class Slicer:
"""
Provides a more convenient syntax for slicing.
Expand Down
10 changes: 1 addition & 9 deletions src/awkward/operations/ak_with_named_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,7 @@ def with_named_axis(
Returns an #ak.Array or #ak.Record (or low-level equivalent, if
`highlevel=False`) with a new name. This function does not change the
array in-place. If the new name is None, then an array without a name is
returned.
The records or tuples may be nested within multiple levels of nested lists.
If records are nested within records, only the outermost are affected.
Setting the `"__record__"` parameter makes it possible to add behaviors
to the data; see #ak.Array and #ak.behavior for a more complete
description.
array in-place. If the new name is None, then the array is returned as it is.
"""
# Dispatch
yield (array,)
Expand Down
14 changes: 2 additions & 12 deletions src/awkward/operations/ak_without_named_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def without_named_axis(
"""
Args:
array: Array-like data (anything #ak.to_layout recognizes).
named_axis: AxisTuple | AxisMapping: Names to give to the array axis; this assigns
the `"__named_axis__"` attr. If None, any existing name is unset.
highlevel (bool): If True, return an #ak.Array; otherwise, return
a low-level #ak.contents.Content subclass.
behavior (None or dict): Custom #ak.behavior for the output array, if
Expand All @@ -35,16 +33,8 @@ def without_named_axis(
high-level.
Returns an #ak.Array or #ak.Record (or low-level equivalent, if
`highlevel=False`) with a new name. This function does not change the
array in-place. If the new name is None, then an array without a name is
returned.
The records or tuples may be nested within multiple levels of nested lists.
If records are nested within records, only the outermost are affected.
Setting the `"__record__"` parameter makes it possible to add behaviors
to the data; see #ak.Array and #ak.behavior for a more complete
description.
`highlevel=False`) without named axes. This function does not change the
array in-place.
"""
# Dispatch
yield (array,)
Expand Down

0 comments on commit f5f9495

Please sign in to comment.