From bcc216792e77c0cb31b8de5419138ca4a37be8fc Mon Sep 17 00:00:00 2001 From: Abhinav Natarajan Date: Fri, 20 Sep 2024 13:59:03 +0100 Subject: [PATCH] (fix) handle empty case in get_matrix --- pyproject.toml | 2 +- src/chalc/sixpack.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 116ef28..a16c5b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "chalc" -version = "6.0.0" +version = "6.0.1" authors = [{ name = "Abhinav Natarajan", email = "natarajan@maths.ox.ac.uk" }] description = "Persistent homology of chromatic Delaunay filtrations" readme = { file = "README.md", content-type = "text/markdown" } diff --git a/src/chalc/sixpack.py b/src/chalc/sixpack.py index c74ae93..5383172 100644 --- a/src/chalc/sixpack.py +++ b/src/chalc/sixpack.py @@ -467,7 +467,11 @@ def get_matrix(self, diagram_name, dim=None): simplices.add(d) for s in dgm._unpaired: simplices.add(s) - dim = list(range(max(np.array(self._dimensions)[list(simplices)]))) + relevant_dims = np.array(self._dimensions)[list(simplices)] + if not relevant_dims: + # there are no features in the diagram + return [] + dim = list(range(max(relevant_dims))) if isinstance(dim, int): # a p-dimensional homology class is captured by a pairing of (p+1) simplices for kernels if diagram_name == "ker":