def test_get_metadata_key_ranges(self): experiment = m.Experiment( os.path.join(ud.UData().Basedir, "foo.myrmidon")) experiment.SetMetaDataKey("alive", True) experiment.CreateAnt() a = experiment.CreateAnt() a.SetValue(key="alive", value=False, time=m.Time()) a = experiment.CreateAnt() a.SetValue(key="alive", value=False, time=m.Time.SinceEver()) a.SetValue(key="alive", value=True, time=m.Time()) a.SetValue(key="alive", value=True, time=m.Time().Add(1)) a.SetValue(key="alive", value=False, time=m.Time().Add(2)) a.SetValue(key="alive", value=True, time=m.Time().Add(3)) ranges = m.Query.GetMetaDataKeyRanges(experiment, key="alive", value=True) self.assertEqual(len(ranges), 4) self.assertEqual(ranges[0], (1, m.Time.SinceEver(), m.Time.Forever())) self.assertEqual(ranges[1], (2, m.Time.SinceEver(), m.Time())) self.assertEqual(ranges[2], (3, m.Time(), m.Time().Add(2))) self.assertEqual(ranges[3], (3, m.Time().Add(3), m.Time.Forever())) with self.assertRaises(IndexError): m.Query.GetMetaDataKeyRanges(experiment, key="isDead", value=True) with self.assertRaises(ValueError): m.Query.GetMetaDataKeyRanges(experiment, key="alive", value=42.0)
def test_identification_manipulation(self): ants = [self.experiment.CreateAnt(), self.experiment.CreateAnt()] with self.assertRaises(IndexError): self.experiment.AddIdentification(42, 0, m.Time.SinceEver(), m.Time.Forever()) self.experiment.AddIdentification(ants[0].ID, 0, m.Time.SinceEver(), m.Time.Forever()) with self.assertRaises(m.OverlappingIdentification): self.experiment.AddIdentification(ants[0].ID, 1, m.Time.SinceEver(), m.Time.Forever()) with self.assertRaises(m.OverlappingIdentification): self.experiment.AddIdentification(ants[1].ID, 0, m.Time.SinceEver(), m.Time.Forever()) self.experiment.AddIdentification(ants[1].ID, 1, m.Time.SinceEver(), m.Time.Forever()) e2 = m.Experiment("foo.myrmidon") a2 = e2.CreateAnt() i2 = e2.AddIdentification(a2.ID, 0, m.Time.SinceEver(), m.Time.Forever()) with self.assertRaises(ValueError): self.experiment.DeleteIdentification(i2) ants[0].Identifications[0].End = m.Time() with self.assertRaises(RuntimeError): self.experiment.FreeIdentificationRangeAt( ants[0].Identifications[0].TagValue, m.Time().Add(-1)) low, high = self.experiment.FreeIdentificationRangeAt( ants[0].Identifications[0].TagValue, m.Time()) self.assertTimeEqual(low, m.Time()) self.assertTimeEqual(high, m.Time.Forever()) low, high = self.experiment.FreeIdentificationRangeAt(42, m.Time()) self.assertTimeEqual(low, m.Time.SinceEver()) self.assertTimeEqual(high, m.Time.Forever()) identifications = self.experiment.IdentificationsAt( time=m.Time().Add(-1), removeUnidentifiedAnt=True) self.assertEqual(len(identifications), 2) self.assertEqual(identifications[ants[0].ID], 0) self.assertEqual(identifications[ants[1].ID], 1) identifications = self.experiment.IdentificationsAt( time=m.Time(), removeUnidentifiedAnt=True) self.assertEqual(len(identifications), 1) self.assertEqual(identifications[ants[1].ID], 1) self.assertFalse(ants[0].ID in identifications) identifications = self.experiment.IdentificationsAt( time=m.Time(), removeUnidentifiedAnt=False) self.assertEqual(len(identifications), 2) self.assertEqual(identifications[ants[0].ID], 2**32 - 1) self.assertEqual(identifications[ants[1].ID], 1)
def test_file_manipulation(self): dirs = [ ud.UData().Basedir / "test-manipulation", ud.UData().Basedir / "test-manipulation-new" ] for d in dirs: try: os.makedirs(d) except FileExistsError: pass filepath = str(dirs[0] / "test.myrmidon") goodNewPath = str(dirs[0] / "test2.myrmidon") badNewPath = str(dirs[1] / "test.myrmidon") e = m.Experiment(filepath) e.Save(filepath) e.Save(goodNewPath) with self.assertRaises(ValueError): e.Save(badNewPath)
def setUp(self): self.experiment = m.Experiment("test-myrmidon")
import py_fort_myrmidon e = py_fort_myrmidon.Experiment('foo.myrmidon') e.Name = 'foo'
def setUp(self): self.experiment = m.Experiment( str(ud.UData().Basedir / "zone-utests.myrmidon")) self.space = self.experiment.CreateSpace("nest")
def setUp(self): self.experiment = m.Experiment( str(ud.UData().Basedir / "identification-utest.myrmidon")) self.ant = self.experiment.CreateAnt() self.i = self.experiment.AddIdentification(self.ant.ID, 123)
def setUp(self): self.experiment = m.Experiment( str(ud.UData().Basedir / 'public-experiment.myrmidon'))