annotate scripts/statistics/mode.m @ 31887:96ed8d1d0c59

mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690) * mode.m: Add isempty() block to return compatible forms of all outputs. Adjust dim input validation to ensure empty, Inf, NaN and negative inputs trigger expected error. Add BISTS for empty input handling and dim input validation. * NEWS.9.md: Note changes under Matlab compatibility.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Sat, 04 Mar 2023 00:59:48 -0500
parents 597f3ee61a48
children 8e4f14837db2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30875
diff changeset
3 ## Copyright (C) 2007-2023 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
7 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
8 ## This file is part of Octave.
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
14 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
19 ##
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7007
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
25
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
26 ## -*- texinfo -*-
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
27 ## @deftypefn {} {@var{m} =} mode (@var{x})
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30564
diff changeset
28 ## @deftypefnx {} {@var{m} =} mode (@var{x}, @var{dim})
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20803
diff changeset
29 ## @deftypefnx {} {[@var{m}, @var{f}, @var{c}] =} mode (@dots{})
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
30 ## Compute the most frequently occurring value in a dataset (mode).
20174
d9341b422488 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
31 ##
10687
a8ce6bdecce5 Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents: 10669
diff changeset
32 ## @code{mode} determines the frequency of values along the first non-singleton
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
33 ## dimension and returns the value with the highest frequency. If two, or
10687
a8ce6bdecce5 Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents: 10669
diff changeset
34 ## more, values have the same frequency @code{mode} returns the smallest.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
35 ##
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
36 ## If the optional argument @var{dim} is given, operate along this dimension.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
37 ##
10687
a8ce6bdecce5 Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents: 10669
diff changeset
38 ## The return variable @var{f} is the number of occurrences of the mode in
20174
d9341b422488 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
39 ## the dataset.
d9341b422488 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
40 ##
d9341b422488 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
41 ## The cell array @var{c} contains all of the elements with the maximum
d9341b422488 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
42 ## frequency.
12575
d0b799dafede Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
43 ## @seealso{mean, median}
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
44 ## @end deftypefn
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
45
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
46 function [m, f, c] = mode (x, dim)
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
47
28789
28de41192f3c Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents: 27923
diff changeset
48 if (nargin < 1)
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
49 print_usage ();
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
50 endif
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
51
12656
6b2f14af2360 Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents: 12585
diff changeset
52 if (! (isnumeric (x) || islogical (x)))
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
53 error ("mode: X must be a numeric vector or matrix");
10669
cab3b148d4e4 Improve validation of input arguments for base statistics functions.
Rik <octave@nomad.inbox5.com>
parents: 9245
diff changeset
54 endif
cab3b148d4e4 Improve validation of input arguments for base statistics functions.
Rik <octave@nomad.inbox5.com>
parents: 9245
diff changeset
55
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
56 nd = ndims (x);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
57 sz = size (x);
12656
6b2f14af2360 Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents: 12585
diff changeset
58 if (nargin < 2)
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
59 ## Find the first non-singleton dimension.
31887
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
60 (dim = find (sz != 1, 1)) || (dim = 1);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
61 else
31887
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
62 if (! (isscalar (dim) && dim > 0 && rem (dim, 1) == 0))
10669
cab3b148d4e4 Improve validation of input arguments for base statistics functions.
Rik <octave@nomad.inbox5.com>
parents: 9245
diff changeset
63 error ("mode: DIM must be an integer and a valid dimension");
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
64 endif
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
65 endif
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
66
31887
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
67 if (isempty (x))
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
68 ## Empty x produces NaN for m, 0 for f, , but m, f and c
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
69 ## shape depends on size of x.
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
70 if ((nargin == 1) && (nd == 2) && (sz == [0 0]))
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
71 f = 0; # f always a double even if x is single.
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
72 if (isa (x, "single"))
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
73 m = NaN ("single");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
74 c = {(NaN (0, 1, "single"))};
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
75 else
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
76 m = NaN;
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
77 c = {(NaN (0, 1))};
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
78 endif
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
79 else
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
80 sz(dim) = 1;
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
81 f = zeros (sz); # f always a double even if x is single.
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
82 c = cell (sz);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
83 if (isa (x, "single"))
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
84 m = (NaN (sz, "single"));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
85 c(:) = NaN (1, 0, "single");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
86 else
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
87 m = NaN (sz);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
88 c(:) = NaN (1, 0);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
89 endif
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
90 endif
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
91 return
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
92 endif
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
93
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
94 if (dim > nd || sz(dim) == 1)
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
95 ## Special case of mode over singleton dimension.
21364
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
96 m = x;
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
97 f = ones (size (x));
21604
d7a268e68e69 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 21364
diff changeset
98 c = num2cell (x);
21364
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
99 return;
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
100 endif
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
101
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
102 sz2 = sz;
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
103 sz2(dim) = 1;
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
104 sz3 = ones (1, nd);
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
105 sz3(dim) = sz(dim);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
106
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
107 if (issparse (x))
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
108 t2 = sparse (sz(1), sz(2));
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
109 else
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
110 t2 = zeros (sz);
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
111 endif
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
112
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
113 if (dim != 1)
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
114 perm = [dim, 1:dim-1, dim+1:nd];
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
115 t2 = permute (t2, perm);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
116 endif
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
117
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
118 xs = sort (x, dim);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
119 t = cat (dim, true (sz2), diff (xs, 1, dim) != 0);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
120
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
121 if (dim != 1)
12656
6b2f14af2360 Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents: 12585
diff changeset
122 t2(permute (t != 0, perm)) = diff ([find(permute (t, perm))(:); prod(sz)+1]);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
123 f = max (ipermute (t2, perm), [], dim);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
124 xs = permute (xs, perm);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
125 else
12656
6b2f14af2360 Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents: 12585
diff changeset
126 t2(t) = diff ([find(t)(:); prod(sz)+1]);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
127 f = max (t2, [], dim);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
128 endif
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
129
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
130 c = cell (sz2);
7287
3f29467c1667 [project @ 2007-12-11 17:03:32 by jwe]
jwe
parents: 7208
diff changeset
131 if (issparse (x))
3f29467c1667 [project @ 2007-12-11 17:03:32 by jwe]
jwe
parents: 7208
diff changeset
132 m = sparse (sz2(1), sz2(2));
3f29467c1667 [project @ 2007-12-11 17:03:32 by jwe]
jwe
parents: 7208
diff changeset
133 else
12585
4e32a1bb9096 mode.m, quantile.m: Return output of same class as input.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
134 m = zeros (sz2, class (x));
7287
3f29467c1667 [project @ 2007-12-11 17:03:32 by jwe]
jwe
parents: 7208
diff changeset
135 endif
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
136 for i = 1 : prod (sz2)
12656
6b2f14af2360 Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents: 12585
diff changeset
137 c{i} = xs(t2(:, i) == f(i), i);
6b2f14af2360 Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents: 12585
diff changeset
138 m(i) = c{i}(1);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
139 endfor
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 21604
diff changeset
140
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
141 endfunction
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
142
12656
6b2f14af2360 Overhaul functions in statistics/base directory.
Rik <octave@nomad.inbox5.com>
parents: 12585
diff changeset
143
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
144 %!test
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
145 %! [m, f, c] = mode (toeplitz (1:5));
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
146 %! assert (m, [1,2,2,2,1]);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
147 %! assert (f, [1,2,2,2,1]);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
148 %! assert (c, {[1;2;3;4;5],[2],[2;3],[2],[1;2;3;4;5]});
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
149 %!test
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
150 %! [m, f, c] = mode (toeplitz (1:5), 2);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
151 %! assert (m, [1;2;2;2;1]);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
152 %! assert (f, [1;2;2;2;1]);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
153 %! assert (c, {[1;2;3;4;5];[2];[2;3];[2];[1;2;3;4;5]});
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
154 %!test
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
155 %! a = sprandn (32, 32, 0.05);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20174
diff changeset
156 %! sp0 = sparse (0);
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
157 %! [m, f, c] = mode (a);
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents:
diff changeset
158 %! [m2, f2, c2] = mode (full (a));
7287
3f29467c1667 [project @ 2007-12-11 17:03:32 by jwe]
jwe
parents: 7208
diff changeset
159 %! assert (m, sparse (m2));
3f29467c1667 [project @ 2007-12-11 17:03:32 by jwe]
jwe
parents: 7208
diff changeset
160 %! assert (f, sparse (f2));
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20174
diff changeset
161 %! c_exp(1:length (a)) = { sp0 };
12930
7bd29d875af1 mode.m: Eliminate cellfun usage in assert tests
Rik <octave@nomad.inbox5.com>
parents: 12656
diff changeset
162 %! assert (c ,c_exp);
21364
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
163 %! assert (c2,c_exp);
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
164
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
165 %!assert (mode ([2,3,1,2,3,4],1),[2,3,1,2,3,4])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
166 %!assert (mode ([2,3,1,2,3,4],2),2)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
167 %!assert (mode ([2,3,1,2,3,4]),2)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
168 %!assert (mode (single ([2,3,1,2,3,4])), single (2))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
169 %!assert (mode (int8 ([2,3,1,2,3,4])), int8 (2))
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
170
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
171 %!assert (mode ([2;3;1;2;3;4],1),2)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
172 %!assert (mode ([2;3;1;2;3;4],2),[2;3;1;2;3;4])
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
173 %!assert (mode ([2;3;1;2;3;4]),2)
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
174
21364
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
175 %!test
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
176 %! x = magic (3);
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
177 %! [m, f, c] = mode (x, 3);
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
178 %! assert (m, x);
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
179 %! assert (f, ones (3,3));
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
180 %! assert (c, num2cell (x));
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
181
31887
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
182 %!test
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
183 %! x = single (magic (3));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
184 %! [m, f, c] = mode (x, 3);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
185 %! assert (class (m), "single");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
186 %! assert (class (f), "double");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
187 %! assert (class (c), "cell");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
188 %! assert (class (c(1)), "cell");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
189 %! assert (class (c{1}), "single");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
190
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
191 %!shared x
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
192 %! x(:,:,1) = toeplitz (1:3);
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
193 %! x(:,:,2) = circshift (toeplitz (1:3), 1);
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
194 %! x(:,:,3) = circshift (toeplitz (1:3), 2);
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
195 %!test
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
196 %! [m, f, c] = mode (x, 1);
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
197 %! assert (reshape (m, [3, 3]), [1 1 1; 2 2 2; 1 1 1]);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
198 %! assert (reshape (f, [3, 3]), [1 1 1; 2 2 2; 1 1 1]);
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
199 %! c = reshape (c, [3, 3]);
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
200 %! assert (c{1}, [1; 2; 3]);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
201 %! assert (c{2}, 2);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
202 %! assert (c{3}, [1; 2; 3]);
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
203 %!test
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
204 %! [m, f, c] = mode (x, 2);
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
205 %! assert (reshape (m, [3, 3]), [1 1 2; 2 1 1; 1 2 1]);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
206 %! assert (reshape (f, [3, 3]), [1 1 2; 2 1 1; 1 2 1]);
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
207 %! c = reshape (c, [3, 3]);
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
208 %! assert (c{1}, [1; 2; 3]);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
209 %! assert (c{2}, 2);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
210 %! assert (c{3}, [1; 2; 3]);
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
211 %!test
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
212 %! [m, f, c] = mode (x, 3);
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
213 %! assert (reshape (m, [3, 3]), [1 2 1; 1 2 1; 1 2 1]);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
214 %! assert (reshape (f, [3, 3]), [1 2 1; 1 2 1; 1 2 1]);
7606
704b7a1098d0 Fix for mode.m NDArrays and row vectors
David Bateman <dbateman@free.fr>
parents: 7287
diff changeset
215 %! c = reshape (c, [3, 3]);
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
216 %! assert (c{1}, [1; 2; 3]);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
217 %! assert (c{2}, [1; 2; 3]);
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
218 %! assert (c{3}, [1; 2; 3]);
31887
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
219 %!shared ## Clear shared to prevent variable echo for any later test failures
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
220
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
221 ## Test empty inputs
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
222 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
223 %! [m, f, c] = mode ([]);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
224 %! assert (m, NaN);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
225 %! assert (f, 0);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
226 %! assert (c, {(NaN (0, 1))});
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
227 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
228 %! [m, f, c] = mode (single ([]));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
229 %! assert (class (m), "single");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
230 %! assert (class (f), "double");
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
231 %! assert (c, {(single (NaN (0, 1)))});
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
232 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
233 %! [m, f, c] = mode ([], 1);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
234 %! assert (m, NaN (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
235 %! assert (f, zeros (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
236 %! assert (c, cell (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
237 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
238 %! [m, f, c] = mode ([], 2);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
239 %! assert (m, NaN (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
240 %! assert (f, zeros (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
241 %! assert (c, cell(0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
242 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
243 %! [m, f, c] = mode ([], 3);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
244 %! assert (m, []);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
245 %! assert (f, []);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
246 %! assert (c, cell (0, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
247 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
248 %! [m, f, c] = mode (ones (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
249 %! assert (m, NaN);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
250 %! assert (f, 0);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
251 %! assert (c, {(NaN (1, 0))});
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
252 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
253 %! [m, f, c] = mode (ones (0, 1), 1);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
254 %! assert (m, NaN);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
255 %! assert (f, 0);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
256 %! assert (c, {(NaN (1, 0))});
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
257 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
258 %! [m, f, c] = mode (ones (0, 1), 2);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
259 %! assert (m, NaN (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
260 %! assert (f, zeros (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
261 %! assert (c, cell (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
262 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
263 %! [m, f, c] = mode (ones (0, 1), 3);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
264 %! assert (m, NaN (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
265 %! assert (f, zeros (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
266 %! assert (c, cell (0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
267 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
268 %! [m, f, c] = mode (ones (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
269 %! assert (m, NaN);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
270 %! assert (f, 0);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
271 %! assert (c, {(NaN (1, 0))});
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
272 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
273 %! [m, f, c] = mode (ones (1, 0), 1);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
274 %! assert (m, NaN (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
275 %! assert (f, zeros (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
276 %! assert (c, cell (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
277 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
278 %! [m, f, c] = mode (ones (1, 0), 2);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
279 %! assert (m, NaN);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
280 %! assert (f, 0);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
281 %! assert (c, {(NaN (1, 0))});
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
282 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
283 %! [m, f, c] = mode (ones (1, 0), 3);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
284 %! assert (m, NaN (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
285 %! assert (f, zeros (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
286 %! assert (c, cell (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
287 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
288 %! [m, f, c] = mode (ones (0, 0, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
289 %! assert (m, NaN (1, 0, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
290 %! assert (f, zeros (1, 0, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
291 %! assert (c, cell (1, 0, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
292 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
293 %! [m, f, c] = mode (ones (0, 0, 0), 1);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
294 %! assert (m, NaN (1, 0, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
295 %! assert (f, zeros (1, 0, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
296 %! assert (c, cell (1, 0, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
297 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
298 %! [m, f, c] = mode (ones (0, 0, 0), 2);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
299 %! assert (m, NaN (0, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
300 %! assert (f, zeros (0, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
301 %! assert (c, cell (0, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
302 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
303 %! [m, f, c] = mode (ones (0, 0, 0), 3);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
304 %! assert (m, NaN (0, 0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
305 %! assert (f, zeros (0, 0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
306 %! assert (c, cell (0, 0, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
307 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
308 %! [m, f, c] = mode (ones (1, 5, 0), 2);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
309 %! assert (m, NaN (1, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
310 %! assert (f, zeros (1, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
311 %! assert (c, cell (1, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
312 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
313 %! [m, f, c] = mode (ones (5, 1, 0), 2);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
314 %! assert (m, NaN (5, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
315 %! assert (f, zeros (5, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
316 %! assert (c, cell (5, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
317 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
318 %! [m, f, c] = mode (ones (2, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
319 %! assert (m, NaN (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
320 %! assert (f, zeros (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
321 %! assert (c, cell (1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
322 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
323 %! [m, f, c] = mode (ones (0, 2));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
324 %! assert (m, NaN (1, 2));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
325 %! assert (f, zeros (1, 2));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
326 %! assert (c, {(NaN (1, 0)),(NaN (1, 0))});
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
327 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
328 %! [m, f, c] = mode (ones (1, 1, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
329 %! assert (m, NaN (1, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
330 %! assert (f, zeros (1, 1));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
331 %! assert (c, {(NaN (1, 0))});
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
332 %!test <*48690>
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
333 %! [m, f, c] = mode (ones (1, 1, 1, 0), 1);
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
334 %! assert (m, NaN (1, 1, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
335 %! assert (f, zeros (1, 1, 1, 0));
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
336 %! assert (c, cell (1,1,1,0));
11436
e151e23f73bc Overhaul base statistics functions and documentation of same.
Rik <octave@nomad.inbox5.com>
parents: 11191
diff changeset
337
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
338 ## Test input validation
28896
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 28789
diff changeset
339 %!error <Invalid call> mode ()
21364
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
340 %!error <X must be a numeric> mode ({1 2 3})
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
341 %!error <DIM must be an integer> mode (1, ones (2,2))
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
342 %!error <DIM must be an integer> mode (1, 1.5)
03ff9371596b mode.m: Allow operation over non-existent dimension (bug #33523).
Rik <rik@octave.org>
parents: 20852
diff changeset
343 %!error <DIM must be .* a valid dimension> mode (1, 0)
31887
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
344 %!error <DIM must be .* a valid dimension> mode (1, -1)
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
345 %!error <DIM must be .* a valid dimension> mode (1, -1.5)
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
346 %!error <DIM must be .* a valid dimension> mode (1, Inf)
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
347 %!error <DIM must be .* a valid dimension> mode (1, NaN)
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
348
96ed8d1d0c59 mode.m: Emtpy input produces Matlab compatible NaN output (bug #48690)
Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
parents: 31706
diff changeset
349