Skip to content

Commit

Permalink
horzcat/vertcat: add tests for horzcat as well
Browse files Browse the repository at this point in the history
  • Loading branch information
cbm755 committed Nov 12, 2024
1 parent edcaec2 commit 90af895
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
31 changes: 30 additions & 1 deletion inst/@sym/horzcat.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%% SPDX-License-Identifier: GPL-3.0-or-later
%% Copyright (C) 2014-2017, 2019, 2024 Colin B. Macdonald
%% Copyright (C) 2014-2017, 2019, 2022, 2024 Colin B. Macdonald
%% Copyright (C) 2022 Alex Vong
%%
%% This file is part of OctSymPy.
Expand Down Expand Up @@ -117,8 +117,37 @@
%! q = sym(ones(3, 0));
%! w = horzcat(v, q);

%!error <ShapeError>
%! z30 = sym (zeros (3, 0));
%! z40 = sym (zeros (4, 0));
%! % Note Issue #1238: unclear error message:
%! % [z30 z40];
%! % but this gives the ShapeError
%! horzcat(z30, z40);

%!test
%! % special case for the 0x0 empty: no error
%! z00 = sym (zeros (0, 0));
%! z30 = sym (zeros (3, 0));
%! [z00 z30];

%!test
%! % issue #700
%! A = sym ([1 2]);
%! B = simplify (A);
%! assert (isequal ([B A], [A B]))

%!test
%! % issue #1236, correct empty sizes
%! syms x
%! z00 = sym (zeros (0, 0));
%! z30 = sym (zeros (3, 0));
%! z03 = sym (zeros (0, 3));
%! z04 = sym (zeros (0, 4));
%! assert (size ([z00 z00]), [0 0])
%! assert (size ([z00 z03]), [0 3])
%! assert (size ([z03 z03]), [0 6])
%! assert (size ([z03 z04]), [0 7])
%! assert (size ([z03 z00 z04]), [0 7])
%! assert (size ([z30 z30]), [3 0])
%! assert (size ([z30 z30 z30]), [3 0])
22 changes: 11 additions & 11 deletions inst/@sym/vertcat.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@
%! % but this gives the ShapeError
%! vertcat(z03, z04);

%!test
%! % special case for the 0x0 empty: no error
%! z00 = sym (zeros (0, 0));
%! z03 = sym (zeros (0, 3));
%! [z00; z03];

%!test
%! syms x
%! a = [x; sym([]) []];
%! assert (isequal (a, x))

%!test
%! % Octave 3.6 bug: should pass on 3.8.1 and matlab
%! a = [sym(1) 2];
Expand Down Expand Up @@ -176,14 +187,3 @@
%! assert (size ([z30; z00; z30]), [6 0])
%! assert (size ([z03; z03]), [0 3])
%! assert (size ([z03; z03; z03]), [0 3])

%!test
%! % special case for the 0x0 empty: no error
%! z00 = sym (zeros (0, 0));
%! z03 = sym (zeros (0, 3));
%! [z00; z03];

%!test
%! syms x
%! a = [x; sym([]) []];
%! assert (isequal (a, x))

0 comments on commit 90af895

Please sign in to comment.