Skip to content

Commit d2b23d0

Browse files
committed
fix bug in curtail()
1 parent 41683a6 commit d2b23d0

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
@@ -8,6 +8,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
88
• New model which is identical to ‘TwoSpecies’ except in that
99
lineages that terminate are replaced by _ghosts_.
1010

11+
• Bug fix in ‘curtail()’.
12+
13+
• Refactoring of ‘lbdp_exact()’.
14+
1115
_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:
1216

1317
• 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
@@ -5,6 +5,8 @@
55
\item New model in which three distinct strains compete for susceptibles from a single pool.
66
See \code{Strains}.
77
\item New model which is identical to \code{TwoSpecies} except in that lineages that terminate are replaced by \emph{ghosts}.
8+
\item Bug fix in \code{curtail()}.
9+
\item Refactoring of \code{lbdp_exact()}.
810
}
911
}
1012
\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
@@ -540,7 +540,7 @@ class genealogy_t : public nodeseq_t {
540540
if (!empty() && troot > timezero()) {
541541
node_t *p = front();
542542
node_t *q;
543-
while (!empty() && p->slate <= troot) {
543+
while (!empty() && p->slate < troot) {
544544
ball_t *b;
545545
assert(p->holds_own());
546546
while (p->size() > 1) {
@@ -552,12 +552,16 @@ class genealogy_t : public nodeseq_t {
552552
case black:
553553
q = make_node(b->deme());
554554
q->slate = troot;
555-
b->holder() = q;
556555
q->insert(b); p->erase(b);
556+
b->holder() = q;
557557
push_back(q);
558558
break;
559559
case green:
560560
q = b->child();
561+
if (q == p) {
562+
b = p->first_ball();
563+
q = b->child();
564+
}
561565
if (q->slate < troot) {
562566
q->insert(b); p->erase(b);
563567
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 620): invalid Newick label: expected one of 'b','g','m', or 'o', got ';'.
139+
Error : in 'scan_label' (genealogy.h line 624): 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 620): invalid Newick label: expected one of 'b','g','m', or 'o', got '_'.
170+
Error : in 'scan_label' (genealogy.h line 624): 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 620): invalid Newick label: expected one of 'b','g','m', or 'o', got 'z'.
176+
Error : in 'scan_label' (genealogy.h line 624): 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 620): invalid Newick label: expected one of 'b','g','m', or 'o', got '('.
215+
Error : in 'scan_label' (genealogy.h line 624): 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 637): invalid Newick format: deme should be indicated with an integer.
261+
Error : in 'scan_label' (genealogy.h line 641): 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 627): invalid Newick format.
273+
Error : in 'scan_label' (genealogy.h line 631): 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 620): invalid Newick label: expected one of 'b','g','m', or 'o', got ')'.
324+
Error : in 'scan_label' (genealogy.h line 624): 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 606): invalid Newick format: empty label.
362+
Error : in 'scan_label' (genealogy.h line 610): 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)