Skip to content

Fix dummy mask for setting dummy weights

Kilian Lieret requested to merge bugfix/dummy-mask-dststlnu-weights into master

The current setup fails with

../RDStar/rdstar/mc_reweighting/BtoDststlnu/BtoDststlnu_weights.py:248: in add_neutral_dstst_weight_columns                                                                                                        
    df.loc[mask, nom_column_name] = 1.0                                                                                                                                                                            
../../../../.python-envs/tagcal/lib/python3.6/site-packages/pandas/core/indexing.py:666: in __setitem__                                                                                                            
    indexer = self._get_setitem_indexer(key)                                                                                                                                                                       
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                                                                                                                                                                                                                   
self = <pandas.core.indexing._LocIndexer object at 0x7fa485b03818>, key = (0    True
dtype: bool, 'weight_ff_Dzerostar_nom')
    
    def _get_setitem_indexer(self, key):
        """
        Convert a potentially-label-based key into a positional indexer.
        """
        if self.name == "loc":
            self._ensure_listlike_indexer(key)

        if self.axis is not None:
            return self._convert_tuple(key, is_setter=True)
    
        ax = self.obj._get_axis(0)
                
        if isinstance(ax, ABCMultiIndex) and self.name != "iloc":
            try:
                return ax.get_loc(key)
            except (TypeError, KeyError, InvalidIndexError):
                # TypeError e.g. passed a bool
                pass
    
        if isinstance(key, tuple):
            try:
                return self._convert_tuple(key, is_setter=True)
            except IndexingError:
                pass

        if isinstance(key, range):
            return list(key)

        try:
            return self._convert_to_indexer(key, axis=0, is_setter=True)
        except TypeError as e:

            # invalid indexer type vs 'other' indexing errors
            if "cannot do" in str(e):
                raise
            elif "unhashable type" in str(e):
                raise
>           raise IndexingError(key) from e
E           pandas.core.indexing.IndexingError: (0    True
E           dtype: bool, 'weight_ff_Dzerostar_nom')

../../../../.python-envs/tagcal/lib/python3.6/site-packages/pandas/core/indexing.py:625: IndexingError

Merge request reports

Loading