<commit_before>import pandas as pd
import numpy as np

from nose import runmodule
from nose.tools import assert_equal, raises
from numpy.testing import assert_array_equal
from pandas.util.testing import assert_frame_equal

from econtools.util import (int2base, base2int, force_df, force_list,           #noqa
                            force_iterable)


class Test_BaseConvert(object):

    def test_2b16_1(self):
        x = 17
        expected = '11'
        result = int2base(x, 16)
        assert expected == result

    def test_2b36_1(self):
        x = 37
        expected = '11'
        result = int2base(x, 36)
        assert expected == result

    def test_2b62_1(self):
        x = 63
        expected = '11'
        result = int2base(x, 62)
        assert expected == result

    def test_b16(self):
        base = 16
        x = 1022
        to = int2base(x, base)
        back = base2int(to, base)
        assert x == back

    def test_b36(self):
        base = 36
        x = 1022
        to = int2base(x, base)
        back = base2int(to, base)
        assert x == back

    def test_b62(self):
        base = 36
        x = 1022
        to = int2base(x, base)
        back = base2int(to, base)
        assert x == back

    @raises(ValueError)
    def test_invalid_char_b16(self):
        base2int('123Z', 16)

    @raises(ValueError)
    def test_invalid_char_b32(self):
        base2int('123a', 32)

    @raises(ValueError)
    def test_invalid_char_b62(self):
        base2int('123!', 62)


class Test_force_df(object):

    def setup(self):
        s = pd.Series([1, 2, 3], name='wut')
        self.s = s
        self.sdf = pd.DataFrame(s)
        df = pd.DataFrame([s, s]).T
        df.columns = ['dingle', 'dangle']
        self.df = df

    def test_simple(self):
        expected = pd.DataFrame(self.s)
        result = force_df(self.s)
        assert_frame_equal(expected, result)

    def test_noname(self):
        expected = self.sdf
        expected.columns = [0]
        result = force_df(self.s, forcename=True)
        assert_frame_equal(expected, result)

    def test_checkname(self):
        expected = self.sdf
        result = force_df(self.s, checkname=True)
        assert_frame_equal(expected, result)

    @raises(AssertionError)
    def test_checkname_fail(self):
        force_df(self.s, name='xxx', checkname=True)

    def test_passthrough(self):
        df = self.df
        assert_frame_equal(df, force_df(df))

    def test_multiidx(self):
        idx = pd.MultiIndex.from_tuples([('a', 1), ('b', 7), ('w', 99)],
                                        names=['dingle', 'dangle'])
        expected = self.sdf
        expected.index = idx
        s = self.s
        s.index = idx
        result = force_df(s)
        assert_frame_equal(expected, result)

    @raises(ValueError)
    def test_list(self):
        force_df([1, 2, 3])

    @raises(ValueError)
    def test_array(self):
        force_df(np.arange(3))


class Test_force_list(object):

    def test_list(self):
        expected = [1, 2, 3]
        result = force_list(expected)
        assert_equal(expected, result)<commit_msg>BUG: update tests for `force_df`<commit_after>import pandas as pd
import numpy as np

from nose import runmodule
from nose.tools import assert_equal, raises
from numpy.testing import assert_array_equal
from pandas.util.testing import assert_frame_equal

from econtools.util import (int2base, base2int, force_df, force_list,           #noqa
                            force_iterable)


class Test_BaseConvert(object):

    def test_2b16_1(self):
        x = 17
        expected = '11'
        result = int2base(x, 16)
        assert expected == result

    def test_2b36_1(self):
        x = 37
        expected = '11'
        result = int2base(x, 36)
        assert expected == result

    def test_2b62_1(self):
        x = 63
        expected = '11'
        result = int2base(x, 62)
        assert expected == result

    def test_b16(self):
        base = 16
        x = 1022
        to = int2base(x, base)
        back = base2int(to, base)
        assert x == back

    def test_b36(self):
        base = 36
        x = 1022
        to = int2base(x, base)
        back = base2int(to, base)
        assert x == back

    def test_b62(self):
        base = 36
        x = 1022
        to = int2base(x, base)
        back = base2int(to, base)
        assert x == back

    @raises(ValueError)
    def test_invalid_char_b16(self):
        base2int('123Z', 16)

    @raises(ValueError)
    def test_invalid_char_b32(self):
        base2int('123a', 32)

    @raises(ValueError)
    def test_invalid_char_b62(self):
        base2int('123!', 62)


class Test_force_df(object):

    def setup(self):
        s = pd.Series([1, 2, 3], name='wut')
        self.s = s
        self.sdf = pd.DataFrame(s)
        df = pd.DataFrame([s, s]).T
        df.columns = ['dingle', 'dangle']
        self.df = df

    def test_simple(self):
        expected = pd.DataFrame(self.s)
        result = force_df(self.s)
        assert_frame_equal(expected, result)

    def test_passthrough(self):
        df = self.df
        assert_frame_equal(df, force_df(df))

    def test_multiidx(self):
        idx = pd.MultiIndex.from_tuples([('a', 1), ('b', 7), ('w', 99)],
                                        names=['dingle', 'dangle'])
        expected = self.sdf
        expected.index = idx
        s = self.s
        s.index = idx
        result = force_df(s)
        assert_frame_equal(expected, result)

    @raises(ValueError)
    def test_list(self):
        force_df([1, 2, 3])

    @raises(ValueError)
    def test_array(self):
        force_df(np.arange(3))


class Test_force_list(object):

    def test_list(self):
        expected = [1, 2, 3]
        result = force_list(expected)
        assert_equal(expected, result)
{'fraction_non_alphanumeric': 0.10978112175102599, 'fraction_numerical': 0.03539671682626539, 'mean_word_length': 2.073568050446663, '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': '6703343', 'n_tokens_mistral': 2080, 'n_tokens_neox': 1907, 'n_words': 453}