kevingurney commented on code in PR #38661:
URL: https://github.com/apache/arrow/pull/38661#discussion_r1391755907


##########
matlab/test/arrow/array/tTime64Array.m:
##########
@@ -290,6 +310,66 @@ function TestIsEqualFalseTimeUnitMistmatch(tc)
             % arrays are not equal
             tc.verifyFalse(isequal(array1, array2));
         end
+
+        function RoundTimeBySpecifyTimeUnit(tc)
+            % Verify that the input parameter "TimeUnit" is used to specify
+            % the time resolution. The value is rounded off based on the
+            % specified "TimeUnit".
+
+            % TimeUnit="Microsecond"
+            matlabTimes = seconds([1.000001, ...
+                                   2.999999, ...
+                                   0.0002004, ...
+                                   0.0000035, ...
+                                   10.123456499, ...
+                                   9.999999543]);
+            arrowTimes = tc.ArrowArrayConstructorFcn(matlabTimes, 
TimeUnit="Microsecond");
+            tc.verifyEqual(arrowTimes.toMATLAB(), ...
+                           seconds([1.000001, ...
+                                    2.999999, ...
+                                    0.0002, ...
+                                    0.000004, ...
+                                    10.123456, ...
+                                    10])', ...
+                          'AbsTol',seconds(1e-14));
+
+            % TimeUnit="Nanosecond"
+            matlabTimes = seconds([1, ...
+                                   1.123, ...
+                                   1.12345, ...
+                                   1.123456, ...
+                                   1.1234567, ...
+                                   1.12345678, ...
+                                   1.123456789, ...
+                                   1.1234567894, ...
+                                   1.1234567895, ...
+                                   1.123456789009]);
+            arrowTimes = tc.ArrowArrayConstructorFcn(matlabTimes, 
TimeUnit="Nanosecond");
+            tc.verifyEqual(arrowTimes.toMATLAB(),...
+                           seconds([1, ...
+                                    1.123, ...
+                                    1.12345, ...
+                                    1.123456, ...
+                                    1.1234567, ...
+                                    1.12345678, ...
+                                    1.123456789, ...
+                                    1.123456789, ...
+                                    1.123456790, ...
+                                    1.123456789])',...
+                          'AbsTol',seconds(1e-15));
+        end
+
+        function TimeUnitIsReadOnly(tc)
+            % Verify that arrowArray.Type.TimeUnit cannot be changed.
+
+            matlabTimes = seconds([1.000001, 2.999999, 0.0002004]);
+            arrowArray = tc.ArrowArrayConstructorFcn(matlabTimes);
+            
tc.verifyError(@()setTimeUnit(arrowArray),'MATLAB:class:SetProhibited');

Review Comment:
   You can use `setfield` here like:
   
   
https://github.com/apache/arrow/blob/bff5fb95ac987354ecd7d69466e11b9f33a67d08/matlab/test/arrow/tabular/tRecordBatch.m#L260



##########
matlab/test/arrow/array/tTime32Array.m:
##########
@@ -274,6 +283,34 @@ function TestIsEqualFalseTimeUnitMistmatch(tc)
             % arrays are not equal
             tc.verifyFalse(isequal(array1, array2));
         end
+
+        function RoundTimeBySpecifyTimeUnit(tc)

Review Comment:
   ```suggestion
           function RoundTimeBySpecifiedTimeUnit(tc)
   ```



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

Reply via email to