kevingurney commented on code in PR #38564:
URL: https://github.com/apache/arrow/pull/38564#discussion_r1380678678
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
+ if i < width(t)
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type")), ' | '];
+ dataDisplay = [dataDisplay, num2str(i), ' | '];
+ else
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type"))];
+ dataDisplay = [dataDisplay, num2str(i)];
+ end
+ end
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ schemaDisplay, newline, ...
+ newline ...
+ dataDisplay, newline, ...
+ newline];
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function dataContainHyperlink(testCase, TabularType)
Review Comment:
```suggestion
function DataContainsHyperlink(testCase, TabularType)
```
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
+ if i < width(t)
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type")), ' | '];
+ dataDisplay = [dataDisplay, num2str(i), ' | '];
+ else
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type"))];
+ dataDisplay = [dataDisplay, num2str(i)];
+ end
+ end
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ schemaDisplay, newline, ...
+ newline ...
+ dataDisplay, newline, ...
+ newline];
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function dataContainHyperlink(testCase, TabularType)
+ % No matter whether hotlinks is turned on or off, the data text
+ % containing hyperlink is not impacted and is displayed well.
+ import arrow.internal.test.display.makeLinkString
+
+ hLink1 = string('<a href="http://www.foo.com">foo</a>');
+ hLink2 = string('<a href="http://www.foo.com">another foo</a>');
+ t =
table(["a";"bcd";missing;""],[hLink1;hLink2;hLink1;hLink2],[NaN;1;2;3],'VariableNames',["Description",
"Link_to_doc", "Result"]);
+ arrowTabularObj = TabularType.FromTableFcn(t);
+
+ % The display of schema and actual tabular data always contain
Review Comment:
```suggestion
% The display of schema and actual tabular data always contains
```
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
+ if i < width(t)
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type")), ' | '];
+ dataDisplay = [dataDisplay, num2str(i), ' | '];
+ else
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type"))];
+ dataDisplay = [dataDisplay, num2str(i)];
+ end
+ end
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ schemaDisplay, newline, ...
+ newline ...
+ dataDisplay, newline, ...
+ newline];
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function dataContainHyperlink(testCase, TabularType)
+ % No matter whether hotlinks is turned on or off, the data text
+ % containing hyperlink is not impacted and is displayed well.
+ import arrow.internal.test.display.makeLinkString
+
+ hLink1 = string('<a href="http://www.foo.com">foo</a>');
+ hLink2 = string('<a href="http://www.foo.com">another foo</a>');
+ t =
table(["a";"bcd";missing;""],[hLink1;hLink2;hLink1;hLink2],[NaN;1;2;3],'VariableNames',["Description",
"Link_to_doc", "Result"]);
+ arrowTabularObj = TabularType.FromTableFcn(t);
+
+ % The display of schema and actual tabular data always contain
+ % hyperlinks no matter whether hotlinks is turned on or off
+ var1Field = char(makeFieldString("Description", "String" ,
"arrow.type.StringType"));
+ var2Field = char(makeFieldString("Link_to_doc", "String" ,
"arrow.type.StringType"));
+ var3Field = char(makeFieldString( "Result", "Float64",
"arrow.type.Float64Type"));
+ schemaDisplay = [' Schema:', newline, newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field];
+ dataDisplay = [' First Row:', newline, newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null'];
+ expectedDisplayOfData = [newline, ...
+ ' Schema:', newline, ...
+ newline ...
+ ' ', var1Field, ' | ', var2Field,
' | ', var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null', newline, ...
+ newline];
+
+ % hotlinks is turned off
+ actualDisplay =
evalc('feature(''hotlinks'',''off'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+
+ % hotlinks is turned on
+ actualDisplay =
evalc('feature(''hotlinks'',''on'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+ end
+
+ function displayClassNameWhenDataIsNotArray(testCase, TabularType)
+ % When the datatype of a column is not an homogeneous array
+ % type, the class name instead of the actual data will be
+ % displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t =
table(datetime(2023,1,[1;2;3]),table([1;2;3],[4;5;6]),seconds([1;2;3]));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(3), getNumString(3));
+ var1Field = char(makeFieldString("Var1", "Timestamp" ,
"arrow.type.TimestampType"));
+ var2Field = char(makeFieldString("Var2", "Struct" ,
"arrow.type.StructType"));
+ var3Field = char(makeFieldString("Var3", "Time64",
"arrow.type.Time64Type"));
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ ' Schema:', newline, ...
+ newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '2023-01-01 00:00:00.000000 |
<Struct> | 00:00:01.000000', newline,...
+ newline];
+
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function displayInvalidData(testCase, TabularType)
+ % Display "null" for invalid value
+ import arrow.internal.test.display.makeLinkString
+
+ t = table(seconds([NaN;1]), string([missing;"a"]),
string(["";"b"]), [NaN;1], datetime(2023,1,[NaN;2]),...
+ VariableNames=["durationVar", "stringVar1",
"stringVar2", "doubleVar", "datetimeVar"]);
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(5));
+ var1Field = char(makeFieldString("durationVar", "Time64" ,
"arrow.type.Time64Type"));
+ var2Field = char(makeFieldString("stringVar1", "String" ,
"arrow.type.StringType"));
+ var3Field = char(makeFieldString("stringVar2", "String",
"arrow.type.StringType"));
+ var4Field = char(makeFieldString("doubleVar", "Float64",
"arrow.type.Float64Type"));
+ var5Field = char(makeFieldString("datetimeVar", "Timestamp",
"arrow.type.TimestampType"));
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ ' Schema:', newline, ...
+ newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field, ' | ', var4Field, ' | ', var5Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', 'null | null | "" | null | null',
newline,...
+ newline];
+
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function unicodeDisplayWell(testCase, TabularType)
Review Comment:
```suggestion
function Unicode(testCase, TabularType)
```
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
+ if i < width(t)
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type")), ' | '];
+ dataDisplay = [dataDisplay, num2str(i), ' | '];
+ else
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type"))];
+ dataDisplay = [dataDisplay, num2str(i)];
+ end
+ end
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ schemaDisplay, newline, ...
+ newline ...
+ dataDisplay, newline, ...
+ newline];
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function dataContainHyperlink(testCase, TabularType)
+ % No matter whether hotlinks is turned on or off, the data text
+ % containing hyperlink is not impacted and is displayed well.
+ import arrow.internal.test.display.makeLinkString
+
+ hLink1 = string('<a href="http://www.foo.com">foo</a>');
+ hLink2 = string('<a href="http://www.foo.com">another foo</a>');
+ t =
table(["a";"bcd";missing;""],[hLink1;hLink2;hLink1;hLink2],[NaN;1;2;3],'VariableNames',["Description",
"Link_to_doc", "Result"]);
+ arrowTabularObj = TabularType.FromTableFcn(t);
+
+ % The display of schema and actual tabular data always contain
+ % hyperlinks no matter whether hotlinks is turned on or off
+ var1Field = char(makeFieldString("Description", "String" ,
"arrow.type.StringType"));
+ var2Field = char(makeFieldString("Link_to_doc", "String" ,
"arrow.type.StringType"));
+ var3Field = char(makeFieldString( "Result", "Float64",
"arrow.type.Float64Type"));
+ schemaDisplay = [' Schema:', newline, newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field];
+ dataDisplay = [' First Row:', newline, newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null'];
+ expectedDisplayOfData = [newline, ...
+ ' Schema:', newline, ...
+ newline ...
+ ' ', var1Field, ' | ', var2Field,
' | ', var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null', newline, ...
+ newline];
+
+ % hotlinks is turned off
+ actualDisplay =
evalc('feature(''hotlinks'',''off'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+
+ % hotlinks is turned on
+ actualDisplay =
evalc('feature(''hotlinks'',''on'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+ end
+
+ function displayClassNameWhenDataIsNotArray(testCase, TabularType)
+ % When the datatype of a column is not an homogeneous array
+ % type, the class name instead of the actual data will be
+ % displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t =
table(datetime(2023,1,[1;2;3]),table([1;2;3],[4;5;6]),seconds([1;2;3]));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(3), getNumString(3));
+ var1Field = char(makeFieldString("Var1", "Timestamp" ,
"arrow.type.TimestampType"));
+ var2Field = char(makeFieldString("Var2", "Struct" ,
"arrow.type.StructType"));
+ var3Field = char(makeFieldString("Var3", "Time64",
"arrow.type.Time64Type"));
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ ' Schema:', newline, ...
+ newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '2023-01-01 00:00:00.000000 |
<Struct> | 00:00:01.000000', newline,...
+ newline];
+
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function displayInvalidData(testCase, TabularType)
+ % Display "null" for invalid value
+ import arrow.internal.test.display.makeLinkString
+
+ t = table(seconds([NaN;1]), string([missing;"a"]),
string(["";"b"]), [NaN;1], datetime(2023,1,[NaN;2]),...
+ VariableNames=["durationVar", "stringVar1",
"stringVar2", "doubleVar", "datetimeVar"]);
Review Comment:
Indentation is off here.
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
Review Comment:
```suggestion
for i = 1:width(t)
```
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
+ if i < width(t)
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type")), ' | '];
+ dataDisplay = [dataDisplay, num2str(i), ' | '];
+ else
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type"))];
+ dataDisplay = [dataDisplay, num2str(i)];
+ end
+ end
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ schemaDisplay, newline, ...
+ newline ...
+ dataDisplay, newline, ...
+ newline];
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function dataContainHyperlink(testCase, TabularType)
+ % No matter whether hotlinks is turned on or off, the data text
+ % containing hyperlink is not impacted and is displayed well.
+ import arrow.internal.test.display.makeLinkString
+
+ hLink1 = string('<a href="http://www.foo.com">foo</a>');
+ hLink2 = string('<a href="http://www.foo.com">another foo</a>');
+ t =
table(["a";"bcd";missing;""],[hLink1;hLink2;hLink1;hLink2],[NaN;1;2;3],'VariableNames',["Description",
"Link_to_doc", "Result"]);
+ arrowTabularObj = TabularType.FromTableFcn(t);
+
+ % The display of schema and actual tabular data always contain
+ % hyperlinks no matter whether hotlinks is turned on or off
+ var1Field = char(makeFieldString("Description", "String" ,
"arrow.type.StringType"));
+ var2Field = char(makeFieldString("Link_to_doc", "String" ,
"arrow.type.StringType"));
+ var3Field = char(makeFieldString( "Result", "Float64",
"arrow.type.Float64Type"));
+ schemaDisplay = [' Schema:', newline, newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field];
+ dataDisplay = [' First Row:', newline, newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null'];
+ expectedDisplayOfData = [newline, ...
+ ' Schema:', newline, ...
+ newline ...
+ ' ', var1Field, ' | ', var2Field,
' | ', var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null', newline, ...
+ newline];
+
+ % hotlinks is turned off
+ actualDisplay =
evalc('feature(''hotlinks'',''off'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+
+ % hotlinks is turned on
+ actualDisplay =
evalc('feature(''hotlinks'',''on'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+ end
+
+ function displayClassNameWhenDataIsNotArray(testCase, TabularType)
+ % When the datatype of a column is not an homogeneous array
Review Comment:
```suggestion
% When the datatype of a column is not a homogeneous array
```
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
+ if i < width(t)
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type")), ' | '];
+ dataDisplay = [dataDisplay, num2str(i), ' | '];
+ else
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type"))];
+ dataDisplay = [dataDisplay, num2str(i)];
+ end
+ end
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ schemaDisplay, newline, ...
+ newline ...
+ dataDisplay, newline, ...
+ newline];
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function dataContainHyperlink(testCase, TabularType)
+ % No matter whether hotlinks is turned on or off, the data text
+ % containing hyperlink is not impacted and is displayed well.
+ import arrow.internal.test.display.makeLinkString
+
+ hLink1 = string('<a href="http://www.foo.com">foo</a>');
+ hLink2 = string('<a href="http://www.foo.com">another foo</a>');
+ t =
table(["a";"bcd";missing;""],[hLink1;hLink2;hLink1;hLink2],[NaN;1;2;3],'VariableNames',["Description",
"Link_to_doc", "Result"]);
+ arrowTabularObj = TabularType.FromTableFcn(t);
+
+ % The display of schema and actual tabular data always contain
+ % hyperlinks no matter whether hotlinks is turned on or off
+ var1Field = char(makeFieldString("Description", "String" ,
"arrow.type.StringType"));
+ var2Field = char(makeFieldString("Link_to_doc", "String" ,
"arrow.type.StringType"));
+ var3Field = char(makeFieldString( "Result", "Float64",
"arrow.type.Float64Type"));
+ schemaDisplay = [' Schema:', newline, newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field];
+ dataDisplay = [' First Row:', newline, newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null'];
+ expectedDisplayOfData = [newline, ...
+ ' Schema:', newline, ...
+ newline ...
+ ' ', var1Field, ' | ', var2Field,
' | ', var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null', newline, ...
+ newline];
+
+ % hotlinks is turned off
+ actualDisplay =
evalc('feature(''hotlinks'',''off'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+
+ % hotlinks is turned on
+ actualDisplay =
evalc('feature(''hotlinks'',''on'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+ end
+
+ function displayClassNameWhenDataIsNotArray(testCase, TabularType)
+ % When the datatype of a column is not an homogeneous array
+ % type, the class name instead of the actual data will be
+ % displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t =
table(datetime(2023,1,[1;2;3]),table([1;2;3],[4;5;6]),seconds([1;2;3]));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(3), getNumString(3));
+ var1Field = char(makeFieldString("Var1", "Timestamp" ,
"arrow.type.TimestampType"));
+ var2Field = char(makeFieldString("Var2", "Struct" ,
"arrow.type.StructType"));
+ var3Field = char(makeFieldString("Var3", "Time64",
"arrow.type.Time64Type"));
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ ' Schema:', newline, ...
+ newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '2023-01-01 00:00:00.000000 |
<Struct> | 00:00:01.000000', newline,...
+ newline];
+
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function displayInvalidData(testCase, TabularType)
+ % Display "null" for invalid value
Review Comment:
For consistency with the other test cases, could you start the test case
comments with something like "Verify that..."
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
Review Comment:
Could you please use `UpperCamelCase` for the test names to follow the
convention used in this file?
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
+ if i < width(t)
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type")), ' | '];
+ dataDisplay = [dataDisplay, num2str(i), ' | '];
+ else
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type"))];
+ dataDisplay = [dataDisplay, num2str(i)];
+ end
+ end
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ schemaDisplay, newline, ...
+ newline ...
+ dataDisplay, newline, ...
+ newline];
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function dataContainHyperlink(testCase, TabularType)
+ % No matter whether hotlinks is turned on or off, the data text
+ % containing hyperlink is not impacted and is displayed well.
+ import arrow.internal.test.display.makeLinkString
+
+ hLink1 = string('<a href="http://www.foo.com">foo</a>');
+ hLink2 = string('<a href="http://www.foo.com">another foo</a>');
+ t =
table(["a";"bcd";missing;""],[hLink1;hLink2;hLink1;hLink2],[NaN;1;2;3],'VariableNames',["Description",
"Link_to_doc", "Result"]);
+ arrowTabularObj = TabularType.FromTableFcn(t);
+
+ % The display of schema and actual tabular data always contain
+ % hyperlinks no matter whether hotlinks is turned on or off
+ var1Field = char(makeFieldString("Description", "String" ,
"arrow.type.StringType"));
+ var2Field = char(makeFieldString("Link_to_doc", "String" ,
"arrow.type.StringType"));
+ var3Field = char(makeFieldString( "Result", "Float64",
"arrow.type.Float64Type"));
+ schemaDisplay = [' Schema:', newline, newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field];
+ dataDisplay = [' First Row:', newline, newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null'];
+ expectedDisplayOfData = [newline, ...
+ ' Schema:', newline, ...
+ newline ...
+ ' ', var1Field, ' | ', var2Field,
' | ', var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '"a"', ' | ', '"', '<a
href="http://www.foo.com">foo</a>', '"', ' | ', 'null', newline, ...
+ newline];
+
+ % hotlinks is turned off
+ actualDisplay =
evalc('feature(''hotlinks'',''off'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+
+ % hotlinks is turned on
+ actualDisplay =
evalc('feature(''hotlinks'',''on'');disp(arrowTabularObj)');
+ testCase.verifySubstring(actualDisplay, expectedDisplayOfData);
+ end
+
+ function displayClassNameWhenDataIsNotArray(testCase, TabularType)
+ % When the datatype of a column is not an homogeneous array
+ % type, the class name instead of the actual data will be
+ % displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t =
table(datetime(2023,1,[1;2;3]),table([1;2;3],[4;5;6]),seconds([1;2;3]));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(3), getNumString(3));
+ var1Field = char(makeFieldString("Var1", "Timestamp" ,
"arrow.type.TimestampType"));
+ var2Field = char(makeFieldString("Var2", "Struct" ,
"arrow.type.StructType"));
+ var3Field = char(makeFieldString("Var3", "Time64",
"arrow.type.Time64Type"));
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ ' Schema:', newline, ...
+ newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', '2023-01-01 00:00:00.000000 |
<Struct> | 00:00:01.000000', newline,...
+ newline];
+
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function displayInvalidData(testCase, TabularType)
+ % Display "null" for invalid value
+ import arrow.internal.test.display.makeLinkString
+
+ t = table(seconds([NaN;1]), string([missing;"a"]),
string(["";"b"]), [NaN;1], datetime(2023,1,[NaN;2]),...
+ VariableNames=["durationVar", "stringVar1",
"stringVar2", "doubleVar", "datetimeVar"]);
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(5));
+ var1Field = char(makeFieldString("durationVar", "Time64" ,
"arrow.type.Time64Type"));
+ var2Field = char(makeFieldString("stringVar1", "String" ,
"arrow.type.StringType"));
+ var3Field = char(makeFieldString("stringVar2", "String",
"arrow.type.StringType"));
+ var4Field = char(makeFieldString("doubleVar", "Float64",
"arrow.type.Float64Type"));
+ var5Field = char(makeFieldString("datetimeVar", "Timestamp",
"arrow.type.TimestampType"));
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ ' Schema:', newline, ...
+ newline, ...
+ ' ', var1Field, ' | ', var2Field, ' | ',
var3Field, ' | ', var4Field, ' | ', var5Field, newline, ...
+ newline, ...
+ ' First Row:', newline, ...
+ newline, ...
+ ' ', 'null | null | "" | null | null',
newline,...
+ newline];
+
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function unicodeDisplayWell(testCase, TabularType)
+ % The current display doesn't align anything. So it should work
+ % well with displaying unicode.
Review Comment:
```suggestion
% well with displaying Unicode characters.
```
##########
matlab/test/arrow/tabular/tTabularDisplay.m:
##########
@@ -124,6 +153,167 @@ function ManyRowsAndColumns(testCase, TabularType)
testCase.verifyEqual(actualDisplay, expectedDisplay);
end
+
+ function veryWideTabular(testCase, TabularType)
+ % Test tabular object that is wider than the MATLAB Command
+ % Window. In this case, all variables are still displayed.
+ import arrow.internal.test.display.makeLinkString
+
+ t = array2table([1:100;101:200],VariableNames="x"+(1:100));
+ arrowTabularObj = TabularType.FromTableFcn(t);
+ actualDisplay = evalc('disp(arrowTabularObj)');
+
+ classNameString =
makeLinkString(FullClassName=TabularType.FullClassName, ...
+ ClassName=TabularType.ClassName, BoldFont=true);
+ header = compose(" Arrow %s with %s rows and %s columns:",
classNameString, getNumString(2), getNumString(100));
+ schemaDisplay = [' Schema:', newline, newline, ' '];
+ dataDisplay = [' First Row:', newline, newline, ' '];
+ for i = 1 : width(t)
+ if i < width(t)
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type")), ' | '];
+ dataDisplay = [dataDisplay, num2str(i), ' | '];
+ else
+ schemaDisplay = [schemaDisplay,
char(makeFieldString("x"+i, "Float64", "arrow.type.Float64Type"))];
+ dataDisplay = [dataDisplay, num2str(i)];
+ end
+ end
+ expectedDisplay = [char(header), newline, ...
+ newline, ...
+ schemaDisplay, newline, ...
+ newline ...
+ dataDisplay, newline, ...
+ newline];
+ testCase.verifyEqual(actualDisplay, expectedDisplay);
+ end
+
+ function dataContainHyperlink(testCase, TabularType)
+ % No matter whether hotlinks is turned on or off, the data text
+ % containing hyperlink is not impacted and is displayed well.
Review Comment:
```suggestion
% containing hyperlink is not impacted and is displayed as
expected.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]