<commit_before>"""
"""

import unittest
import tempfile
import pyjams.util as util
import os


class UtilTests(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_read_lab(self):
        fid, fpath = tempfile.mkstemp(suffix='.lab')
        lab_data = [[0, 1.5, 'a\tblah blah'],
                    [],
                    ['# I am a comment'],
                    ['b', -2, -5.5]]
        text = ["\t".join(["%s" % _ for _ in row]) + "\n" for row in lab_data]
        fhandle = os.fdopen(fid, 'w')
        fhandle.writelines(text)
        fhandle.close()
        result = util.read_lab(fpath, 3, delimiter='\t', comment='#')
        self.assertEqual(result[0], [0, 'b'])
        self.assertEqual(result[1], [1.5, -2])
        self.assertEqual(result[2], ['a\tblah blah', -5.5])

        with self.assertRaises(ValueError):
            util.read_lab(fpath, 4, delimiter='\t', comment='#')

if __name__ == "__main__":
    unittest.main()<commit_msg>Removing tempfile from util tests<commit_after>"""
"""

import unittest
import tempfile
import pyjams.util as util
import os


class UtilTests(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_read_lab(self):
        fid, fpath = tempfile.mkstemp(suffix='.lab')
        lab_data = [[0, 1.5, 'a\tblah blah'],
                    [],
                    ['# I am a comment'],
                    ['b', -2, -5.5]]
        text = ["\t".join(["%s" % _ for _ in row]) + "\n" for row in lab_data]
        fhandle = os.fdopen(fid, 'w')
        fhandle.writelines(text)
        fhandle.close()
        result = util.read_lab(fpath, 3, delimiter='\t', comment='#')
        self.assertEqual(result[0], [0, 'b'])
        self.assertEqual(result[1], [1.5, -2])
        self.assertEqual(result[2], ['a\tblah blah', -5.5])

        with self.assertRaises(ValueError):
            util.read_lab(fpath, 4, delimiter='\t', comment='#')
        os.remove(fpath)

if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.1683748169838946, 'fraction_numerical': 0.016593460224499756, 'mean_word_length': 2.1587057010785826, 'pattern_counts': {'":': 2, '<': 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': '4979233', 'n_tokens_mistral': 722, 'n_tokens_neox': 699, 'n_words': 156}