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

[GitHub] [arrow] kou commented on a diff in pull request #35495: GH-35492 [MATLAB]: Add arrow.array.Float32Array MATLAB Class

kou commented on code in PR #35495:
URL: https://github.com/apache/arrow/pull/35495#discussion_r1193564526


##########
matlab/test/arrow/array/tFloat32Array.m:
##########
@@ -0,0 +1,99 @@
+classdef tFloat32Array < matlab.unittest.TestCase
+    % Tests for arrow.array.Float32rray
+
+    % 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.
+    
+    properties (TestParameter)
+        MakeDeepCopy = {true false}
+    end
+
+    methods(TestClassSetup)
+        function verifyOnMatlabPath(testCase)
+            % arrow.array.Float32Array must be on the MATLAB path.
+            testCase.assertTrue(~isempty(which('arrow.array.Float32Array')), ...
+                '''arrow.array.Float32Array'' must be on the MATLAB path. Use ''addpath'' to add folders to the MATLAB path.');
+        end
+    end
+    
+    methods(Test)
+        function Basic(testCase, MakeDeepCopy)
+            A = arrow.array.Float32Array(single([1, 2, 3]), DeepCopy=MakeDeepCopy);
+            className = string(class(A));
+            testCase.verifyEqual(className, "arrow.array.Float32Array");
+        end
+
+        function ShallowCopy(testCase)
+        % By default, Float32Array does not create a deep copy on
+        % construction when constructed from a MATLAB array. Instead,
+        % it stores a shallow copy of the array keep the memory alive.
+            A = arrow.array.Float32Array(single([1, 2, 3]));
+            testCase.verifyEqual(A.MatlabArray, single([1 2 3]));
+            testCase.verifyEqual(single(A), single([1 2 3]'));
+
+            A = arrow.array.Float32Array(single([1, 2, 3]), DeepCopy=false);
+            testCase.verifyEqual(A.MatlabArray, single([1 2 3]));
+            testCase.verifyEqual(single(A), single([1 2 3]'));
+        end
+
+        function DeepCopy(testCase)
+        % Verify Float32Array does not store shallow copy of the MATLAB
+        % array if DeepCopy=true was supplied.

Review Comment:
   ```suggestion
             % Verify Float32Array does not store shallow copy of the MATLAB
             % array if DeepCopy=true was supplied.
   ```



##########
matlab/test/arrow/array/tFloat32Array.m:
##########
@@ -0,0 +1,99 @@
+classdef tFloat32Array < matlab.unittest.TestCase
+    % Tests for arrow.array.Float32rray
+
+    % 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.
+    
+    properties (TestParameter)
+        MakeDeepCopy = {true false}
+    end
+
+    methods(TestClassSetup)
+        function verifyOnMatlabPath(testCase)
+            % arrow.array.Float32Array must be on the MATLAB path.
+            testCase.assertTrue(~isempty(which('arrow.array.Float32Array')), ...
+                '''arrow.array.Float32Array'' must be on the MATLAB path. Use ''addpath'' to add folders to the MATLAB path.');
+        end
+    end
+    
+    methods(Test)
+        function Basic(testCase, MakeDeepCopy)
+            A = arrow.array.Float32Array(single([1, 2, 3]), DeepCopy=MakeDeepCopy);
+            className = string(class(A));
+            testCase.verifyEqual(className, "arrow.array.Float32Array");
+        end
+
+        function ShallowCopy(testCase)
+        % By default, Float32Array does not create a deep copy on
+        % construction when constructed from a MATLAB array. Instead,
+        % it stores a shallow copy of the array keep the memory alive.

Review Comment:
   ```suggestion
               % By default, Float32Array does not create a deep copy on
               % construction when constructed from a MATLAB array. Instead,
               % it stores a shallow copy of the array keep the memory alive.
   ```



-- 
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