Skip to content

Commit a78f520

Browse files
fix: Python 3 compatibility in examples
- speed_highd.py: Cast float to int for evolve() argument - genealogies_with_selection.py: Use integer division (//) instead of float division (/) for locus index In Python 3, `/` always returns float, while `//` returns int. Functions expecting integer arguments now get the correct type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 4c28d2a commit a78f520

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

examples/genealogies_with_selection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
#set the effect sizes of the mutations that are injected (the same at each site in this case)
3939
pop.set_fitness_additive(np.ones(L)*s)
4040

41-
#track the genealogy at a central locus L/2 (which one doesn't matter in the asexual case)
42-
pop.track_locus_genealogy([L/2])
41+
#track the genealogy at a central locus L//2 (which one doesn't matter in the asexual case)
42+
pop.track_locus_genealogy([L//2])
4343

4444
#initialize the populations
4545
pop.set_wildtype(pop.carrying_capacity)

examples/speed_highd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
pop.set_wildtype(N) # set a wildtype population of size N
4343

44-
pop.evolve(1.0 / (L * (mu + r))) # evolve until equilibrium
44+
pop.evolve(int(1.0 / (L * (mu + r)))) # evolve until equilibrium
4545

4646
# run for G generations to measure execution time
4747
t1=time.time()

0 commit comments

Comments
 (0)