@@ -649,9 +649,7 @@ def inside_pass(self, *, normalize=True, cache_inside=False, progress=None):
649
649
)
650
650
# It is possible that a simple node is non-fixed, in which case we want to
651
651
# provide an inside array that reflects the prior distribution
652
- nonfixed_samples = np .intersect1d (
653
- self .priors .nonfixed_node_ids (), self .ts .samples ()
654
- )
652
+ nonfixed_samples = np .intersect1d (inside .nonfixed_node_ids (), self .ts .samples ())
655
653
for u in nonfixed_samples :
656
654
# this is in the same probability space as the prior, so we should be
657
655
# OK just to copy the prior values straight in (but we should check they
@@ -663,6 +661,8 @@ def inside_pass(self, *, normalize=True, cache_inside=False, progress=None):
663
661
(self .ts .num_edges , self .lik .grid_size ), self .lik .identity_constant
664
662
)
665
663
norm = np .full (self .ts .num_nodes , np .nan )
664
+ to_visit = np .zeros (self .ts .num_nodes , dtype = bool )
665
+ to_visit [inside .nonfixed_node_ids ()] = True
666
666
# Iterate through the nodes via groupby on parent node
667
667
for parent , edges in tqdm (
668
668
self .edges_by_parent_asc (),
@@ -707,6 +707,12 @@ def inside_pass(self, *, normalize=True, cache_inside=False, progress=None):
707
707
g_i [edge .id ] = edge_lik
708
708
norm [parent ] = np .max (val ) if normalize else 1
709
709
inside [parent ] = self .lik .reduce (val , norm [parent ])
710
+ to_visit [parent ] = False
711
+
712
+ # There may be nodes that are not parents but are also not fixed (e.g.
713
+ # undated sample nodes). These need an identity normalization constant
714
+ for unfixed_unvisited in np .where (to_visit )[0 ]:
715
+ norm [unfixed_unvisited ] = 1
710
716
711
717
if cache_inside :
712
718
self .g_i = self .lik .reduce (g_i , norm [self .ts .tables .edges .child , None ])
0 commit comments