ashander / ftprime

Forward-time simulation of the msprime data structure (for development)
2 stars 1 forks source link

works with simupop if in a simulator, but not if in a population #11

Closed petrelharp closed 7 years ago

petrelharp commented 7 years ago

Why is this? If we change the simu.evolve( ) call in test_ftprime_with_simuPOP.py to pop.evolve( ) -- which should be functionally the same, as the simuPOP documentation says that evolvling a population just evolves a single replicate in a simulator -- it throws a keyError.

ashander commented 7 years ago

Hmm. At first I thought it was obvious, you need to remove pop = simu.population(0)? https://github.com/ashander/ftprime/blob/master/tests/test_ftprime_with_simuPOP.py#L52

But then there is still a ValueError. Weird. Not creating a simulator from that pop solves this. See the top 3 commits on explore/simu-vs-pop-errors

A hint from the help of Simulator suggests the underlying reason is that pop data is not deep copied by default when you create a simulator from a pop

Create a simulator with rep (default to 1) replicates of populations pops, which is a list of populations although a single population object is also acceptable. Contents of passed populations are by default moved to the simulator to avoid duplication of potentially large population objects, leaving empty populations behind. This behavior can be changed by setting stealPops to False, in which case populations are copied to the simulator.

Sure enough if we don't stealPops then it also works 4bafa22a8c648916338969e714284f4419bc5406

petrelharp commented 7 years ago

great. thanks for working that out.