Skip to content

Fix error in transmitting nodes. Closes #96 #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions examples/forward_simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,15 @@ fn crossover_and_record_edges_details(
tables: &mut tskit::TableCollection,
rng: &mut StdRng,
) {
let mut pnodes = (parent.node0, parent.node1);
mendel(&mut pnodes, rng);

if params.xovers == 0.0 {
match tables.add_edge(0., tables.sequence_length(), parent.node0, offspring_node) {
match tables.add_edge(0., tables.sequence_length(), pnodes.0, offspring_node) {
Ok(_) => (),
Err(e) => panic!("{}", e),
}
} else {
let mut pnodes = (parent.node0, parent.node1);
mendel(&mut pnodes, rng);

let mut p0 = parent.node0;
let mut p1 = parent.node1;

let exp = match Exp::new(params.xovers / tables.sequence_length()) {
Ok(e) => e,
Err(e) => panic!("{}", e),
Expand All @@ -243,18 +240,22 @@ fn crossover_and_record_edges_details(
match tables.add_edge(
current_pos,
current_pos + next_length,
p0,
pnodes.0,
offspring_node,
) {
Ok(_) => (),
Err(e) => panic!("{}", e),
}
std::mem::swap(&mut p0, &mut p1);
std::mem::swap(&mut pnodes.0, &mut pnodes.1);
current_pos += next_length;
}
Some(_) => {
match tables.add_edge(current_pos, tables.sequence_length(), p0, offspring_node)
{
match tables.add_edge(
current_pos,
tables.sequence_length(),
pnodes.0,
offspring_node,
) {
Ok(_) => (),
Err(e) => panic!("{}", e),
}
Expand Down