Skip to content

Commit bb9ea48

Browse files
committed
fix bug in curtail()
1 parent 632dd8a commit bb9ea48

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: phylopomp
22
Type: Package
33
Title: Phylodynamic Inference for POMP Models
4-
Version: 0.15.1.4
5-
Date: 2026-01-26
4+
Version: 0.15.2.0
5+
Date: 2026-01-29
66
Authors@R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="kingaa@umich.edu",comment=c(ORCID="0000-0001-6159-3207")),
77
person(given=c("Qianying"),family="Lin",role=c("aut"),comment=c(ORCID="0000-0001-8620-9910"))
88
)

inst/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ _C_h_a_n_g_e_s _i_n '_p_h_y_l_o_p_o_m_p' _v_e_r_s_i_o_n
1212
• New model which is identical to ‘TwoSpecies’ except in that
1313
lineages that terminate are replaced by _ghosts_.
1414

15+
• Bug fix in ‘curtail()’.
16+
17+
• Refactoring of ‘lbdp_exact()’.
18+
1519
_C_h_a_n_g_e_s _i_n '_p_h_y_l_o_p_o_m_p' _v_e_r_s_i_o_n _0._1_4:
1620

1721
• The ‘curtail()’ function now allows one to curtail a

inst/NEWS.Rd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
\item New model in which three distinct strains compete for susceptibles from a single pool.
1111
See \code{Strains}.
1212
\item New model which is identical to \code{TwoSpecies} except in that lineages that terminate are replaced by \emph{ghosts}.
13+
\item Bug fix in \code{curtail()}.
14+
\item Refactoring of \code{lbdp_exact()}.
1315
}
1416
}
1517
\section{Changes in \pkg{phylopomp} version 0.14}{

src/genealogy.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ class genealogy_t : public nodeseq_t {
543543
if (!empty() && troot > timezero()) {
544544
node_t *p = front();
545545
node_t *q;
546-
while (!empty() && p->slate <= troot) {
546+
while (!empty() && p->slate < troot) {
547547
ball_t *b;
548548
assert(p->holds_own());
549549
while (p->size() > 1) {
@@ -555,12 +555,16 @@ class genealogy_t : public nodeseq_t {
555555
case black:
556556
q = make_node(b->deme());
557557
q->slate = troot;
558-
b->holder() = q;
559558
q->insert(b); p->erase(b);
559+
b->holder() = q;
560560
push_back(q);
561561
break;
562562
case green:
563563
q = b->child();
564+
if (q == p) {
565+
b = p->first_ball();
566+
q = b->child();
567+
}
564568
if (q->slate < troot) {
565569
q->insert(b); p->erase(b);
566570
b->holder() = q;

src/nodeseq.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@ class nodeseq_t : public std::list<node_t*> {
9292
private:
9393

9494
//! Order relation among nodes.
95-
//! Nodes should be ordered by time, then by unique name.
95+
//! An ancestor node should always come before its descendants.
96+
//! Nodes should be ordered by time, then arbitrarily.
9697
static bool compare (node_t* p, node_t* q) {
9798
return (p->slate < q->slate) ||
98-
((p->slate == q->slate) && (p->uniq < q->uniq));
99+
((p->slate == q->slate) &&
100+
((p==q->green_ball()->holder()) || (p->uniq < q->uniq)));
99101
};
100102

101103
public:

src/pocket.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ class pocket_t : public std::set<ball_t*,ball_order> {
120120
}
121121
return result;
122122
};
123+
//! retrieve the first ball
124+
ball_t* first_ball (void) const {
125+
return *cbegin();
126+
};
123127
//! retrieve the last ball
124128
ball_t* last_ball (void) const {
125129
return *crbegin();

tests/parse.Rout.save

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Error : in 'scan_tree': premature end of Newick string.
136136
+ r"{((o_9_1:1.000000,b_3_2:0.500000,o_1_3:1.000000)m_0_0:0.000000);}" |>
137137
+ parse_newick()
138138
+ )
139-
Error : in 'scan_label' (genealogy.h line 623): invalid Newick label: expected one of 'b','g','m', or 'o', got ';'.
139+
Error : in 'scan_label' (genealogy.h line 627): invalid Newick label: expected one of 'b','g','m', or 'o', got ';'.
140140
>
141141
> try(
142142
+ r"{(o_9_1:1.000000,b_3_2:0.500000,o_1_3:1.000000)m_0_0:0.000000);}" |>
@@ -167,13 +167,13 @@ Error : in 'parse': invalid Newick string.
167167
+ r"{(o_9_1:1.000000)_g_1_3:1.000000)m_0_0:0.000000;}" |>
168168
+ parse_newick()
169169
+ )
170-
Error : in 'scan_label' (genealogy.h line 623): invalid Newick label: expected one of 'b','g','m', or 'o', got '_'.
170+
Error : in 'scan_label' (genealogy.h line 627): invalid Newick label: expected one of 'b','g','m', or 'o', got '_'.
171171
>
172172
> try(
173173
+ r"{(o_9_1:1.000000)z_1_3:1.000000)m_0_0:0.000000;}" |>
174174
+ parse_newick()
175175
+ )
176-
Error : in 'scan_label' (genealogy.h line 623): invalid Newick label: expected one of 'b','g','m', or 'o', got 'z'.
176+
Error : in 'scan_label' (genealogy.h line 627): invalid Newick label: expected one of 'b','g','m', or 'o', got 'z'.
177177
>
178178
> r"{((,o_9_1:1.000000,)g_1_3:1.000000)m_0_0:0.000000;}" |>
179179
+ parse_newick() |>
@@ -212,7 +212,7 @@ Error : in 'parse': invalid Newick string: unbalanced parentheses.
212212
+ r"{((((o_9_1:1.000000)g_1_3:1.000000)m_0_0:0.000000)g_3:22)()))));}" |>
213213
+ parse_newick()
214214
+ )
215-
Error : in 'scan_label' (genealogy.h line 623): invalid Newick label: expected one of 'b','g','m', or 'o', got '('.
215+
Error : in 'scan_label' (genealogy.h line 627): invalid Newick label: expected one of 'b','g','m', or 'o', got '('.
216216
>
217217
> try(
218218
+ r"{(o_9_1:1.000000,b_1_3)m_0_0:0.000000;}" |>
@@ -258,7 +258,7 @@ $newick
258258
+ r"{(o_a9_1:1.000000,b_0_0:3)m_0_0:0.000000,b_____2:17;}" |>
259259
+ parse_newick()
260260
+ )
261-
Error : in 'scan_label' (genealogy.h line 640): invalid Newick format: deme should be indicated with an integer.
261+
Error : in 'scan_label' (genealogy.h line 644): invalid Newick format: deme should be indicated with an integer.
262262
>
263263
> try(
264264
+ r"{(o_9_1:1.000000,b_0_0:3)m_0_0(:0.500000,b_____2:17;}" |>
@@ -270,7 +270,7 @@ Error : in 'scan_label': invalid Newick format: missing or invalid branch length
270270
+ r"{(o_9_1:1.000000,b_0_0:3)m_)0_0:0.500000,b_____2:17;}" |>
271271
+ parse_newick()
272272
+ )
273-
Error : in 'scan_label' (genealogy.h line 630): invalid Newick format.
273+
Error : in 'scan_label' (genealogy.h line 634): invalid Newick format.
274274
>
275275
> try(
276276
+ r"{(o_9_1:1.000000,b_0_0:3)m_0_0:(0.000000,b_____2:17;}" |>
@@ -321,7 +321,7 @@ $newick
321321
+ r"{(o_9_1:1.000000,b_0_0:3))m_0_0:0.000000,b_____2:17;}" |>
322322
+ parse_newick()
323323
+ )
324-
Error : in 'scan_label' (genealogy.h line 623): invalid Newick label: expected one of 'b','g','m', or 'o', got ')'.
324+
Error : in 'scan_label' (genealogy.h line 627): invalid Newick label: expected one of 'b','g','m', or 'o', got ')'.
325325
>
326326
> try(
327327
+ r"{(o_9_1:1.000000,b_0_0:3)m_0_0:0.000000,b_____2:17))));}" |>
@@ -359,7 +359,7 @@ Error : in 'scan_label': invalid Newick format: missing or invalid branch length
359359
+ parse_newick() |>
360360
+ newick(prune=FALSE,obscure=FALSE)
361361
+ )
362-
Error : in 'scan_label' (genealogy.h line 609): invalid Newick format: empty label.
362+
Error : in 'scan_label' (genealogy.h line 613): invalid Newick format: empty label.
363363
>
364364
> try(
365365
+ r"{(o_9_1: 1.000000,b_0:3,)m_0_0:-0.00001,b_2_45:17}" |>

0 commit comments

Comments
 (0)