[Numpy-svn] r5088 - trunk/numpy/lib

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Apr 25 17:04:17 EDT 2008


Author: dhuard
Date: 2008-04-25 16:04:16 -0500 (Fri, 25 Apr 2008)
New Revision: 5088

Modified:
   trunk/numpy/lib/function_base.py
Log:
histogram: an error is raised for varying bin widths only if normed=True.

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2008-04-25 18:13:46 UTC (rev 5087)
+++ trunk/numpy/lib/function_base.py	2008-04-25 21:04:16 UTC (rev 5088)
@@ -173,16 +173,26 @@
             if range is None:
                 range = (a.min(), a.max())
             else:
-                warnings.warn("""Outliers handling will change in version 1.2.  
-                    Please read the docstring for details.""", FutureWarning)
+                warnings.warn("""
+                Outliers handling will change in version 1.2.  
+                Please read the docstring for details.""", FutureWarning)
             mn, mx = [mi+0.0 for mi in range]
             if mn == mx:
                 mn -= 0.5
                 mx += 0.5
             bins = linspace(mn, mx, bins, endpoint=False)
         else:
-            raise ValueError, 'Use new=True to pass bin edges explicitly.'
+            if normed: 
+                raise ValueError, 'Use new=True to pass bin edges explicitly.'
+            warnings.warn("""
+            The semantic for bins will change in version 1.2. 
+            The bins will become the bin edges, instead of the left bin edges.
+            """, FutureWarning)
+            bins = asarray(bins)
+            if (np.diff(bins) < 0).any():
+                raise AttributeError, 'bins must increase monotonically.'
             
+            
         if weights is not None:
             raise ValueError, 'weights are only available with new=True.'
             




More information about the Numpy-svn mailing list