@@ -1744,7 +1744,7 @@ def _compute_conf_interval(data, med, iqr, bootstrap):
17441744 bxpstats = []
17451745
17461746 # convert X to a list of lists
1747- X = _reshape_2D (X )
1747+ X = _reshape_2D (X , "X" )
17481748
17491749 ncols = len (X )
17501750 if labels is None :
@@ -1974,14 +1974,16 @@ def _check_1d(x):
19741974 return np .atleast_1d (x )
19751975
19761976
1977- def _reshape_2D (X ):
1977+ def _reshape_2D (X , name ):
19781978 """
1979- Converts a non-empty list or an ndarray of two or fewer dimensions
1980- into a list of iterable objects so that in
1979+ Use Fortran ordering to convert ndarrays and lists of iterables to lists of
1980+ 1D arrays.
19811981
1982- for v in _reshape_2D(X):
1982+ Lists of iterables are converted by applying `np.asarray` to each of their
1983+ elements. 1D ndarrays are returned in a singleton list containing them.
1984+ 2D ndarrays are converted to the list of their *columns*.
19831985
1984- v is iterable and can be used to instantiate a 1D array .
1986+ *name* is used to generate the error message for invalid inputs .
19851987 """
19861988 # Iterate over columns for ndarrays, over rows otherwise.
19871989 X = X .T if isinstance (X , np .ndarray ) else np .asarray (X )
@@ -1992,7 +1994,7 @@ def _reshape_2D(X):
19921994 # 2D array, or 1D array of iterables: flatten them first.
19931995 return [np .reshape (x , - 1 ) for x in X ]
19941996 else :
1995- raise ValueError ("input `X` must have 2 or fewer dimensions" )
1997+ raise ValueError ("{} must have 2 or fewer dimensions" . format ( name ) )
19961998
19971999
19982000def violin_stats (X , method , points = 100 ):
@@ -2039,7 +2041,7 @@ def violin_stats(X, method, points=100):
20392041 vpstats = []
20402042
20412043 # Want X to be a list of data sequences
2042- X = _reshape_2D (X )
2044+ X = _reshape_2D (X , "X" )
20432045
20442046 for x in X :
20452047 # Dictionary of results for this distribution
0 commit comments