@@ -715,6 +715,17 @@ def is_sequence_of_strings(obj):
715715 return True
716716
717717
718+ def is_hashable (obj ):
719+ """
720+ Returns true if *obj* can be hashed
721+ """
722+ try :
723+ hash (obj )
724+ except TypeError :
725+ return False
726+ return True
727+
728+
718729def is_writable_file_like (obj ):
719730 'return true if *obj* looks like a file object with a *write* method'
720731 return hasattr (obj , 'write' ) and six .callable (obj .write )
@@ -1863,39 +1874,46 @@ def delete_masked_points(*args):
18631874 return margs
18641875
18651876
1866- def boxplot_stats (X , whis = 1.5 , bootstrap = None , labels = None ):
1867- '''
1868- Returns list of dictionaries of staticists to be use to draw a series of
1869- box and whisker plots. See the `Returns` section below to the required
1870- keys of the dictionary. Users can skip this function and pass a user-
1871- defined set of dictionaries to the new `axes.bxp` method instead of
1872- relying on MPL to do the calcs.
1877+ def boxplot_stats (X , whis = 1.5 , bootstrap = None , labels = None ,
1878+ autorange = False ):
1879+ """
1880+ Returns list of dictionaries of statistics used to draw a series
1881+ of box and whisker plots. The `Returns` section enumerates the
1882+ required keys of the dictionary. Users can skip this function and
1883+ pass a user-defined set of dictionaries to the new `axes.bxp` method
1884+ instead of relying on MPL to do the calculations.
18731885
18741886 Parameters
18751887 ----------
18761888 X : array-like
1877- Data that will be represented in the boxplots. Should have 2 or fewer
1878- dimensions.
1889+ Data that will be represented in the boxplots. Should have 2 or
1890+ fewer dimensions.
18791891
18801892 whis : float, string, or sequence (default = 1.5)
1881- As a float, determines the reach of the whiskers past the first and
1882- third quartiles (e.g., Q3 + whis*IQR, QR = interquartile range, Q3-Q1).
1883- Beyond the whiskers, data are considered outliers and are plotted as
1884- individual points. Set this to an unreasonably high value to force the
1885- whiskers to show the min and max data. Alternatively, set this to an
1886- ascending sequence of percentile (e.g., [5, 95]) to set the whiskers
1887- at specific percentiles of the data. Finally, can `whis` be the
1888- string 'range' to force the whiskers to the min and max of the data.
1889- In the edge case that the 25th and 75th percentiles are equivalent,
1890- `whis` will be automatically set to 'range'
1891-
1892- bootstrap : int or None (default)
1893- Number of times the confidence intervals around the median should
1894- be bootstrapped (percentile method).
1895-
1896- labels : sequence
1897- Labels for each dataset. Length must be compatible with dimensions
1898- of `X`
1893+ As a float, determines the reach of the whiskers past the first
1894+ and third quartiles (e.g., Q3 + whis*IQR, QR = interquartile
1895+ range, Q3-Q1). Beyond the whiskers, data are considered outliers
1896+ and are plotted as individual points. This can be set this to an
1897+ ascending sequence of percentile (e.g., [5, 95]) to set the
1898+ whiskers at specific percentiles of the data. Finally, `whis`
1899+ can be the string ``'range'`` to force the whiskers to the
1900+ minimum and maximum of the data. In the edge case that the 25th
1901+ and 75th percentiles are equivalent, `whis` can be automatically
1902+ set to ``'range'`` via the `autorange` option.
1903+
1904+ bootstrap : int, optional
1905+ Number of times the confidence intervals around the median
1906+ should be bootstrapped (percentile method).
1907+
1908+ labels : array-like, optional
1909+ Labels for each dataset. Length must be compatible with
1910+ dimensions of `X`.
1911+
1912+ autorange : bool, optional (False)
1913+ When `True` and the data are distributed such that the 25th and
1914+ 75th percentiles are equal, ``whis`` is set to ``'range'`` such
1915+ that the whisker ends are at the minimum and maximum of the
1916+ data.
18991917
19001918 Returns
19011919 -------
@@ -1920,8 +1938,8 @@ def boxplot_stats(X, whis=1.5, bootstrap=None, labels=None):
19201938
19211939 Notes
19221940 -----
1923- Non-bootstrapping approach to confidence interval uses Gaussian-based
1924- asymptotic approximation:
1941+ Non-bootstrapping approach to confidence interval uses Gaussian-
1942+ based asymptotic approximation:
19251943
19261944 .. math::
19271945
@@ -1931,7 +1949,7 @@ def boxplot_stats(X, whis=1.5, bootstrap=None, labels=None):
19311949 McGill, R., Tukey, J.W., and Larsen, W.A. (1978) "Variations of
19321950 Boxplots", The American Statistician, 32:12-16.
19331951
1934- '''
1952+ """
19351953
19361954 def _bootstrap_median (data , N = 5000 ):
19371955 # determine 95% confidence intervals of the median
@@ -2011,7 +2029,7 @@ def _compute_conf_interval(data, med, iqr, bootstrap):
20112029
20122030 # interquartile range
20132031 stats ['iqr' ] = q3 - q1
2014- if stats ['iqr' ] == 0 :
2032+ if stats ['iqr' ] == 0 and autorange :
20152033 whis = 'range'
20162034
20172035 # conf. interval around median
0 commit comments