Skip to content

Commit

Permalink
fix: pass a copy of RecordArray's internal fields in HL API
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp committed Aug 30, 2022
1 parent 8da1671 commit 24e687d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/awkward/_v2/operations/ak_fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE

import copy

import awkward as ak

np = ak.nplike.NumpyMetadata.instance()
Expand Down Expand Up @@ -27,4 +29,4 @@ def fields(array):

def _impl(array):
layout = ak._v2.operations.to_layout(array, allow_record=True, allow_other=False)
return layout.fields
return copy.copy(layout.fields)
6 changes: 4 additions & 2 deletions src/awkward/_v2/operations/ak_parameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE

import copy

import awkward as ak

np = ak.nplike.NumpyMetadata.instance()
Expand Down Expand Up @@ -27,13 +29,13 @@ def parameters(array):

def _impl(array):
if isinstance(array, (ak._v2.highlevel.Array, ak._v2.highlevel.Record)):
return array.layout.parameters
return copy.copy(array.layout.parameters)

elif isinstance(
array,
(ak._v2.contents.Content, ak._v2.record.Record),
):
return array.parameters
return copy.copy(array.parameters)

elif isinstance(array, ak._v2.highlevel.ArrayBuilder):
return array.snapshot().layout.parameters
Expand Down

0 comments on commit 24e687d

Please sign in to comment.