<commit_before># coding: utf-8

from fireant.slicer.transformers import utils
from fireant.tests.slicer.transformers.base import BaseTransformerTests


class UtilsTest(BaseTransformerTests):
    def test_correct_dims_cont_cat(self):
        df = self.cont_cat_dims_multi_metric_df.reorder_levels([1, 0])

        result = utils.correct_dimension_level_order(df, self.cont_cat_dims_multi_metric_schema)

        self.assertListEqual(['cont', 'cat1'], list(result.index.names))

    def test_correct_dims_cont_cat_uni(self):
        df = self.cont_cat_uni_dims_multi_metric_df.reorder_levels([2, 0, 3, 1])

        result = utils.correct_dimension_level_order(df, self.cont_cat_uni_dims_multi_metric_schema)

        self.assertListEqual(['cont', 'cat1', 'uni', 'uni_label'], list(result.index.names))<commit_msg>Added test coverage for correcting metric order<commit_after># coding: utf-8

from fireant.slicer.transformers import utils
from fireant.tests.slicer.transformers.base import BaseTransformerTests


class UtilsTest(BaseTransformerTests):
    def test_correct_dims_cont_cat(self):
        df = self.cont_cat_dims_multi_metric_df.reorder_levels([1, 0])

        result = utils.correct_dimension_level_order(df, self.cont_cat_dims_multi_metric_schema)

        self.assertListEqual(['cont', 'cat1'], list(result.index.names))

    def test_correct_dims_cont_cat_uni(self):
        df = self.cont_cat_uni_dims_multi_metric_df.reorder_levels([2, 0, 3, 1])

        result = utils.correct_dimension_level_order(df, self.cont_cat_uni_dims_multi_metric_schema)

        self.assertListEqual(['cont', 'cat1', 'uni', 'uni_label'], list(result.index.names))

    def test_correct_metrics(self):
        df = self.cont_cat_uni_dims_multi_metric_df

        result = utils.correct_dimension_level_order(df[['two', 'one']], self.cont_cat_uni_dims_multi_metric_schema)

        self.assertListEqual(['one', 'two'], list(result.columns))

    def test_correct_metrics_ref(self):
        df = self.time_dim_single_metric_ref_df

        result = utils.correct_dimension_level_order(df[[('wow', 'one'), ('', 'one')]],
                                                     self.time_dim_single_metric_ref_schema)

        self.assertListEqual([('', 'one'), ('wow', 'one')], list(result.columns))
{'fraction_non_alphanumeric': 0.11466083150984682, 'fraction_numerical': 0.00787746170678337, 'mean_word_length': 4.4951923076923075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1880089', 'n_tokens_mistral': 765, 'n_tokens_neox': 748, 'n_words': 108}