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

Refactor _subdiagrams to take all homology dimensions into account #439

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Changes from all commits
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
10 changes: 7 additions & 3 deletions gtda/diagrams/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@


def _subdiagrams(X, homology_dimensions, remove_dim=False):
for dim in homology_dimensions:
Xs = X[X[:, :, 2] == dim]
Xs = Xs.reshape(X.shape[0], -1, 3)
"""For each diagram in a collection, extract the subdiagrams in a given
list of homology dimensions. It is assumed that all diagrams in X contain
the same number of points in each homology dimension."""
n = len(X)
Xs = np.concatenate([X[X[:, :, 2] == dim].reshape(n, -1, 3)
for dim in homology_dimensions],
axis=1)
if remove_dim:
Xs = Xs[:, :, :2]
return Xs
Expand Down