Skip to content

Commit

Permalink
C++ back-end for DiploidPopulation now passes ploidy to base class.
Browse files Browse the repository at this point in the history
Fixes #836
  • Loading branch information
molpopgen committed Oct 27, 2021
1 parent 67b6df0 commit bc58956
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions doc/misc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Major changes are listed below. Each release likely contains fiddling with back-end code,
updates to latest `fwdpp` version, etc.

## 0.17.0

Bug fixes

* Fix error initializing the founder genome of {class}`fwdpy11.DiploidPopulation`
`issue`{836}
`pr`{838}

## 0.16.2

Documentation
Expand Down
4 changes: 2 additions & 2 deletions fwdpy11/headers/fwdpy11/types/DiploidPopulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ namespace fwdpy11

// Constructors for Python
DiploidPopulation(const fwdpp::uint_t N, const double length)
: Population{ N, length }, diploids(N, { 0, 0 }),
: Population{2, N, length }, diploids(N, { 0, 0 }),
diploid_metadata(N), ancient_sample_metadata{}
{
finish_construction({ N });
}

DiploidPopulation(const std::vector<std::uint32_t> &deme_sizes,
const double length)
: Population{ std::accumulate(begin(deme_sizes), end(deme_sizes),
: Population{2, std::accumulate(begin(deme_sizes), end(deme_sizes),
0u),
length },
diploids(std::accumulate(begin(deme_sizes), end(deme_sizes), 0u),
Expand Down
4 changes: 2 additions & 2 deletions fwdpy11/headers/fwdpy11/types/Population.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ namespace fwdpy11
// represent a matrix of N rows by "dimensions" columns.
std::vector<double> genetic_value_matrix, ancient_sample_genetic_value_matrix;

Population(fwdpp::uint_t N_, const double L)
: fwdpp_base{N_}, N{N_}, generation{0}, is_simulating{false},
Population(fwdpp::uint_t ploidy, fwdpp::uint_t N_, const double L)
: fwdpp_base{ploidy*N_}, N{N_}, generation{0}, is_simulating{false},
tables(init_tables(N_, L)), alive_nodes{}, preserved_sample_nodes{},
genetic_value_matrix{}, ancient_sample_genetic_value_matrix{}
{
Expand Down
4 changes: 4 additions & 0 deletions tests/test_DiploidPopulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def setUpClass(self):
def test_N(self):
self.assertEqual(self.pop.N, 1000)

def test_founder_genome_counts(self):
self.assertEqual(1, len(self.pop.haploid_genomes))
self.assertEqual(2 * self.pop.N, self.pop.haploid_genomes[0].n)

def test_generation(self):
self.assertEqual(self.pop.generation, 0)

Expand Down

0 comments on commit bc58956

Please sign in to comment.