Skip to content

Commit

Permalink
Make arrow.buffer.Buffer.fromMATLAB error if given a sparse or comple…
Browse files Browse the repository at this point in the history
…x array
  • Loading branch information
sgilmore10 committed Oct 4, 2023
1 parent 29edeb1 commit 37c83ed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion matlab/src/matlab/+arrow/+buffer/Buffer.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
methods (Static, Hidden)
function buffer = fromMATLAB(data)
arguments
data(:, 1) {mustBeNumeric}
data(:, 1) {mustBeNumeric, mustBeNonsparse, mustBeReal}
end

% Re-interpret bit pattern as uint8s without changing the
Expand Down
18 changes: 18 additions & 0 deletions matlab/test/arrow/buffer/tBuffer.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ function fromMATLABNonNumericError(testCase)
testCase.verifyError(fcn, "MATLAB:validators:mustBeNumeric");
end

function fromMATLABNonRealError(testCase)
% Verify fromMATLAB throws an error if given a complex
% numeric array as input.
import arrow.buffer.Buffer

fcn = @() Buffer.fromMATLAB(10 + 3i);
testCase.verifyError(fcn, "MATLAB:validators:mustBeReal");
end

function fromMATLABNonSparseError(testCase)
% Verify fromMATLAB throws an error if given a sparse
% numeric array as input.
import arrow.buffer.Buffer

fcn = @() Buffer.fromMATLAB(sparse(ones([5 1])));
testCase.verifyError(fcn, "MATLAB:validators:mustBeNonsparse");
end

function NumBytesNoSetter(testCase)
% Verifies the NumBytes property is not settable.

Expand Down

0 comments on commit 37c83ed

Please sign in to comment.