changeset 23163:af64b6b61db9

histc.m: Return empty output when EDGES is empty for ML compatibility (bug #49944). * histc.m: Check empty EDGES input and issue warning. Immediately return from function. Modify BIST test for new behavior.
author Rik <rik@octave.org>
date Tue, 07 Feb 2017 21:55:34 -0800
parents 6edad6ad4da9
children 99ca557fd34f
files scripts/statistics/base/histc.m
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/statistics/base/histc.m	Tue Feb 07 10:30:31 2017 -0800
+++ b/scripts/statistics/base/histc.m	Tue Feb 07 21:55:34 2017 -0800
@@ -54,7 +54,9 @@
 
   num_edges = numel (edges);
   if (num_edges == 0)
-    error ("histc: EDGES must not be empty");
+    warning ("histc: empty EDGES specified\n");
+    n = idx = [];
+    return;
   endif
 
   if (! isreal (edges))
@@ -172,5 +174,5 @@
 %!error histc (1)
 %!error histc (1, 2, 3, 4)
 %!error histc ([1:10 1+i], 2)
-%!error histc (1:10, [])
+%!warning <empty EDGES specified> histc (1:10, []);
 %!error histc (1, 1, 3)