Skip to content

Commit

Permalink
Prevent panic in antipushout
Browse files Browse the repository at this point in the history
  • Loading branch information
calintat committed Feb 3, 2024
1 parent 1ac95b9 commit 8ce8a58
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions homotopy-core/src/antipushout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ pub fn antipushout(
)
})
.multi_cartesian_product()
.map(|spans| {
.filter_map(|spans| {
let s_slices =
spans.iter().map(|span| span.0.clone()).collect_vec();
let h_slices =
spans.iter().map(|span| span.1.clone()).collect_vec();
let k_slices =
spans.iter().map(|span| span.2.clone()).collect_vec();

let s = construct_source(a, h_mono, &h_slices, &s_slices);
let s = construct_source(a, h_mono, &h_slices, &s_slices)?;

let h = RewriteN::from_monotone_unlabelled(
s.dimension(),
Expand All @@ -172,7 +172,7 @@ pub fn antipushout(
&k_slices,
);

(s.into(), h.into(), k.into())
Some((s.into(), h.into(), k.into()))
})
.collect_vec()
}
Expand All @@ -188,7 +188,7 @@ fn construct_source(
mono: &Monotone,
slices: &[Rewrite],
source_slices: &[Diagram],
) -> DiagramN {
) -> Option<DiagramN> {
let mut cospans = vec![];
let target_slices = target.singular_slices().collect_vec();
for (ti, cospan) in target.cospans().iter().enumerate() {
Expand All @@ -200,13 +200,14 @@ fn construct_source(
let mut rewrites = vec![factorize(&cospan.forward, &slices[start]).next().unwrap()];

for si in start..end - 1 {
let span = &antipushout(
let antipushouts = antipushout(
&source_slices[si],
&source_slices[si + 1],
&target_slices[ti],
&slices[si],
&slices[si + 1],
)[0];
);
let span = antipushouts.first()?;
rewrites.push(span.1.clone());
rewrites.push(span.2.clone());
}
Expand All @@ -226,7 +227,7 @@ fn construct_source(
}
}

DiagramN::new(target.source(), cospans)
Some(DiagramN::new(target.source(), cospans))
}

impl RewriteN {
Expand Down

0 comments on commit 8ce8a58

Please sign in to comment.