Commits


sgilmore10 authored and GitHub committed 788760570d8
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 <sgilmore@mathworks.com> Co-authored-by: sgilmore10 <74676073+sgilmore10@users.noreply.github.com> Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Signed-off-by: Sutou Kouhei <kou@clear-code.com>