Example #1
0
 def test_load_invalid_target(self, tmpdir):
     directory = tmpdir.mkdir('ckpt')
     with raises(FileNotFoundError):
         Population.load(directory.join('no_file' + self.extension), lambda x: x)
     with raises(FileNotFoundError):
         Population.load(directory, lambda x: x)
     txt_file = directory.join('file.txt')
     txt_file.write('Something')
     with raises(ValueError):
         Population.load(txt_file.strpath, lambda x: x)
Example #2
0
 def test_load(self, tmpdir, simple_population):
     directory = tmpdir.mkdir("ckpt")
     simple_population.checkpoint(target=directory, method=self.method)
     pop = Population.load(directory, lambda x: x['x'])
     assert len(simple_population) == len(pop)
     assert all(x.__dict__ == y.__dict__ for x, y in zip(simple_population, pop))