def test_persistence(self): with self.assertRaises(NotFittedError): self.pipe.save() df = self.df[-200:] self.pipe.fit(df, self.target) # Load test self.pipe.save(filename=PIPE_PATH) self.pipe = MatPipe.load(PIPE_PATH) df_test = self.pipe.predict(self.df[-220:-201]) self.assertTrue(self.target in df_test.columns) self.assertTrue(self.target + " predicted" in df_test.columns) # Version test self.pipe.version = "not a real version" self.pipe.save(VERSION_PIPE_PATH) with self.assertRaises(AutomatminerError): MatPipe.load(VERSION_PIPE_PATH)
def test_persistence_and_digest(self): with self.assertRaises(NotFittedError): self.pipe.save() df = self.df[-200:] self.pipe.fit(df, self.target) filename = os.path.join(test_dir, PIPE_PATH) self.pipe.save(filename=filename) self.pipe = MatPipe.load(filename, logger=False) df_test = self.pipe.predict(self.df[-220:-201], self.target) self.assertTrue(self.target in df_test.columns) self.assertTrue(self.target + " predicted" in df_test.columns) digest_file = os.path.join(test_dir, DIGEST_PATH) digest = self.pipe.digest(filename=digest_file) self.assertTrue(os.path.isfile(digest_file)) self.assertTrue(isinstance(digest, str))
def test_persistence_and_digest(self): pipe = MatPipe(**debug_config) with self.assertRaises(NotFittedError): pipe.save() df = self.df[-200:] pipe.fit(df, self.target) filename = os.path.join(test_dir, "test_pipe.p") pipe.save(filename=filename) pipe = MatPipe.load(filename, logger=False) df_test = pipe.predict(self.df[-220:-201], self.target) self.assertTrue(self.target in df_test.columns) self.assertTrue(self.target + " predicted" in df_test.columns) digest_file = os.path.join(test_dir, "matdigest.txt") digest = pipe.digest(filename=digest_file) self.assertTrue(os.path.isfile(digest_file)) self.assertTrue(isinstance(digest, str))