Bug#950928: seaborn: FTBFS with pandas 1.0 TestClustermap.test_row_col_colors_*_missing fail

Rebecca N. Palmer rebecca_palmer at zoho.com
Sat Feb 8 14:04:12 GMT 2020


Package: python3-seaborn
Version: 0.9.0-2
Control: tags -1 fixed-upstream
Control: block 950430 by -1

With pandas 1.0 from experimental, two more tests fail (in addition to 
the one in #950695).

This appears to be upstream bug 
https://github.com/mwaskom/seaborn/issues/1498, which is fixed in 0.9.1, 
but I have not explicitly tested this.

________________ TestClustermap.test_row_col_colors_df_missing 
_________________

self = <seaborn.tests.test_matrix.TestClustermap object at 0x7f9a4733f430>

     def test_row_col_colors_df_missing(self):
         kws = self.default_kws.copy()
         row_colors = pd.DataFrame({'row_annot': list(self.row_colors)},
                                   index=self.df_norm.index)
         kws['row_colors'] = row_colors.drop(self.df_norm.index[0])

         col_colors = pd.DataFrame({'col_annot': list(self.col_colors)},
                                   index=self.df_norm.columns)
         kws['col_colors'] = col_colors.drop(self.df_norm.columns[0])

 >       cm = mat.clustermap(self.df_norm, **kws)

seaborn/tests/test_matrix.py:961:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _
seaborn/matrix.py:1292: in clustermap
     plotter = ClusterGrid(data, pivot_kws=pivot_kws, figsize=figsize,
seaborn/matrix.py:774: in __init__
     self._preprocess_colors(data, row_colors, axis=0)
seaborn/matrix.py:823: in _preprocess_colors
     colors = colors.loc[data.index]
/usr/lib/python3/dist-packages/pandas/core/indexing.py:1766: in __getitem__
     return self._getitem_axis(maybe_callable, axis=axis)
/usr/lib/python3/dist-packages/pandas/core/indexing.py:1952: in 
_getitem_axis
     return self._getitem_iterable(key, axis=axis)
/usr/lib/python3/dist-packages/pandas/core/indexing.py:1593: in 
_getitem_iterable
     keyarr, indexer = self._get_listlike_indexer(key, axis, 
raise_missing=False)
/usr/lib/python3/dist-packages/pandas/core/indexing.py:1550: in 
_get_listlike_indexer
     self._validate_read_indexer(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _

self = <pandas.core.indexing._LocIndexer object at 0x7f9a46f2d8b0>
key = RangeIndex(start=0, stop=4, step=1), indexer = array([-1,  0,  1,  2])
axis = 0, raise_missing = False

     def _validate_read_indexer(
         self, key, indexer, axis: int, raise_missing: bool = False
     ):
         """
         Check that indexer can be used to return a result.

         e.g. at least one element was found,
         unless the list of keys was actually empty.

         Parameters
         ----------
         key : list-like
             Targeted labels (only used to show correct error message).
         indexer: array-like of booleans
             Indices corresponding to the key,
             (with -1 indicating not found).
         axis: int
             Dimension on which the indexing is being made.
         raise_missing: bool
             Whether to raise a KeyError if some labels are not found. 
Will be
             removed in the future, and then this method will always 
behave as
             if raise_missing=True.

         Raises
         ------
         KeyError
             If at least one key was requested but none was found, and
             raise_missing=True.
         """
         ax = self.obj._get_axis(axis)

         if len(key) == 0:
             return

         # Count missing values:
         missing = (indexer < 0).sum()

         if missing:
             if missing == len(indexer):
                 axis_name = self.obj._get_axis_name(axis)
                 raise KeyError(f"None of [{key}] are in the [{axis_name}]")

             # We (temporarily) allow for some missing keys with .loc, 
except in
             # some cases (e.g. setting) in which "raise_missing" will 
be False
             if not (self.name == "loc" and not raise_missing):
                 not_found = list(set(key) - set(ax))
                 raise KeyError(f"{not_found} not in index")

             # we skip the warning on Categorical/Interval
             # as this check is actually done (check for
             # non-missing values), but a bit later in the
             # code, so we want to avoid warning & then
             # just raising
             if not (ax.is_categorical() or ax.is_interval()):
 >               raise KeyError(
                     "Passing list-likes to .loc or [] with any missing 
labels "
                     "is no longer supported, see "
 
"https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike" 
  # noqa:E501
                 )
E               KeyError: 'Passing list-likes to .loc or [] with any 
missing labels is no longer supported, see 
https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'

/usr/lib/python3/dist-packages/pandas/core/indexing.py:1652: KeyError
______________ TestClustermap.test_row_col_colors_series_missing 
_______________

self = <seaborn.tests.test_matrix.TestClustermap object at 0x7f9a473131f0>

     def test_row_col_colors_series_missing(self):
         kws = self.default_kws.copy()
         row_colors = pd.Series(list(self.row_colors), name='row_annot',
                                index=self.df_norm.index)
         kws['row_colors'] = row_colors.drop(self.df_norm.index[0])

         col_colors = pd.Series(list(self.col_colors), name='col_annot',
                                index=self.df_norm.columns)
         kws['col_colors'] = col_colors.drop(self.df_norm.columns[0])

 >       cm = mat.clustermap(self.df_norm, **kws)

seaborn/tests/test_matrix.py:1050:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _
seaborn/matrix.py:1292: in clustermap
     plotter = ClusterGrid(data, pivot_kws=pivot_kws, figsize=figsize,
seaborn/matrix.py:774: in __init__
     self._preprocess_colors(data, row_colors, axis=0)
seaborn/matrix.py:823: in _preprocess_colors
     colors = colors.loc[data.index]
/usr/lib/python3/dist-packages/pandas/core/indexing.py:1766: in __getitem__
     return self._getitem_axis(maybe_callable, axis=axis)
/usr/lib/python3/dist-packages/pandas/core/indexing.py:1952: in 
_getitem_axis
     return self._getitem_iterable(key, axis=axis)
/usr/lib/python3/dist-packages/pandas/core/indexing.py:1593: in 
_getitem_iterable
     keyarr, indexer = self._get_listlike_indexer(key, axis, 
raise_missing=False)
/usr/lib/python3/dist-packages/pandas/core/indexing.py:1550: in 
_get_listlike_indexer
     self._validate_read_indexer(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _

self = <pandas.core.indexing._LocIndexer object at 0x7f9a476837c0>
key = RangeIndex(start=0, stop=4, step=1), indexer = array([-1,  0,  1,  2])
axis = 0, raise_missing = False

     def _validate_read_indexer(
         self, key, indexer, axis: int, raise_missing: bool = False
     ):
         """
         Check that indexer can be used to return a result.

         e.g. at least one element was found,
         unless the list of keys was actually empty.

         Parameters
         ----------
         key : list-like
             Targeted labels (only used to show correct error message).
         indexer: array-like of booleans
             Indices corresponding to the key,
             (with -1 indicating not found).
         axis: int
             Dimension on which the indexing is being made.
         raise_missing: bool
             Whether to raise a KeyError if some labels are not found. 
Will be
             removed in the future, and then this method will always 
behave as
             if raise_missing=True.

         Raises
         ------
         KeyError
             If at least one key was requested but none was found, and
             raise_missing=True.
         """
         ax = self.obj._get_axis(axis)

         if len(key) == 0:
             return

         # Count missing values:
         missing = (indexer < 0).sum()

         if missing:
             if missing == len(indexer):
                 axis_name = self.obj._get_axis_name(axis)
                 raise KeyError(f"None of [{key}] are in the [{axis_name}]")

             # We (temporarily) allow for some missing keys with .loc, 
except in
             # some cases (e.g. setting) in which "raise_missing" will 
be False
             if not (self.name == "loc" and not raise_missing):
                 not_found = list(set(key) - set(ax))
                 raise KeyError(f"{not_found} not in index")

             # we skip the warning on Categorical/Interval
             # as this check is actually done (check for
             # non-missing values), but a bit later in the
             # code, so we want to avoid warning & then
             # just raising
             if not (ax.is_categorical() or ax.is_interval()):
 >               raise KeyError(
                     "Passing list-likes to .loc or [] with any missing 
labels "
                     "is no longer supported, see "
 
"https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike" 
  # noqa:E501
                 )
E               KeyError: 'Passing list-likes to .loc or [] with any 
missing labels is no longer supported, see 
https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'

/usr/lib/python3/dist-packages/pandas/core/indexing.py:1652: KeyError



More information about the debian-science-maintainers mailing list