You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2023/06/10 20:21:48 UTC

[arrow] branch main updated: GH-35693: [MATLAB] Add `Valid` as a name-value pair on the `arrow.array.Float64Array` constructor (#35977)

This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 788760570d GH-35693: [MATLAB] Add `Valid` as a name-value pair on the `arrow.array.Float64Array` constructor (#35977)
788760570d is described below

commit 788760570d8182e1eb05a47e8871360515f431be
Author: sgilmore10 <74...@users.noreply.github.com>
AuthorDate: Sat Jun 10 16:21:41 2023 -0400

    GH-35693: [MATLAB] Add `Valid` as a name-value pair on the `arrow.array.Float64Array` constructor (#35977)
    
    
    
    ### Rationale for this change
    Users should be able to specify exactly which elements in a MATLAB array should be treated as `null` values. In a previous PR, we added the name-value pair `InferNulls` which users can use to turn off the automatic "null detection" of values for which the MATLAB `ismissing` function returns true:
    
    ```MATLAB
    >> matlabArray = [1 NaN 3];
    
    % NaN is treated as null by default
    >> arrowArray = arrow.array.Float64Array(matlabArray);
    
    arrowArray =
    
    [
      1,
      null,
      3
    ]
    
    % Don't treat NaN as a null value
    >> arrowArray = arrow.array.Float64Array(matlabArray, InferNulls=false);
    
    arrowArray =
    
    [
      1,
      nan,
      3
    ]
    ```
    
    To provide more control, this PR adds a new name-value pair named `Valid`. This name-value pair will take precedence over `InferNulls` and allows users to specify which elements are valid using either a logical array or a list of indices:
    
    ```MATLAB
    >> matlabArray = [1 NaN 3];
    
    >> arrowArray = arrow.array.Float64Array(matlabArray, Valid=[true true false]);
    
    arrowArray =
    
    [
      1,
      nan,
      null
    ]
    
    >> arrowArray = arrow.array.Float64Array(matlabArray, Valid=[2 3]);
    
    arrowArray =
    
    [
      null,
      nan,
      3
    ]
    
    ```
    
    ### What changes are included in this PR?
    
    1. Added the `Valid` name-value pair to `arrow.array.Float64Array`.
    
    ### Are these changes tested?
    
    1. Added a new test file called `tParseValidElements.m` to independently test the helper function `arrow.args.parseValidElements` used by `arrow.array.Float64Array`.
    2. Added two integration tests in `tFloat64Array.m`.
    
    ### Are there any user-facing changes?
    Yes, users can now pass the `Valid` name-value pair to `arrow.array.Float64Array`.
    
    ### Future Directions
    
    1. Currently, only `arrow.array.Float64Array` supports the `InferNulls` and `Valid` name-value pairs. In a followup PR, we will add support for these name-value pairs to the rest of the numeric array classes.
    
    * Closes: #35693
    
    Lead-authored-by: Sarah Gilmore <sg...@mathworks.com>
    Co-authored-by: sgilmore10 <74...@users.noreply.github.com>
    Co-authored-by: Sutou Kouhei <ko...@cozmixng.org>
    Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
 .../src/matlab/+arrow/+args/parseValidElements.m   |  45 +++++-
 .../src/matlab/+arrow/+args/validateTypeAndShape.m |   4 +-
 matlab/src/matlab/+arrow/+array/Float32Array.m     |  31 ++--
 matlab/src/matlab/+arrow/+array/Float64Array.m     |  40 ++---
 matlab/src/matlab/+arrow/+array/Int16Array.m       |  32 ++--
 matlab/src/matlab/+arrow/+array/Int32Array.m       |  30 ++--
 matlab/src/matlab/+arrow/+array/Int64Array.m       |  32 ++--
 matlab/src/matlab/+arrow/+array/Int8Array.m        |  32 ++--
 matlab/src/matlab/+arrow/+array/UInt16Array.m      |  32 ++--
 matlab/src/matlab/+arrow/+array/UInt32Array.m      |  32 ++--
 matlab/src/matlab/+arrow/+array/UInt64Array.m      |  32 ++--
 matlab/src/matlab/+arrow/+array/UInt8Array.m       |  32 ++--
 matlab/test/arrow/args/tParseValidElements.m       | 163 +++++++++++++++++++++
 matlab/test/arrow/array/hNumericArray.m            |  51 +++----
 matlab/test/arrow/array/tFloat32Array.m            |  32 ++--
 matlab/test/arrow/array/tFloat64Array.m            |  53 ++++---
 matlab/test/arrow/array/tInt16Array.m              |  32 ++--
 matlab/test/arrow/array/tInt32Array.m              |  32 ++--
 matlab/test/arrow/array/tInt64Array.m              |  32 ++--
 matlab/test/arrow/array/tInt8Array.m               |  32 ++--
 matlab/test/arrow/array/tUInt16Array.m             |  32 ++--
 matlab/test/arrow/array/tUInt32Array.m             |  30 ++--
 matlab/test/arrow/array/tUInt64Array.m             |  32 ++--
 matlab/test/arrow/array/tUInt8Array.m              |  32 ++--
 24 files changed, 571 insertions(+), 356 deletions(-)

diff --git a/matlab/src/matlab/+arrow/+args/parseValidElements.m b/matlab/src/matlab/+arrow/+args/parseValidElements.m
index 90d26b5315..deabb5cd08 100644
--- a/matlab/src/matlab/+arrow/+args/parseValidElements.m
+++ b/matlab/src/matlab/+arrow/+args/parseValidElements.m
@@ -13,16 +13,51 @@
 % implied.  See the License for the specific language governing
 % permissions and limitations under the License.
 
-function validElements = parseValidElements(data, inferNulls)
-    % Returns a logical vector of the validElements in data. If inferNulls
-    % is true, calls ismissing on data to determine which elements are 
-    % null.
+function validElements = parseValidElements(data, opts)
+% Returns a logical vector of the validElements in data. 
+%
+% opts is a scalar struct that is required to have a field called
+% InferNulls. opts may have a field named Valid. If so, it takes 
+% precedence over InferNulls.
+
+    if isfield(opts, "Valid")
+        validElements = parseValid(numel(data), opts.Valid);
+    else
+        validElements = parseInferNulls(data, opts.InferNulls);
+    end
+end
+
+function validElements = parseValid(numElements, valid)
+    if islogical(valid)
+        validElements = reshape(valid, [], 1);
+        if ~isscalar(validElements)
+            % Verify the logical vector has the correct number of elements
+            validateattributes(validElements, "logical", {'numel', numElements});
+        else
+            % TODO: consider making validElements empty if every 
+            % element is Valid.
 
+            % Expand scalar logical inputs to the correct dimensions
+            validElements = repmat(validElements, numElements, 1);
+        end
+    else
+        % valid is a list of indices. Verify the indices are numeric, 
+        % integers, and within the range 1 < indices < numElements.
+        validateattributes(valid, "numeric", {'integer', '>', 0, '<=', numElements});
+        % Create a logical vector that contains true values at the indices
+        % specified by opts.Valid.
+        validElements = false([numElements 1]);
+        validElements(valid) = true;
+    end
+end
+
+function validElements = parseInferNulls(data, inferNulls)
     if inferNulls
         % TODO: consider making validElements empty if everything is valid.
         validElements = ~ismissing(data);
+        validElements = reshape(validElements, [], 1);
     else
         % TODO: consider making this an empty array if everything is valid
         validElements = true([numel(data) 1]);
     end
-end
+end
\ No newline at end of file
diff --git a/matlab/src/matlab/+arrow/+args/validateTypeAndShape.m b/matlab/src/matlab/+arrow/+args/validateTypeAndShape.m
index 08c3312bc1..78e8dd1efe 100644
--- a/matlab/src/matlab/+arrow/+args/validateTypeAndShape.m
+++ b/matlab/src/matlab/+arrow/+args/validateTypeAndShape.m
@@ -14,8 +14,8 @@
 % permissions and limitations under the License.
 
 function validateTypeAndShape(data, type)
-    % Validates data has the expected type and is a vector or empty 2D
-    % matrix. If data is numeric, validates is real and nonsparse.
+% Validates data has the expected type and is a vector or empty 2D
+% matrix. If data is numeric, validates is real and nonsparse.
 
     arguments
         data
diff --git a/matlab/src/matlab/+arrow/+array/Float32Array.m b/matlab/src/matlab/+arrow/+array/Float32Array.m
index f641463aa7..f35be565e4 100644
--- a/matlab/src/matlab/+arrow/+array/Float32Array.m
+++ b/matlab/src/matlab/+arrow/+array/Float32Array.m
@@ -1,20 +1,19 @@
+% 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.
 classdef Float32Array < arrow.array.Array
-    % arrow.array.Float32Array
-
-    % 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.
+% arrow.array.Float32Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray = single([])
diff --git a/matlab/src/matlab/+arrow/+array/Float64Array.m b/matlab/src/matlab/+arrow/+array/Float64Array.m
index f8d8a671db..67c29145e7 100644
--- a/matlab/src/matlab/+arrow/+array/Float64Array.m
+++ b/matlab/src/matlab/+arrow/+array/Float64Array.m
@@ -1,20 +1,19 @@
+ % 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.
 classdef Float64Array < arrow.array.Array
-    % arrow.array.Float64Array
-
-    % 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.
+% arrow.array.Float64Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray
@@ -22,14 +21,15 @@ classdef Float64Array < arrow.array.Array
     end
 
     methods
-        function obj = Float64Array(data, opts)
+        function obj = Float64Array(data, opts, nullOpts)
             arguments
                 data
                 opts.DeepCopy(1, 1) logical = false
-                opts.InferNulls(1, 1) logical = true
+                nullOpts.InferNulls(1, 1) logical = true
+                nullOpts.Valid
             end
             arrow.args.validateTypeAndShape(data, "double");
-            validElements = arrow.args.parseValidElements(data, opts.InferNulls);
+            validElements = arrow.args.parseValidElements(data, nullOpts);
             obj@arrow.array.Array("Name", "arrow.array.proxy.Float64Array", "ConstructorArguments", {data, opts.DeepCopy, validElements});
             % Store a reference to the array if not doing a deep copy
             if (~opts.DeepCopy), obj.MatlabArray = data; end
@@ -38,7 +38,7 @@ classdef Float64Array < arrow.array.Array
         function data = double(obj)
             data = obj.toMATLAB();
         end
-        
+
         function matlabArray = toMATLAB(obj)
             matlabArray = obj.Proxy.toMATLAB();
             matlabArray(~obj.Valid) = obj.NullSubstitionValue;
diff --git a/matlab/src/matlab/+arrow/+array/Int16Array.m b/matlab/src/matlab/+arrow/+array/Int16Array.m
index e4c8589594..6daa719adf 100644
--- a/matlab/src/matlab/+arrow/+array/Int16Array.m
+++ b/matlab/src/matlab/+arrow/+array/Int16Array.m
@@ -1,20 +1,20 @@
+% 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.
+    
 classdef Int16Array < arrow.array.Array
-    % arrow.array.Int16Array
-
-    % 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.
+% arrow.array.Int16Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray = int16([])
diff --git a/matlab/src/matlab/+arrow/+array/Int32Array.m b/matlab/src/matlab/+arrow/+array/Int32Array.m
index 840321f65e..58ecefdba9 100644
--- a/matlab/src/matlab/+arrow/+array/Int32Array.m
+++ b/matlab/src/matlab/+arrow/+array/Int32Array.m
@@ -1,21 +1,21 @@
+% 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.
+
 classdef Int32Array < arrow.array.Array
     % arrow.array.Int32Array
 
-    % 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 (Hidden, SetAccess=private)
         MatlabArray = int32([])
     end
diff --git a/matlab/src/matlab/+arrow/+array/Int64Array.m b/matlab/src/matlab/+arrow/+array/Int64Array.m
index 90d5512422..17360f17d4 100644
--- a/matlab/src/matlab/+arrow/+array/Int64Array.m
+++ b/matlab/src/matlab/+arrow/+array/Int64Array.m
@@ -1,20 +1,20 @@
-classdef Int64Array < arrow.array.Array
-    % arrow.array.Int64Array
+% 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.
 
-    % 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.
+classdef Int64Array < arrow.array.Array
+% arrow.array.Int64Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray = int64([])
diff --git a/matlab/src/matlab/+arrow/+array/Int8Array.m b/matlab/src/matlab/+arrow/+array/Int8Array.m
index 632e72e7ea..99d3347c0f 100644
--- a/matlab/src/matlab/+arrow/+array/Int8Array.m
+++ b/matlab/src/matlab/+arrow/+array/Int8Array.m
@@ -1,20 +1,20 @@
-classdef Int8Array < arrow.array.Array
-    % arrow.array.Int8Array
+% 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.
 
-    % 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.
+classdef Int8Array < arrow.array.Array
+% arrow.array.Int8Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray = int8([])
diff --git a/matlab/src/matlab/+arrow/+array/UInt16Array.m b/matlab/src/matlab/+arrow/+array/UInt16Array.m
index 14318de116..6b3839c022 100644
--- a/matlab/src/matlab/+arrow/+array/UInt16Array.m
+++ b/matlab/src/matlab/+arrow/+array/UInt16Array.m
@@ -1,20 +1,20 @@
-classdef UInt16Array < arrow.array.Array
-    % arrow.array.UInt16Array
+% 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.
 
-    % 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.
+classdef UInt16Array < arrow.array.Array
+% arrow.array.UInt16Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray = uint16([])
diff --git a/matlab/src/matlab/+arrow/+array/UInt32Array.m b/matlab/src/matlab/+arrow/+array/UInt32Array.m
index 9a5f63b243..884dc1f5ed 100644
--- a/matlab/src/matlab/+arrow/+array/UInt32Array.m
+++ b/matlab/src/matlab/+arrow/+array/UInt32Array.m
@@ -1,20 +1,20 @@
-classdef UInt32Array < arrow.array.Array
-    % arrow.array.UInt32Array
+% 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.
 
-    % 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.
+classdef UInt32Array < arrow.array.Array
+% arrow.array.UInt32Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray = uint32([])
diff --git a/matlab/src/matlab/+arrow/+array/UInt64Array.m b/matlab/src/matlab/+arrow/+array/UInt64Array.m
index c5f819b33d..c8abac34dd 100644
--- a/matlab/src/matlab/+arrow/+array/UInt64Array.m
+++ b/matlab/src/matlab/+arrow/+array/UInt64Array.m
@@ -1,20 +1,20 @@
-classdef UInt64Array < arrow.array.Array
-    % arrow.array.UInt64Array
+% 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.
 
-    % 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.
+classdef UInt64Array < arrow.array.Array
+% arrow.array.UInt64Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray = uint64([])
diff --git a/matlab/src/matlab/+arrow/+array/UInt8Array.m b/matlab/src/matlab/+arrow/+array/UInt8Array.m
index 04c634be41..1c652b209b 100644
--- a/matlab/src/matlab/+arrow/+array/UInt8Array.m
+++ b/matlab/src/matlab/+arrow/+array/UInt8Array.m
@@ -1,20 +1,20 @@
+% 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.
+    
 classdef UInt8Array < arrow.array.Array
-    % arrow.array.UInt8Array
-
-    % 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.
+% arrow.array.UInt8Array
 
     properties (Hidden, SetAccess=private)
         MatlabArray = uint8([])
diff --git a/matlab/test/arrow/args/tParseValidElements.m b/matlab/test/arrow/args/tParseValidElements.m
new file mode 100644
index 0000000000..0bf086498f
--- /dev/null
+++ b/matlab/test/arrow/args/tParseValidElements.m
@@ -0,0 +1,163 @@
+% 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.
+
+classdef tParseValidElements < matlab.unittest.TestCase
+% Tests for arrow.args.parseValidElements
+    
+    methods(Test)
+        % Test methods
+        function InferNullsTrue(testCase)
+            % Verify values for which ismissing returns true for are not
+            % considered valid.
+            data = [1 NaN 3 NaN 5];
+            validElements = parseValidElements(data, InferNulls=true);
+            expectedValidElements = [true; false; true; false; true];
+            testCase.verifyEqual(validElements, expectedValidElements);
+
+            data = [1 2 3];
+            validElements = parseValidElements(data, InferNulls=true);
+            expectedValidElements = [true; true; true];
+            testCase.verifyEqual(validElements, expectedValidElements);
+        end
+
+        function InferNullsFalse(testCase)
+            % Verify all elements are treated as Valid wen InferNulls=false is
+            % provided - including values for which that ismissing returns true.
+            data = [1 NaN 3 NaN 5];
+            validElements = parseValidElements(data, InferNulls=false);
+            expectedValidElements = [true; true; true; true; true];
+            testCase.verifyEqual(validElements, expectedValidElements);
+        end
+
+        function LogicalValid(testCase)
+            data = [1 2 3]; 
+
+            % Supply a scalar true value for Valid 
+            validElements = parseValidElements(data, Valid=true);
+            expectedValidElements = [true; true; true];
+            testCase.verifyEqual(validElements, expectedValidElements);
+
+            % Supply a scalar false value for Valid
+            validElements = parseValidElements(data, Valid=false);
+            expectedValidElements = [false; false; false];
+            testCase.verifyEqual(validElements, expectedValidElements);
+
+            % Supply a logical vector for Valid
+            validElements = parseValidElements(data, Valid=[false; true; true]);
+            expectedValidElements = [false; true; true];
+            testCase.verifyEqual(validElements, expectedValidElements);
+        end
+
+        function NumericValid(testCase)
+            data = [1 2 3]; 
+
+            % Supply 1 valid index for Valid
+            validElements = parseValidElements(data, Valid=2);
+            expectedValidElements = [false; true; false];
+            testCase.verifyEqual(validElements, expectedValidElements);
+
+            % Supply a numeric vector for Valid 
+            validElements = parseValidElements(data, Valid=[1 3]);
+            expectedValidElements = [true; false; true];
+            testCase.verifyEqual(validElements, expectedValidElements);
+        end
+
+        function ComplexValidIndicesError(testCase)
+            % Verify parseValidElements errors if Valid is a numeric array
+            % containing complex numbers.
+            data = [1 2 3];
+            fcn = @() parseValidElements(data, Valid=[1i 2]);
+            testCase.verifyError(fcn, "MATLAB:expectedInteger");
+        end
+
+        function FloatingPointValidIndicesError(testCase)
+        % Verify parseValidElements errors if Valid is a numeric array
+        % containing floating point values.
+            data = [1 2 3];
+            fcn = @() parseValidElements(data, Valid=[1.1 2.1]);
+            testCase.verifyError(fcn, "MATLAB:expectedInteger");
+        end
+
+        function NegativeValidIndicesError(testCase)
+        % Verify parseValidElements errors if Valid is a numeric array
+        % containing negative numbers.
+            data = [1 2 3];
+            fcn = @() parseValidElements(data, Valid=-1);
+            testCase.verifyError(fcn, "MATLAB:notGreater");
+        end
+
+        function ValidIndicesNotInRangeError(testCase)
+        % Verify parseValidElements errors if Valid is a numeric array
+        % whose values are not between 1 and the number of  elements in 
+        % the data array.
+            data = [1 2 3];
+            fcn = @() parseValidElements(data, Valid=0);
+            testCase.verifyError(fcn, "MATLAB:notGreater");
+
+            fcn = @() parseValidElements(data, Valid=4);
+            testCase.verifyError(fcn, "MATLAB:notLessEqual");
+        end
+
+        function LogicalValidTooManyError(testCase)
+        % Verify parseValidElements errors if Valid is a logical array
+        % with more elements than data.
+            data = [1 2 3];
+            fcn = @() parseValidElements(data, Valid=[true false false true]);
+            testCase.verifyError(fcn, "MATLAB:incorrectNumel");
+        end
+
+        function LogicalValidTooFewError(testCase)
+        % Verify parseValidElements errors if Valid is a non-scalar logical
+        % array containing less elements than the data array.
+            data = [1 2 3];
+            fcn = @() parseValidElements(data, Valid=[true false]);
+            testCase.verifyError(fcn, "MATLAB:incorrectNumel");
+
+            fcn = @() parseValidElements(data, Valid=logical.empty(0, 1));
+            testCase.verifyError(fcn, "MATLAB:incorrectNumel");
+        end
+
+        function ValidPrecedenceOverInferNulls(testCase)
+        % Verify that if both InferNulls and Valid are supplied, Valid
+        % takes precedence over InferNulls.
+
+            data = [1 NaN 3];
+            validElements = parseValidElements(data, InferNulls=true, Valid=true);
+            expectedValidElements = [true; true; true];
+            testCase.verifyEqual(validElements, expectedValidElements);
+
+            validElements = parseValidElements(data, InferNulls=false, Valid=[true; false; false]);
+            expectedValidElements = [true; false; false];
+            testCase.verifyEqual(validElements, expectedValidElements);
+
+            validElements = parseValidElements(data, InferNulls=true, Valid=[1 2]);
+            expectedValidElements = [true; true; false];
+            testCase.verifyEqual(validElements, expectedValidElements);
+
+            validElements = parseValidElements(data, InferNulls=false, Valid=1);
+            expectedValidElements = [true; false; false];
+            testCase.verifyEqual(validElements, expectedValidElements);
+        end
+    end
+end
+
+function validElements = parseValidElements(data, opts)
+    arguments
+        data
+        opts.InferNulls = true;
+        opts.Valid
+    end
+    validElements = arrow.args.parseValidElements(data, opts);
+end
\ No newline at end of file
diff --git a/matlab/test/arrow/array/hNumericArray.m b/matlab/test/arrow/array/hNumericArray.m
index 3c6742ef2f..7d3696a8c7 100644
--- a/matlab/test/arrow/array/hNumericArray.m
+++ b/matlab/test/arrow/array/hNumericArray.m
@@ -1,21 +1,22 @@
+% 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.
+
 classdef hNumericArray < matlab.unittest.TestCase
-    % Test class containing shared tests for numeric arrays.
-
-    % 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 (Abstract)
+% Test class containing shared tests for numeric arrays.
+
+      properties (Abstract)
         ArrowArrayClassName(1, 1) string
         ArrowArrayConstructor
         MatlabArrayFcn
@@ -30,7 +31,7 @@ classdef hNumericArray < matlab.unittest.TestCase
 
     methods(TestClassSetup)
         function verifyOnMatlabPath(tc)
-            % Verify the arrow array class is on the MATLAB Search Path.
+        % Verify the arrow array class is on the MATLAB Search Path.
             tc.assertTrue(~isempty(which(tc.ArrowArrayClassName)), ...
                 """" + tc.ArrowArrayClassName + """must be on the MATLAB path. " + ...
                 "Use ""addpath"" to add folders to the MATLAB path.");
@@ -45,9 +46,9 @@ classdef hNumericArray < matlab.unittest.TestCase
         end
 
         function ShallowCopyTest(tc)
-            % By default, NumericArrays do 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.
+        % By default, NumericArrays do 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 = tc.ArrowArrayConstructor(tc.MatlabArrayFcn([1, 2, 3]));
             tc.verifyEqual(A.MatlabArray, tc.MatlabArrayFcn([1, 2, 3]));
             tc.verifyEqual(toMATLAB(A), tc.MatlabArrayFcn([1 2 3]'));
@@ -58,8 +59,8 @@ classdef hNumericArray < matlab.unittest.TestCase
         end
 
         function DeepCopyTest(tc)
-            % Verify NumericArrays does not store shallow copy of the 
-            % MATLAB array if DeepCopy=true was supplied.
+        % Verify NumericArrays does not store shallow copy of the 
+        % MATLAB array if DeepCopy=true was supplied.
             A = tc.ArrowArrayConstructor(tc.MatlabArrayFcn([1, 2, 3]), DeepCopy=true);
             tc.verifyEqual(A.MatlabArray, tc.MatlabArrayFcn([]));
             tc.verifyEqual(toMATLAB(A), tc.MatlabArrayFcn([1 2 3]'));
@@ -83,8 +84,8 @@ classdef hNumericArray < matlab.unittest.TestCase
         end
 
         function MatlabConversion(tc, MakeDeepCopy)
-            % Tests the type-specific conversion methods, e.g. single for
-            % arrow.array.Float32Array, double for array.array.Float64Array
+        % Tests the type-specific conversion methods, e.g. single for
+        % arrow.array.Float32Array, double for array.array.Float64Array
 
             % Create array from a scalar
             A1 = tc.ArrowArrayConstructor(tc.MatlabArrayFcn(100), DeepCopy=MakeDeepCopy);
diff --git a/matlab/test/arrow/array/tFloat32Array.m b/matlab/test/arrow/array/tFloat32Array.m
index e9a3206fbf..c1570db0a5 100644
--- a/matlab/test/arrow/array/tFloat32Array.m
+++ b/matlab/test/arrow/array/tFloat32Array.m
@@ -1,21 +1,21 @@
+% 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.
+
 classdef tFloat32Array < hNumericArray
-    % Tests for arrow.array.Float32rray
+% 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
         ArrowArrayClassName = "arrow.array.Float32Array"
         ArrowArrayConstructor = @arrow.array.Float32Array
diff --git a/matlab/test/arrow/array/tFloat64Array.m b/matlab/test/arrow/array/tFloat64Array.m
index 5358ffc888..7248d88e49 100755
--- a/matlab/test/arrow/array/tFloat64Array.m
+++ b/matlab/test/arrow/array/tFloat64Array.m
@@ -1,21 +1,20 @@
-classdef tFloat64Array < hNumericArray
-    % Tests for arrow.array.Float64Array
-
-    % 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.
+% 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.
     
+classdef tFloat64Array < hNumericArray
+% Tests for arrow.array.Float64Array
 
     properties
         ArrowArrayClassName = "arrow.array.Float64Array"
@@ -79,7 +78,7 @@ classdef tFloat64Array < hNumericArray
             testCase.verifyEqual(arrowArray.Valid, expectedValid);
         end
 
-        function ValidEmpty(testCase, MakeDeepCopy)
+        function EmptyArrayValidBitmap(testCase, MakeDeepCopy)
             % Create an empty 0x0 MATLAB array.
             matlabArray = double.empty(0, 0);
             arrowArray = arrow.array.Float64Array(matlabArray, DeepCopy=MakeDeepCopy);
@@ -96,5 +95,23 @@ classdef tFloat64Array < hNumericArray
             arrowArray = arrow.array.Float64Array(matlabArray, DeepCopy=MakeDeepCopy);
             testCase.verifyEqual(arrowArray.Valid, expectedValid);
         end
+
+        function LogicalValidNVPair(testCase)
+            matlabArray = [1 2 3]; 
+
+            % Supply a logical vector for Valid
+            arrowArray = arrow.array.Float64Array(matlabArray, Valid=[false; true; true]);
+            testCase.verifyEqual(arrowArray.Valid, [false; true; true]);
+            testCase.verifyEqual(toMATLAB(arrowArray), [NaN; 2; 3]);
+        end
+
+        function NumericlValidNVPair(testCase)
+            matlabArray = [1 2 3]; 
+
+            % Supply a numeric vector for Valid 
+            arrowArray = arrow.array.Float64Array(matlabArray, Valid=[1 3]);
+            testCase.verifyEqual(arrowArray.Valid, [true; false; true]);
+            testCase.verifyEqual(toMATLAB(arrowArray), [1; NaN; 3]);
+        end
     end
 end
diff --git a/matlab/test/arrow/array/tInt16Array.m b/matlab/test/arrow/array/tInt16Array.m
index 7ae3a5ead7..02c1e7c410 100644
--- a/matlab/test/arrow/array/tInt16Array.m
+++ b/matlab/test/arrow/array/tInt16Array.m
@@ -1,20 +1,20 @@
-classdef tInt16Array < hNumericArray
-    % Tests for arrow.array.Int16Array
+% 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.
 
-    % 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.
+classdef tInt16Array < hNumericArray
+% Tests for arrow.array.Int16Array
     
     properties
         ArrowArrayClassName = "arrow.array.Int16Array"
diff --git a/matlab/test/arrow/array/tInt32Array.m b/matlab/test/arrow/array/tInt32Array.m
index 7b63c5c57c..705810e6e8 100644
--- a/matlab/test/arrow/array/tInt32Array.m
+++ b/matlab/test/arrow/array/tInt32Array.m
@@ -1,20 +1,20 @@
-classdef tInt32Array < hNumericArray
-    % Tests for arrow.array.Int32Array
+% 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.
 
-    % 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.
+classdef tInt32Array < hNumericArray
+% Tests for arrow.array.Int32Array
     
     properties
         ArrowArrayClassName = "arrow.array.Int32Array"
diff --git a/matlab/test/arrow/array/tInt64Array.m b/matlab/test/arrow/array/tInt64Array.m
index 41270ef240..c873059edf 100644
--- a/matlab/test/arrow/array/tInt64Array.m
+++ b/matlab/test/arrow/array/tInt64Array.m
@@ -1,21 +1,21 @@
+% 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.
+
 classdef tInt64Array < hNumericArray
-    % Tests for arrow.array.Int64Array
+% Tests for arrow.array.Int64Array
 
-    % 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
         ArrowArrayClassName = "arrow.array.Int64Array"
         ArrowArrayConstructor = @arrow.array.Int64Array
diff --git a/matlab/test/arrow/array/tInt8Array.m b/matlab/test/arrow/array/tInt8Array.m
index 76f96f01e4..e7cf729fb8 100644
--- a/matlab/test/arrow/array/tInt8Array.m
+++ b/matlab/test/arrow/array/tInt8Array.m
@@ -1,20 +1,20 @@
-classdef tInt8Array < hNumericArray
-    % Tests for arrow.array.Int8Array
+% 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.
 
-    % 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.
+classdef tInt8Array < hNumericArray
+% Tests for arrow.array.Int8Array
     
     properties
         ArrowArrayClassName = "arrow.array.Int8Array"
diff --git a/matlab/test/arrow/array/tUInt16Array.m b/matlab/test/arrow/array/tUInt16Array.m
index d5cbbc9a4a..7d1ba1618a 100644
--- a/matlab/test/arrow/array/tUInt16Array.m
+++ b/matlab/test/arrow/array/tUInt16Array.m
@@ -1,20 +1,20 @@
-classdef tUInt16Array < hNumericArray
-    % Tests for arrow.array.UInt16Array
+% 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.
 
-    % 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.
+classdef tUInt16Array < hNumericArray
+% Tests for arrow.array.UInt16Array
     
     properties
         ArrowArrayClassName = "arrow.array.UInt16Array"
diff --git a/matlab/test/arrow/array/tUInt32Array.m b/matlab/test/arrow/array/tUInt32Array.m
index 0223c1b6fc..54a9f1600e 100644
--- a/matlab/test/arrow/array/tUInt32Array.m
+++ b/matlab/test/arrow/array/tUInt32Array.m
@@ -1,20 +1,20 @@
+% 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.
+
 classdef tUInt32Array < hNumericArray
     % Tests for arrow.array.UInt32Array
-
-    % 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
         ArrowArrayClassName = "arrow.array.UInt32Array"
diff --git a/matlab/test/arrow/array/tUInt64Array.m b/matlab/test/arrow/array/tUInt64Array.m
index ba5adc66a6..56c0da227e 100644
--- a/matlab/test/arrow/array/tUInt64Array.m
+++ b/matlab/test/arrow/array/tUInt64Array.m
@@ -1,21 +1,21 @@
+% 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.
+    
 classdef tUInt64Array < hNumericArray
-    % Tests for arrow.array.UInt64Array
+% Tests for arrow.array.UInt64Array
 
-    % 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
         ArrowArrayClassName = "arrow.array.UInt64Array"
         ArrowArrayConstructor = @arrow.array.UInt64Array
diff --git a/matlab/test/arrow/array/tUInt8Array.m b/matlab/test/arrow/array/tUInt8Array.m
index 9dd8c548f9..37fa378a91 100644
--- a/matlab/test/arrow/array/tUInt8Array.m
+++ b/matlab/test/arrow/array/tUInt8Array.m
@@ -1,20 +1,20 @@
-classdef tUInt8Array < hNumericArray
-    % Tests for arrow.array.UInt8Array
+% 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.
 
-    % 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.
+classdef tUInt8Array < hNumericArray
+% Tests for arrow.array.UInt8Array
     
     properties
         ArrowArrayClassName = "arrow.array.UInt8Array"