diff --git a/src/awkward/_v2/operations/structure/ak_without_parameters.py b/src/awkward/_v2/operations/structure/ak_without_parameters.py index 3f7642b2f6..0e42ae2b92 100644 --- a/src/awkward/_v2/operations/structure/ak_without_parameters.py +++ b/src/awkward/_v2/operations/structure/ak_without_parameters.py @@ -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) diff --git a/tests/v2/test_0527-fix-unionarray-ufuncs-and-parameters-in-merging.py b/tests/v2/test_0527-fix-unionarray-ufuncs-and-parameters-in-merging.py index b032525628..8af1108f60 100644 --- a/tests/v2/test_0527-fix-unionarray-ufuncs-and-parameters-in-merging.py +++ b/tests/v2/test_0527-fix-unionarray-ufuncs-and-parameters-in-merging.py @@ -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])