-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial API elements to ForwardDemesGraph:
* initialization * iteration * error-handling, throws DemographyError * tests
- Loading branch information
Showing
7 changed files
with
209 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "forward_demes_graph_fixtures.hpp" | ||
|
||
const char* single_deme_model = R"( | ||
description: single deme model | ||
time_units: generations | ||
demes: | ||
- name: A | ||
epochs: | ||
- start_size: 100 | ||
)"; | ||
|
||
const char* single_deme_one_size_change = R"( | ||
time_units: generations | ||
demes: | ||
- name: A | ||
epochs: | ||
- start_size: 100 | ||
end_time: 50 | ||
- start_size: 200 | ||
)"; | ||
|
||
SingleDemeModel::SingleDemeModel() : yaml(single_deme_model) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
struct SingleDemeModel | ||
{ | ||
std::string yaml; | ||
SingleDemeModel(); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <boost/test/unit_test.hpp> | ||
|
||
#include <boost/test/unit_test_suite.hpp> | ||
#include <fwdpy11/types/DiploidPopulation.hpp> | ||
#include <core/demes/forward_graph.hpp> | ||
#include <stdexcept> | ||
|
||
#include "forward_demes_graph_fixtures.hpp" | ||
|
||
BOOST_AUTO_TEST_SUITE(test_forward_demes_graph) | ||
|
||
BOOST_FIXTURE_TEST_CASE(test_zero_length_single_deme_model, SingleDemeModel) | ||
{ | ||
fwdpy11_core::ForwardDemesGraph g(yaml, 0); | ||
fwdpy11::DiploidPopulation pop(100, 1.0); | ||
g.initialize_model(pop.generation); | ||
auto end_time = g.model_end_time(); | ||
BOOST_REQUIRE_EQUAL(end_time, 1); | ||
while (g.iterating_model()) | ||
{ | ||
g.iterate_state(); | ||
pop.generation += 1; | ||
} | ||
BOOST_REQUIRE_EQUAL(pop.generation, 0); | ||
} | ||
|
||
BOOST_FIXTURE_TEST_CASE(single_deme_model_with_burn_in, SingleDemeModel) | ||
{ | ||
fwdpy11_core::ForwardDemesGraph g(yaml, 10); | ||
fwdpy11::DiploidPopulation pop(100, 1.0); | ||
g.initialize_model(pop.generation); | ||
auto end_time = g.model_end_time(); | ||
BOOST_REQUIRE_EQUAL(end_time, 11); | ||
while (g.iterating_model()) | ||
{ | ||
g.iterate_state(); | ||
pop.generation += 1; | ||
} | ||
BOOST_REQUIRE_EQUAL(pop.generation, 10); | ||
} | ||
|
||
BOOST_FIXTURE_TEST_CASE(single_deme_model_with_burn_in_THE_CODE_WE_WANT_TO_WRITE, | ||
SingleDemeModel) | ||
{ | ||
fwdpy11_core::ForwardDemesGraph g(yaml, 10); | ||
fwdpy11::DiploidPopulation pop(100, 1.0); | ||
g.initialize_model(pop.generation); | ||
auto end_time = g.model_end_time(); | ||
BOOST_REQUIRE_EQUAL(end_time, 11); | ||
while (g.iterating_model()) | ||
{ | ||
g.iterate_state(); | ||
pop.generation += 1; | ||
} | ||
BOOST_REQUIRE_EQUAL(pop.generation, 10); | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters