Skip to content

Commit

Permalink
Slice X first inside parallel calls to _subdiagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
ulupo committed Jul 21, 2020
1 parent b0e0c07 commit 25e17d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gtda/diagrams/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def transform(self, X, y=None):

with np.errstate(divide='ignore', invalid='ignore'):
Xt = Parallel(n_jobs=self.n_jobs)(
delayed(self._persistence_entropy)(_subdiagrams(X, [dim])[s])
delayed(self._persistence_entropy)(_subdiagrams(X[s], [dim]))
for dim in self.homology_dimensions_
for s in gen_even_slices(
X.shape[0], effective_n_jobs(self.n_jobs))
Expand Down
25 changes: 13 additions & 12 deletions gtda/diagrams/representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,13 @@ def transform(self, X, y=None):
X = check_diagrams(X, copy=True)

Xt = Parallel(n_jobs=self.n_jobs, mmap_mode='c')(delayed(
heats)(_subdiagrams(X, [dim], remove_dim=True)[s],
heats)(_subdiagrams(X[s], [dim], remove_dim=True),
self._samplings[dim], self._step_size[dim], self.sigma)
for dim in self.homology_dimensions_
for s in gen_even_slices(X.shape[0],
effective_n_jobs(self.n_jobs)))
Xt = np.concatenate(Xt).reshape(self._n_dimensions, X.shape[0],
self.n_bins, self.n_bins).\
Xt = np.concatenate(Xt).\
reshape(self._n_dimensions, X.shape[0], self.n_bins, self.n_bins).\
transpose((1, 0, 2, 3))
return Xt

Expand Down Expand Up @@ -793,18 +793,19 @@ def transform(self, X, y=None):
X = check_diagrams(X, copy=True)

Xt = Parallel(n_jobs=self.n_jobs, mmap_mode='c')(
delayed(persistence_images)(_subdiagrams(X, [dim],
remove_dim=True)[s],
self._samplings[dim],
self._step_size[dim],
self.weights_[dim],
self.sigma)
delayed(persistence_images)(
_subdiagrams(X[s], [dim], remove_dim=True),
self._samplings[dim],
self._step_size[dim],
self.weights_[dim],
self.sigma
)
for dim in self.homology_dimensions_
for s in gen_even_slices(X.shape[0],
effective_n_jobs(self.n_jobs))
)
Xt = np.concatenate(Xt).reshape(self._n_dimensions, X.shape[0],
self.n_bins, self.n_bins).\
Xt = np.concatenate(Xt).\
reshape(self._n_dimensions, X.shape[0], self.n_bins, self.n_bins).\
transpose((1, 0, 2, 3))
return Xt

Expand Down Expand Up @@ -975,7 +976,7 @@ def transform(self, X, y=None):
X = check_diagrams(X)

Xt = (Parallel(n_jobs=self.n_jobs)
(delayed(silhouettes)(_subdiagrams(X, [dim], remove_dim=True)[s],
(delayed(silhouettes)(_subdiagrams(X[s], [dim], remove_dim=True),
self._samplings[dim], power=self.power)
for dim in self.homology_dimensions_
for s in gen_even_slices(X.shape[0],
Expand Down

0 comments on commit 25e17d8

Please sign in to comment.