<commit_before>import os
import pyexcel as pe
from base import create_sample_file2


class TestRareCases:
    def test_validate(self):
        ifr = pe.filters.IndexFilter(None)
        ifr.validate_filter(None)
        ifr.translate(1,2)
        assert 1==1

    def test_empty_column_filter(self):
        data = [
            [1,2,3]
        ]
        s = pe.sheets.MultipleFilterableSheet(data)
        s.add_filter(pe.filters.ColumnFilter([100]))
        result = pe.utils.to_array(s)
        assert data == result

    def test_empty_row_filter(self):
        data = [
            [1,2,3]
        ]
        s = pe.sheets.MultipleFilterableSheet(data)
        s.add_filter(pe.filters.RowFilter([100]))
        result = pe.utils.to_array(s)
        assert data == result

    def test_row_value_filter_with_series_reader(self):
        data = "Person,Age\nAdam,24\nBilly,23\nCeri,28\nDennis,25"
        r1 = pe.SeriesReader(("csv", data))
        filter_func = lambda row: row['Age'] == 23
        r1.filter(pe.filters.RowValueFilter(filter_func))
        print pe.utils.to_records(r1)


class TestFilterWithFilterableReader:
    def setUp(self):
        """
        Make a test csv file as:

        1,2,3,4
        5,6,7,8
        9,10,11,12
        """
        self.testfile = "test.csv"
        create_sample_file2(self.testfile)

    def test_use_filter_reader_without_filter(self):
        r = pe.FilterableReader(self.testfile)
        result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
        actual = pe.utils.to_array(r.enumerate())
        assert result == actual<commit_msg>fix broken py3 build<commit_after>import os
import pyexcel as pe
from base import create_sample_file2


class TestRareCases:
    def test_validate(self):
        ifr = pe.filters.IndexFilter(None)
        ifr.validate_filter(None)
        ifr.translate(1,2)
        assert 1==1

    def test_empty_column_filter(self):
        data = [
            [1,2,3]
        ]
        s = pe.sheets.MultipleFilterableSheet(data)
        s.add_filter(pe.filters.ColumnFilter([100]))
        result = pe.utils.to_array(s)
        assert data == result

    def test_empty_row_filter(self):
        data = [
            [1,2,3]
        ]
        s = pe.sheets.MultipleFilterableSheet(data)
        s.add_filter(pe.filters.RowFilter([100]))
        result = pe.utils.to_array(s)
        assert data == result

    def test_row_value_filter_with_series_reader(self):
        data = "Person,Age\nAdam,24\nBilly,23\nCeri,28\nDennis,25"
        r1 = pe.SeriesReader(("csv", data))
        filter_func = lambda row: row['Age'] == 23
        r1.filter(pe.filters.RowValueFilter(filter_func))


class TestFilterWithFilterableReader:
    def setUp(self):
        """
        Make a test csv file as:

        1,2,3,4
        5,6,7,8
        9,10,11,12
        """
        self.testfile = "test.csv"
        create_sample_file2(self.testfile)

    def test_use_filter_reader_without_filter(self):
        r = pe.FilterableReader(self.testfile)
        result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
        actual = pe.utils.to_array(r.enumerate())
        assert result == actual
{'fraction_non_alphanumeric': 0.1169367651731808, 'fraction_numerical': 0.03876707975850016, 'mean_word_length': 2.3276955602536997, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4893249', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1064, 'n_words': 194}