Skip to content

Commit

Permalink
feat: Adding awkward.semipublic submodule (#3152)
Browse files Browse the repository at this point in the history
* Renaming _prettyprint to prettyprint (no longer private)

* _prettyprint remains as a deprecated submodule

* highlevel.py: removing unnecessary prettyprint imports

* Fixing (deprecated) _prettyprint with explicit imports.

* Putting remove_structure in contents.remove_structure submodule.

Also adding a unit test for this and prettyprint.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
tcawlfield and pre-commit-ci[bot] authored Jun 18, 2024
1 parent ef1e851 commit 02858f8
Show file tree
Hide file tree
Showing 7 changed files with 554 additions and 491 deletions.
39 changes: 1 addition & 38 deletions src/awkward/_do.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from awkward._nplikes.numpy_like import NumpyMetadata
from awkward._typing import Any, AxisMaybeNone, Literal
from awkward.contents.content import ActionType, Content
from awkward.contents.remove_structure import remove_structure
from awkward.errors import AxisError
from awkward.forms import form
from awkward.record import Record
Expand Down Expand Up @@ -191,44 +192,6 @@ def pad_none(
return layout._pad_none(length, axis, 1, clip)


def remove_structure(
layout: Content | Record,
backend: Backend | None = None,
flatten_records: bool = True,
function_name: str | None = None,
drop_nones: bool = True,
keepdims: bool = False,
allow_records: bool = False,
list_to_regular: bool = False,
):
if isinstance(layout, Record):
return remove_structure(
layout._array[layout._at : layout._at + 1],
backend,
flatten_records,
function_name,
drop_nones,
keepdims,
allow_records,
)

else:
if backend is None:
backend = layout._backend
arrays = layout._remove_structure(
backend,
{
"flatten_records": flatten_records,
"function_name": function_name,
"drop_nones": drop_nones,
"keepdims": keepdims,
"allow_records": allow_records,
"list_to_regular": list_to_regular,
},
)
return tuple(arrays)


def flatten(layout: Content, axis: int = 1) -> Content:
offsets, flattened = layout._offsets_and_flattened(axis, 1)
return flattened
Expand Down
Loading

0 comments on commit 02858f8

Please sign in to comment.