forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…7826) ### Rationale for this change We should improve the display of `arrow.type.Field`, which currently looks like this: ```matlab >> arrow.field("A", arrow.int32()) ans = A: int32 ``` This display isn't very "MATLAB-like". For instance, it doesn't display the object's class type. This display would be better: ```matlab >> arrow.field("A", arrow.int32()) ans = Field with properties: Name: "A" Type: [1x1 arrow.type.Int32Type] ``` ### What changes are included in this PR? 1. Added `getPropertyGroups` method to `Field`. This method is inherited from the superclass `matlab.mixin.CustomDisplay`. 2. Removed `displayScalarObject` method from `Field`. This method is also inherited from `matlab.mixin.CustomDisplay`. By implementing `getPropertyGroups`, we no longer need to override `displayScalarObject` and can use the default implementation of this method in `CustomDisplay`. 3. Removed `toString()` method from `Field`. This method was private, and only used by `displayScalarObject`. Since `displayScalarObject` has been removed, `toString()` can be deleted too. 4. Converted the helper test methods (`makeLinkString`, `makeDimensionString`, `verifyDisplay`) in `tTypeDisplay` into standalone functions. Test classes other than `tTypeDisplay.m` can now use these utilities as well. ### Are these changes tested? Yes. Added a `TestDisplay` unit test to `tField.m`. ### Are there any user-facing changes? Yes. `arrow.type.Field` objects are now displayed differently in the Command Window. ### Future Directions 1. Update the display of `arrow.tabular.Schema`. 2. Update the display of `arrow.array.Array`. 3. Update the display of `arrow.tabular.Table`. 4. Update the display of `arrow.tabular.RecordBatch`. * Closes: apache#37825 Authored-by: Sarah Gilmore <[email protected]> Signed-off-by: Kevin Gurney <[email protected]>
- Loading branch information
1 parent
605b070
commit dd9f1c9
Showing
8 changed files
with
157 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
matlab/src/matlab/+arrow/+internal/+test/+display/makeDimensionString.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
%MAKEDIMENSIONSTRING Utility function for creating a string representation | ||
%of dimensions. | ||
|
||
% Licensed to the Apache Software Foundation (ASF) under one or more | ||
% contributor license agreements. See the NOTICE file distributed with | ||
% this work for additional information regarding copyright ownership. | ||
% The ASF licenses this file to you under the Apache License, Version | ||
% 2.0 (the "License"); you may not use this file except in compliance | ||
% with the License. You may obtain a copy of the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, | ||
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
% implied. See the License for the specific language governing | ||
% permissions and limitations under the License. | ||
|
||
function dimensionString = makeDimensionString(arraySize) | ||
dimensionString = string(arraySize); | ||
dimensionString = join(dimensionString, char(215)); | ||
end |
36 changes: 36 additions & 0 deletions
36
matlab/src/matlab/+arrow/+internal/+test/+display/makeLinkString.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
%MAKELINKSTRING Utility function for creating hyperlinks. | ||
|
||
% Licensed to the Apache Software Foundation (ASF) under one or more | ||
% contributor license agreements. See the NOTICE file distributed with | ||
% this work for additional information regarding copyright ownership. | ||
% The ASF licenses this file to you under the Apache License, Version | ||
% 2.0 (the "License"); you may not use this file except in compliance | ||
% with the License. You may obtain a copy of the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, | ||
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
% implied. See the License for the specific language governing | ||
% permissions and limitations under the License. | ||
|
||
function link = makeLinkString(opts) | ||
arguments | ||
opts.FullClassName(1, 1) string | ||
opts.ClassName(1, 1) string | ||
% When displaying heterogeneous arrays, only the name of the | ||
% closest shared anscestor class is displayed in bold. All other | ||
% class names are not bolded. | ||
opts.BoldFont(1, 1) logical | ||
end | ||
|
||
if opts.BoldFont | ||
link = compose("<a href=""matlab:helpPopup %s""" + ... | ||
" style=""font-weight:bold"">%s</a>", ... | ||
opts.FullClassName, opts.ClassName); | ||
else | ||
link = compose("<a href=""matlab:helpPopup %s"">%s</a>", ... | ||
opts.FullClassName, opts.ClassName); | ||
end | ||
end |
32 changes: 32 additions & 0 deletions
32
matlab/src/matlab/+arrow/+internal/+test/+display/verify.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
%VERIFY Utility function used to verify object display. | ||
|
||
% Licensed to the Apache Software Foundation (ASF) under one or more | ||
% contributor license agreements. See the NOTICE file distributed with | ||
% this work for additional information regarding copyright ownership. | ||
% The ASF licenses this file to you under the Apache License, Version | ||
% 2.0 (the "License"); you may not use this file except in compliance | ||
% with the License. You may obtain a copy of the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, | ||
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
% implied. See the License for the specific language governing | ||
% permissions and limitations under the License. | ||
|
||
function verify(testCase, actualDisplay, expectedDisplay) | ||
% When the MATLAB GUI is running, '×' (char(215)) is used as | ||
% the delimiter between dimension values. However, when the | ||
% GUI is not running, 'x' (char(120)) is used as the delimiter. | ||
% To account for this discrepancy, check if actualDisplay | ||
% contains char(215). If not, replace all instances of | ||
% char(215) in expectedDisplay with char(120). | ||
|
||
tf = contains(actualDisplay, char(215)); | ||
if ~tf | ||
idx = strfind(expectedDisplay, char(215)); | ||
expectedDisplay(idx) = char(120); | ||
end | ||
testCase.verifyEqual(actualDisplay, expectedDisplay); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters