Team Ai
Apppublic

TangibleAI/mathtext

sourceHugging Faceagpl-3.0updated 4y agoView on Hugging Face
1likes
test_text2int.py44 linesDownload Raw Back to tests
1import unittest2 3import pandas as pd4 5from app import text2int6 7 8TEST_DATA_FILE = "data/test_text2int.all.csv"9 10 11class TestStringMethods(unittest.TestCase):12 13    def setUp(self):14        pass15 16    @staticmethod17    def get_text2int(text):18        """Makes a post request to the endpoint"""19        r = None20        try:21            r = text2int(text)22        except:23            pass24        return r25 26 27    def test_acc_score_text2int(self):28        """Calculates accuracy score for endpoint"""29        df = pd.read_csv(TEST_DATA_FILE)30 31        df["text2int"] = df["input"].apply(func=self.get_text2int)32        df["score"] = df[["output", "text2int"]].apply(33            lambda row: row[0] == row[1],34            axis=135        )36        df.to_csv("data/text2int_results.csv", index=False)37        acc_score = df["score"].mean().__round__(2)38 39        self.assertGreaterEqual(acc_score, 0.8, f"Accuracy score: '{acc_score}'. Value is too low!")40 41 42if __name__ == '__main__':43    unittest.main()44