From 463e7e2bfc3e4cec5c3fb48fbc20fb30140a9577 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Tue, 27 Sep 2022 18:03:05 +0200 Subject: [PATCH] fix: Record is not in contents, but in record --- src/awkward/highlevel.py | 12 ++++++------ src/awkward/nplike.py | 8 ++++---- src/awkward/operations/ak_from_iter.py | 2 +- src/awkward/operations/ak_is_tuple.py | 2 +- src/awkward/operations/ak_is_valid.py | 2 +- src/awkward/operations/ak_packed.py | 2 +- src/awkward/operations/ak_to_layout.py | 8 ++++---- src/awkward/operations/ak_validity_error.py | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/awkward/highlevel.py b/src/awkward/highlevel.py index b82f0c84ed..8cea367708 100644 --- a/src/awkward/highlevel.py +++ b/src/awkward/highlevel.py @@ -1451,7 +1451,7 @@ def _jax_unflatten(cls, aux_data, children): class Record(NDArrayOperatorsMixin): """ Args: - data (#ak.contents.Record, #ak.Record, str, or dict): + data (#ak.record.Record, #ak.Record, str, or dict): Data to wrap or convert into a record. If a string, the data are assumed to be JSON. If a dict, calls #ak.from_iter, which assumes all inner @@ -1532,19 +1532,19 @@ def __init__( @property def layout(self): """ - The #ak.contents.Record that contains composable #ak.contents.Content + The #ak.record.Record that contains composable #ak.contents.Content elements to determine how the array is structured. See #ak.Array.layout for a more complete description. - The #ak.contents.Record is not a subclass of #ak.contents.Content in + The #ak.record.Record is not a subclass of #ak.contents.Content in Python (note: [Record](../_static/classawkward_1_1Record.html) *is* a subclass of [Content](../_static/classawkward_1_1Content.html) in - C++!) and it is not composable with them: #ak.contents.Record contains + C++!) and it is not composable with them: #ak.record.Record contains one #ak.contents.RecordArray (which is a #ak.contents.Content), but - #ak.contents.Content nodes cannot contain a #ak.contents.Record. + #ak.contents.Content nodes cannot contain a #ak.record.Record. - A #ak.contents.Record is not an independent entity from its + A #ak.record.Record is not an independent entity from its #ak.contents.RecordArray; it's really just a marker indicating which element to select. The XML representation reflects that: diff --git a/src/awkward/nplike.py b/src/awkward/nplike.py index ed76d2588d..4aa63db4b9 100644 --- a/src/awkward/nplike.py +++ b/src/awkward/nplike.py @@ -566,7 +566,7 @@ def asarray(self, array, dtype=None, order=None): ak.highlevel.Array, ak.highlevel.Record, ak.contents.Content, - ak.contents.Record, + ak.record.Record, ), ): out = ak.operations.ak_to_cupy.to_cupy(array) @@ -600,7 +600,7 @@ def ascontiguousarray(self, array, dtype=None): ak.highlevel.Array, ak.highlevel.Record, ak.contents.Content, - ak.contents.Record, + ak.record.Record, ), ): out = ak.operations.ak_to_cupy.to_cupy(array) @@ -730,7 +730,7 @@ def to_rectilinear(self, array, *args, **kwargs): ak.Record, ak.ArrayBuilder, ak.contents.Content, - ak.contents.Record, + ak.record.Record, ak._ext.ArrayBuilder, ), ): @@ -782,7 +782,7 @@ def ascontiguousarray(self, array, dtype=None): ak.highlevel.Array, ak.highlevel.Record, ak.contents.Content, - ak.contents.Record, + ak.record.Record, ), ): out = ak.operations.ak_to_jax.to_jax(array) diff --git a/src/awkward/operations/ak_from_iter.py b/src/awkward/operations/ak_from_iter.py index 24ca08a0d8..9e363fd86a 100644 --- a/src/awkward/operations/ak_from_iter.py +++ b/src/awkward/operations/ak_from_iter.py @@ -16,7 +16,7 @@ def from_iter( behavior (None or dict): Custom #ak.behavior for the output array, if high-level. allow_record (bool): If True, the outermost element may be a record - (returning #ak.Record or #ak.contents.Record type, depending on + (returning #ak.Record or #ak.record.Record type, depending on `highlevel`); if False, the outermost element must be an array. initial (int): Initial size (in bytes) of buffers used by the [ak::ArrayBuilder](_static/classawkward_1_1ArrayBuilder.html). diff --git a/src/awkward/operations/ak_is_tuple.py b/src/awkward/operations/ak_is_tuple.py index 0238e50f7e..b6ec64e873 100644 --- a/src/awkward/operations/ak_is_tuple.py +++ b/src/awkward/operations/ak_is_tuple.py @@ -6,7 +6,7 @@ def is_tuple(array): """ Args: - array (#ak.Array, #ak.Record, #ak.contents.Content, #ak.contents.Record, #ak.ArrayBuilder): + array (#ak.Array, #ak.Record, #ak.contents.Content, #ak.record.Record, #ak.ArrayBuilder): Array or record to check. If `array` is a record, this returns True if the record is a tuple. diff --git a/src/awkward/operations/ak_is_valid.py b/src/awkward/operations/ak_is_valid.py index 915c500c43..d8b56d834f 100644 --- a/src/awkward/operations/ak_is_valid.py +++ b/src/awkward/operations/ak_is_valid.py @@ -6,7 +6,7 @@ def is_valid(array, exception=False): """ Args: - array (#ak.Array, #ak.Record, #ak.contents.Content, #ak.contents.Record, #ak.ArrayBuilder): + array (#ak.Array, #ak.Record, #ak.contents.Content, #ak.record.Record, #ak.ArrayBuilder): Array or record to check. exception (bool): If True, validity errors raise exceptions. diff --git a/src/awkward/operations/ak_packed.py b/src/awkward/operations/ak_packed.py index 38f6734f0d..c4a202edba 100644 --- a/src/awkward/operations/ak_packed.py +++ b/src/awkward/operations/ak_packed.py @@ -26,7 +26,7 @@ def packed(array, highlevel=True, behavior=None): - #ak.contents.ByteMaskedArray becomes an #ak.contents.IndexedOptionArray if it contains records, stays a #ak.contents.ByteMaskedArray otherwise - #ak.contents.BitMaskedArray becomes an #ak.contents.IndexedOptionArray if it contains records, stays a #ak.contents.BitMaskedArray otherwise - #ak.contents.UnionArray gets projected contents - - #ak.contents.Record becomes a record over a single-item #ak.contents.RecordArray + - #ak.record.Record becomes a record over a single-item #ak.contents.RecordArray Example: diff --git a/src/awkward/operations/ak_to_layout.py b/src/awkward/operations/ak_to_layout.py index 825983662a..efe5ed6935 100644 --- a/src/awkward/operations/ak_to_layout.py +++ b/src/awkward/operations/ak_to_layout.py @@ -17,20 +17,20 @@ def to_layout( """ Args: array: Data to convert into a low-level #ak.contents.Content layout - or maybe #ak.contents.Record, its record equivalent, or other types. - allow_record (bool): If True, allow #ak.contents.Record as an output; + or maybe #ak.record.Record, its record equivalent, or other types. + allow_record (bool): If True, allow #ak.record.Record as an output; otherwise, if the output would be a scalar record, raise an error. allow_other (bool): If True, allow non-Awkward outputs; otherwise, if the output would be another type, raise an error. numpytype (tuple of NumPy types): Dtypes to allow from NumPy arrays. Converts `array` (many types supported, including all Awkward Arrays and - Records) into a #ak.contents.Content and maybe #ak.contents.Record or + Records) into a #ak.contents.Content and maybe #ak.record.Record or other types. This function is usually used to sanitize inputs for other functions; it would rarely be used in a data analysis because #ak.contents.Content and - #ak.contents.Record are lower-level than #ak.Array. + #ak.record.Record are lower-level than #ak.Array. """ with ak._util.OperationErrorContext( "ak.to_layout", diff --git a/src/awkward/operations/ak_validity_error.py b/src/awkward/operations/ak_validity_error.py index 73a4e54753..ccf5b4859f 100644 --- a/src/awkward/operations/ak_validity_error.py +++ b/src/awkward/operations/ak_validity_error.py @@ -6,7 +6,7 @@ def validity_error(array, exception=False): """ Args: - array (#ak.Array, #ak.Record, #ak.contents.Content, #ak.contents.Record, #ak.ArrayBuilder): + array (#ak.Array, #ak.Record, #ak.contents.Content, #ak.record.Record, #ak.ArrayBuilder): Array or record to check. exception (bool): If True, validity errors raise exceptions.