Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cocycles feature #23

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[PY] Update cocycle to return a numpy array
Signed-off-by: julian <julian.burellaperez@heig-vd.ch>
julian authored and MonkeyBreaker committed Aug 17, 2022
commit 60626d7273cdb9615bef5f2d3fa9825d030c18bf
4 changes: 3 additions & 1 deletion gph/python/ripser_interface.py
Original file line number Diff line number Diff line change
@@ -667,15 +667,17 @@ def ripser_parallel(X, maxdim=1, thresh=np.inf, coeff=2, metric="euclidean",

# Unwrap cocycles
if return_cocycles:
nb_dim = len(res.cocycles_by_dim)
cocycles = []
for dim in range(len(res.cocycles_by_dim)):
for dim in range(nb_dim):
cocycles.append([])
for j in range(len(res.cocycles_by_dim[dim])):
ccl = res.cocycles_by_dim[dim][j]
n = int(len(ccl) / (dim + 2))
ccl = np.reshape(np.array(ccl, dtype=np.int64), [n, dim + 2])
ccl[:, -1] = np.mod(ccl[:, -1], coeff)
cocycles[dim].append(ccl)
cocycles = np.asarray(cocycles)

ret["cocycles"] = cocycles