def test_eq_spill_container_pair(uncertain): """ SpillContainerPair inherits from SpillContainer so it should compute __eq__ and __ne__ in the same way - test it here Incomplete - this doesn't currently work! Test fails if uncertainty is on whether particles are released or not This is because 'id' of uncertain spills do not match and one should not expect them to match. todo: remove 'id' property as a check for equality. This requires changes in persisting logic. Update persistence then revisit this test and simplify it """ (sp1, sp2) = get_eq_spills() # windages array will not match after elements are released so lets not # add any more types to data_arrays for this test. Just look at base # array_types for SpillContainer's and ensure the data matches for them #sp1.element_type = ElementType() #sp2.element_type = ElementType() scp1 = SpillContainerPair(uncertain) # uncertainty is on scp1.add(sp1) scp2 = SpillContainerPair(uncertain) if uncertain: u_sp1 = [ scp1.items()[1].spills[spill.id] for spill in scp1.items()[1].spills ][0] u_sp2 = copy.deepcopy(u_sp1) # deepcopy does not match ids! # for test, we need these to match so force them to be equal here u_sp2._id = u_sp1.id scp2.add((sp2, u_sp2)) else: scp2.add(sp2) for sc in zip(scp1.items(), scp2.items()): sc[0].prepare_for_model_run() sc[0].release_elements(360, sp1.release.release_time) sc[1].prepare_for_model_run() sc[1].release_elements(360, sp2.release.release_time) assert scp1 == scp2 assert scp2 == scp1 assert not (scp1 != scp2) assert not (scp2 != scp1)
def test_eq_spill_container_pair(uncertain): """ SpillContainerPair inherits from SpillContainer so it should compute __eq__ and __ne__ in the same way - test it here Incomplete - this doesn't currently work! Test fails if uncertainty is on whether particles are released or not This is because 'id' of uncertain spills do not match and one should not expect them to match. todo: remove 'id' property as a check for equality. This requires changes in persisting logic. Update persistence then revisit this test and simplify it """ (sp1, sp2) = get_eq_spills() # windages array will not match after elements are released so lets not # add any more types to data_arrays for this test. Just look at base # array_types for SpillContainer's and ensure the data matches for them #sp1.element_type = ElementType() #sp2.element_type = ElementType() scp1 = SpillContainerPair(uncertain) # uncertainty is on scp1.add(sp1) scp2 = SpillContainerPair(uncertain) if uncertain: u_sp1 = [scp1.items()[1].spills[spill.id] for spill in scp1.items()[1].spills][0] u_sp2 = copy.deepcopy(u_sp1) # deepcopy does not match ids! # for test, we need these to match so force them to be equal here u_sp2._id = u_sp1.id scp2.add((sp2, u_sp2)) else: scp2.add(sp2) for sc in zip(scp1.items(), scp2.items()): sc[0].prepare_for_model_run() sc[0].release_elements(360, sp1.release.release_time) sc[1].prepare_for_model_run() sc[1].release_elements(360, sp2.release.release_time) assert scp1 == scp2 assert scp2 == scp1 assert not (scp1 != scp2) assert not (scp2 != scp1)