BoPeng / simuPOP

A general-purpose forward-time population genetics simulation environment.
http://bopeng.github.io/simuPOP/
GNU General Public License v2.0
31 stars 12 forks source link

ValueError with EventsBased model #94

Closed evanwcarson closed 2 years ago

evanwcarson commented 2 years ago

Hi Bo, I am hoping that you can help resolve the following error. Briefly, I have a test script (attached) for an EventsBased model that runs fine with an older version of SimuPOP (1.1.8.3) but crashes (at pop.evolve) when I run the exact same script with the newer version of SimuPOP (1.1.10.9). I am using different laptops but working off the exact same .py file. In both cases I am running simuPOP via Anaconda3 and as implemented in Visual Studio Code. I’m using VSC version 1.65 for runs on the older version of simuPOP (runs fine), and VSC version 1.70 for runs on the newer version of simuPOP (throws error). The error is shown below, first with debugger output (1) and then from the actual traceback (2):

1, From the debugger: Turn on debug 'DBG_WARNING' WARNING: Parameter subPopSize of a HomoMating is ignored when this mating scheme is used in a heterogeneous mating scheme. Migrants in each generation: Gen 0: [8900] (before mating) [8900] (after mating) Gen 1: [8900] (before mating) 2 2 WARNING: The returned object of function Individual.genotype() is a special carray object that reflects the underlying genotype of an individual. It will become invalid once the population changes. Please use list(ind.genotype()) if you would like to keep a copy of genotypes [7300, 1500, 100] (after mating) WARNING: The returned object of function Population.genotype() is a special carray object that reflects the underlying genotype of a population. It will become invalid once the population changes. Please use list(pop.genotype()) if you would like to keep a copy of genotypes WARNING: The returned object of function Individual.genotype() is a special carray object that reflects the underlying genotype of an individual. It will become invalid once the population changes. Please use list(ind.genotype()) if you would like to keep a copy of genotypes

2. and the traceback: Traceback (most recent call last): File "/home/evanwcarson/Documents/SimuPop/gm3_test.py", line 44, in pop.evolve( File "/home/evanwcarson/anaconda3/lib/python3.8/site-packages/simuPOP/init.py", line 407, in evolve_pop gen = simu.evolve(initOps, preOps, matingScheme, postOps, finalOps, gen) ValueError: population.cpp: 1111 sex can only be one of ANY_SEX, MALE_ONLY, FEMALE_ONLY, and PAIR_ONLY.

I looked at line 407 within the flagged init_.py file (for version 1.1.10.9), and that code block seems to reference a selfing population, which I am not using. I am not sure if I have a setting that’s off (I’ve looked, to no avail thus far), if this is a bug to report, or something else is causing the problem. Thoughts?

Thanks, Evan

gm3_test.txt

BoPeng commented 2 years ago

I can reproduce the problem with your code, but cannot quickly identify the cause. I will let you know later today.

BoPeng commented 2 years ago

The fix is basically a one-liner but unfortunately it involves the C/C++ part so no quick "patch" is available.

I have released simuPOP 1.1.11. The conda version should be available in the next few hours for you to install it through conda-forge. Otherwise you can compile from source.

evanwcarson commented 2 years ago

Hi Bo. The new release is working well. I installed it from source since the update wasn't on conda forge as of yesterday. Thanks.

BoPeng commented 2 years ago

Yes, conda-forge can compile the module under windows and mac, but not linux. I asked for help but no one has responded yet.