Commits


sgilmore10 authored and GitHub committed e14f60b7efd
GH-38398: [MATLAB] Improve array display (#38400) ### Rationale for this change Currently, the display for `arrow.array.Array`s is not very MATLAB-like: ```matlab >> a = arrow.array([1 2 3 4]) a = [ 1, 2, 3, ] ``` At the very least, the display should include the class header and indent each line by 4 spaces. Here's one display option: ```matlab >> a = arrow.array([1 2 3 4]) a = Float64Array with 4 elements and 0 null values: 1 | 2 | 3 | 4 ``` ### What changes are included in this PR? 1. Array display now includes a class header, which states the array type and the number of elements/nulls in the array. 2. Changed the [`window`](https://github.com/apache/arrow/blob/37935604bf168a3b2d52f3cc5b0edf83b5783309/cpp/src/arrow/pretty_print.h#L79C1-L80C1) size to 3 from 10. 3. Primitive and string arrays are displayed horizontally, i.e. set [`skip_new_lines`](https://github.com/apache/arrow/blob/37935604bf168a3b2d52f3cc5b0edf83b5783309/cpp/src/arrow/pretty_print.h#L90) to `false`. Uses ` | ` as the delimiter between elements with no opening/closing brackets. 4. All other array types (`struct`, `list`, etc) are displayed vertically with an `indent` of 4. **Example String Array Display:** ```matlab >> a = arrow.array(["Hello", missing, "Bye"]) a = StringArray with 3 elements and 1 null value: "Hello" | null | "Bye" ``` **Example Struct Array Display:** ```matlab >> a1 = arrow.array(["Hello", missing, "Bye"]); >> a2 = arrow.array([1 2 3]); >> structArray = arrow.array.StructArray.fromArrays(a1, a2) structArray = StructArray with 3 elements and 0 null values: -- is_valid: all not null -- child 0 type: string [ "Hello", null, "Bye" ] -- child 1 type: double [ 1, 2, 3 ] ``` ### Are these changes tested? Yes. Added a new test class called `tArrayDisplay.m` with unit tests for array display. ### Are there any user-facing changes? Yes. Users will see a different display for arrays now. ### Future Directions 1. #38166 * Closes: #38398 Lead-authored-by: Sarah Gilmore <sgilmore@mathworks.com> Co-authored-by: sgilmore10 <74676073+sgilmore10@users.noreply.github.com> Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>