Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ refactoring: ak.without_parameters #1297

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions src/awkward/_v2/operations/structure/ak_without_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@


def without_parameters(array, highlevel=True, behavior=None):
raise NotImplementedError

"""
Args:
array: Data convertible into an Awkward Array.
highlevel (bool): If True, return an #ak.Array; otherwise, return
a low-level #ak.layout.Content subclass.
behavior (None or dict): Custom #ak.behavior for the output array, if
high-level.

# """
# Args:
# array: Data convertible into an Awkward Array.
# highlevel (bool): If True, return an #ak.Array; otherwise, return
# a low-level #ak.layout.Content subclass.
# behavior (None or dict): Custom #ak.behavior for the output array, if
# high-level.
This function returns a new array without any parameters in its
#ak.Array.layout, on nodes of any level of depth.

# This function returns a new array without any parameters in its
# #ak.Array.layout, on nodes of any level of depth.
Note that a "new array" is a lightweight shallow copy, not a duplication
of large data buffers.
"""
layout = ak._v2.operations.convert.to_layout(
array, allow_record=True, allow_other=False
)

# Note that a "new array" is a lightweight shallow copy, not a duplication
# of large data buffers.
# """
# layout = ak._v2.operations.convert.to_layout(
# array, allow_record=True, allow_other=False
# )
out = layout.recursively_apply(lambda layout, **kwargs: None, keep_parameters=False)

# out = ak._v2._util.recursively_apply(
# layout, lambda layout: None, pass_depth=False, keep_parameters=False
# )

# return ak._v2._util.maybe_wrap_like(out, array, behavior, highlevel)
return ak._v2._util.wrap(out, behavior, highlevel)
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ def test_0459_types():
array_isdoc
) != ak._v2.operations.describe.type(plain_isdoc)

assert array_plain.layout.parameters == {"__array__": "zoinks"}
assert (
ak._v2.operations.structure.without_parameters(array_plain).layout.parameters
== {}
)
assert plain_isdoc.layout.parameters == {"__doc__": "This is a zoink."}
assert (
ak._v2.operations.structure.without_parameters(plain_isdoc).layout.parameters
== {}
)
assert array_isdoc.layout.parameters == {
"__array__": "zoinks",
"__doc__": "This is a zoink.",
}
assert (
ak._v2.operations.structure.without_parameters(array_isdoc).layout.parameters
== {}
)


def test_0459():
plain_plain = ak._v2.highlevel.Array([0.0, 1.1, 2.2, 3.3, 4.4])
Expand Down