def __init__(
        self,
        value_s,
        feature_df,
        feature_to_category,
        feature_name="feature",
        category_name="category",
        feature_summary=None,
        feature_summary_fun=None,
        category_summary=None,
        category_summary_fun=None,
        min_features_per_cat=2,
        max_dist=0,
        chrom_len=None,
        ncpus=1,
    ):
        # todo: logging for AssertionErrors, explain what the problem is
        hp.check_rod(value_s)
        hp.check_feature_df(feature_df)
        assert feature_name in feature_df.columns
        assert (feature_summary is not None) != (
            feature_summary_fun is not None
        ), "Specify either feature_summary OR feature_summary_fun."
        assert (category_summary is not None) != (
            category_summary_fun is not None
        ), "Specify either category_summary OR category_summary_fun."
        # if chrom_len is not None:
        #    self.flat_index = True
        # else:
        self.flat_index = False

        # if self.flat_index:
        #    self.value_s = hp.rod_to_1d(value_s, chrom_len)
        #    self.feature_df = hp.feature_df_to_1d(feature_df, chrom_len)
        # else:
        self.value_s = value_s.copy()
        self.feature_df = feature_df.copy()

        self.value_name = self.value_s.name

        self._bind_feature_to_category(feature_to_category, feature_name, category_name)

        self.prune_feature_to_category(min_features_per_cat)

        self.feature_summary = feature_summary
        self.category_summary = category_summary
        self.feature_summary_fun = feature_summary_fun
        self.category_summary_fun = category_summary_fun

        # new
        self.features_per_data = hp.get_features_per_data(
            self.value_s, self.feature_df, feature_name=self.feature_name, max_dist=max_dist
        )
        self.features_per_data.index = self.features_per_data.index.droplevel(2)

        self.init_rank_table = self.initital_rank_table()
        self.rank_table = self.init_rank_table
        self.ncpus = ncpus
    def __init__(self, value_s, feature_df,  feature_to_category, feature_name='feature', category_name='category',
                    feature_summary=None, feature_summary_fun=None,
                 category_summary=None, category_summary_fun=None, min_features_per_cat=2,
                                                        max_dist=0, chrom_len=None, ncpus=1):
        #todo: logging for AssertionErrors, explain what the problem is
        hp.check_rod(value_s) 
        hp.check_feature_df(feature_df)
        assert feature_name in feature_df.columns
        assert (feature_summary is not None) != (feature_summary_fun is not None), \
                                "Specify either feature_summary OR feature_summary_fun."
        assert (category_summary is not None) != (category_summary_fun is not None), \
                                "Specify either category_summary OR category_summary_fun."
        if chrom_len is not None:
            self.flat_index = True
        else:
            self.flat_index = False

        if self.flat_index:
            self.value_s = hp.rod_to_1d(value_s, chrom_len)
            self.feature_df = hp.feature_df_to_1d(feature_df, chrom_len)
        else:
            self.value_s = value_s.copy()
            self.feature_df = feature_df.copy()

        self.value_name = self.value_s.name

        self._bind_feature_to_category(feature_to_category, feature_name,  category_name)

        self.prune_feature_to_category(min_features_per_cat)

        self.feature_summary = feature_summary
        self.category_summary = category_summary
        self.feature_summary_fun = feature_summary_fun
        self.category_summary_fun = category_summary_fun
        self.max_dist = max_dist

        #logging.debug("I am before.")
        #import pdb
        #logging.debug("I am here.")
        #pdb.set_trace()
        #logging.debug("I am after.")

        self.init_rank_table = self.initital_rank_table()
        self.rank_table = self.init_rank_table
        self.ncpus = ncpus