[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: an unreported fix to union.m
From: |
Juan Pablo Carbajal |
Subject: |
Re: an unreported fix to union.m |
Date: |
Fri, 31 Jul 2015 14:08:08 +0200 |
On Fri, Jul 31, 2015 at 1:02 PM, Juan Pablo Carbajal
<address@hidden> wrote:
> Hi,
>
> The developer of this software (see commments)
> http://journal.frontiersin.org/article/10.3389/fninf.2013.00008/abstract
>
> fixed an compatibility issue in union.m of octave. Of course the fix
> is not compatible with Octave standards. However if we need this fix I
> will port it.
>
> The difference is
>
> --- /home/juanpi/Devel/octave/default/scripts/set/union.m
> +++ /home/juanpi/Downloads/ndt.1.0.4_exported/octave_code/union.m
> @@ -40,7 +40,7 @@
> ## @seealso{unique, intersect, setdiff, setxor, ismember}
> ## @end deftypefn
>
> -## Author: jwe
> +## Author: jwe, modified by Ethan Meyers 2015
>
> function [y, ia, ib] = union (a, b, varargin)
>
> @@ -48,11 +48,35 @@
> print_usage ();
> endif
>
> - [a, b] = validsetargs ("union", a, b, varargin{:});
> +
>
> by_rows = nargin == 3;
> isrowvec = isvector (a) && isvector (b) && isrow (a) && isrow (b);
>
> +
> + % Modified by Ethan to deal with creating a union between an empty
> vector and a cell array
> + if isempty(a)
> + if by_rows
> + y = unique(b, 'rows');
> + else
> + y = unique(b);
> + end
> + return
> + end
> +
> + if isempty(b)
> + if by_rows
> + y = unique(a, 'rows');
> + else
> + y = unique(a);
> + end
> + return
> + end
> +
> +
> + [a, b] = validsetargs ("union", a, b, varargin{:});
> +
> +
> if (by_rows)
> y = [a; b];
> else
>
>
> Comments?
I have condensed the changes into a single line correction and added
some tests. Please verify that indeed the output is compatible with
Matlab's
https://savannah.gnu.org/patch/index.php?8710