def test_save_load(self): data = pandas.read_csv(join(TEST_DATA_PATH, "test_data.csv.xz"), index_col=0).infer_objects() candidates = pandas.read_csv(join(TEST_DATA_PATH, "test_data_candidates_full.csv.xz")) candidates.loc[:, Columns.Features] = candidates[Columns.Features].apply( lambda x: list(map(float, x[1:-1].split()))) ranker = CandidatesRanker() ranker.fit(data[Columns.CorrectToken], get_candidates_metadata(candidates), get_candidates_features(candidates)) with io.BytesIO() as buffer: ranker.save(output=buffer, series="typos-analyzer") print(buffer.tell()) buffer.seek(0) ranker2 = CandidatesRanker().load(buffer) print(ranker) self.assertTrue(ranker == ranker2)
def test_save_load(self): data = pandas.read_csv(join(TEST_DATA_PATH, "test_data.csv.xz"), index_col=0).infer_objects() candidates = pandas.read_pickle( join(TEST_DATA_PATH, "test_data_candidates_full.pkl")) ranker = CandidatesRanker() ranker.fit(data[CORRECT_TOKEN_COLUMN], get_candidates_metadata(candidates), get_candidates_features(candidates)) with io.BytesIO() as buffer: ranker.save(buffer) print(buffer.tell()) buffer.seek(0) ranker2 = CandidatesRanker().load(buffer) print(ranker) self.assertTrue(ranker == ranker2)