You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "sgilmore10 (via GitHub)" <gi...@apache.org> on 2023/09/07 17:03:52 UTC

[GitHub] [arrow] sgilmore10 commented on a diff in pull request #37613: GH-37597: [MATLAB] Add `toMATLAB` method to `arrow.array.ChunkedArray` class

sgilmore10 commented on code in PR #37613:
URL: https://github.com/apache/arrow/pull/37613#discussion_r1318897707


##########
matlab/test/arrow/array/tChunkedArray.m:
##########
@@ -240,6 +255,214 @@ function NumericIndexEmptyChunkedArrayError(testCase)
             fcn = @() chunkedArray.chunk(2);
             testCase.verifyError(fcn, "arrow:chunkedarray:NumericIndexWithEmptyChunkedArray");
         end
+
+        function ToMATLABBooleanType(testCase)
+            % Verify toMATLAB returns the expected MATLAB array when the
+            % Chunked Array contains boolean arrays.
+            import arrow.array.ChunkedArray
+
+            bools = true([1 11]);
+            bools([2 3 7 8 9]) = false;
+            a1 = arrow.array(bools(1:8));
+            a2 = arrow.array(bools(8:7));
+            a3 = arrow.array(bools(9:11));
+
+            % ChunkedArray with three chunks and nonzero length
+            chunkedArray1 = ChunkedArray.fromArrays(a1, a2, a3);
+            actualArray1 = toMATLAB(chunkedArray1);
+            expectedArray1 = bools';
+            testCase.verifyEqual(actualArray1, expectedArray1);
+
+            % ChunkedArray with zero chunks and zero length
+            chunkedArray2 = ChunkedArray.fromArrays(Type=a1.Type);
+            actualArray2 = toMATLAB(chunkedArray2);
+            expectedArray2 = logical.empty(0, 1);
+            testCase.verifyEqual(actualArray2, expectedArray2);
+
+            % ChunkedArray with two chunks and zero length
+            chunkedArray3 = ChunkedArray.fromArrays(a2, a2);
+            actualArray3 = toMATLAB(chunkedArray3);
+            expectedArray3 = logical.empty(0, 1);
+            testCase.verifyEqual(actualArray3, expectedArray3);
+        end
+
+        function ToMATLABIntegerTypes(testCase, IntegerMatlabClass)
+            % Verify toMATLAB returns the expected MATLAB array when the
+            % Chunked Array contains integer arrays.
+            import arrow.array.ChunkedArray
+
+            a1 = arrow.array(cast([1 2 3 4], IntegerMatlabClass));
+            a2 = arrow.array(cast([], IntegerMatlabClass));
+            a3 = arrow.array(cast([5 6 7 8 9], IntegerMatlabClass));
+
+            % ChunkedArray with three chunks and nonzero length
+            chunkedArray1 = ChunkedArray.fromArrays(a1, a2, a3);
+            actualArray1 = toMATLAB(chunkedArray1);
+            expectedArray1 = cast((1:9)', IntegerMatlabClass);
+            testCase.verifyEqual(actualArray1, expectedArray1);
+
+            % ChunkedArray with zero chunks and zero length
+            chunkedArray2 = ChunkedArray.fromArrays(Type=a1.Type);
+            actualArray2 = toMATLAB(chunkedArray2);
+            expectedArray2 = cast(double.empty(0, 1), IntegerMatlabClass);
+            testCase.verifyEqual(actualArray2, expectedArray2);
+
+            % ChunkedArray with two chunks and zero length
+            chunkedArray3 = ChunkedArray.fromArrays(a2, a2);
+            actualArray3 = toMATLAB(chunkedArray3);
+            expectedArray3 = cast(double.empty(0, 1), IntegerMatlabClass);
+            testCase.verifyEqual(actualArray3, expectedArray3);
+        end
+
+        function ToMATLABFloatTypes(testCase, FloatMatlabClass)
+             % Verify toMATLAB returns the expected MATLAB array when the

Review Comment:
   Oops! I'll fix that.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org