Skip to content

Commit

Permalink
Create v0.5.1 (#599)
Browse files Browse the repository at this point in the history
* Make ParallelClustering picklable, fixing memory caching in Mapper pipelines (#597)

* Prepare v0.5.1 (#598)
  • Loading branch information
ulupo committed Jul 9, 2021
1 parent 51b2a8d commit 4c13c5d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 11 deletions.
4 changes: 2 additions & 2 deletions doc/library.rst
Expand Up @@ -124,5 +124,5 @@ What's new

.. include::
release.rst
:start-after: Release 0.5.0
:end-before: Release 0.4.0
:start-after: Release 0.5.1
:end-before: Release 0.5.0
30 changes: 30 additions & 0 deletions doc/release.rst
Expand Up @@ -4,6 +4,36 @@ Release Notes

.. _stable:

*************
Release 0.5.1
*************

This release was made shortly after the release of version 0.5.0, to resolve an important bug. Please refer to `the release notes for 0.5.0 <https://giotto-ai.github.io/gtda-docs/0.5.0/release.html#release-0-5-0>`_ to see the major improvements and backwards-incompatible changes to the Mapper subpackage which were introduced there.

Major Features and Improvements
===============================

None.

Bug Fixes
=========

A bug preventing Mapper pipelines from working with memory caching has been fixed (`#597 <https://github.com/giotto-ai/giotto-tda/pull/597>`_).

Backwards-Incompatible Changes
==============================

None.

Thanks to our Contributors
==========================

This release contains contributions from:

Umberto Lupo

We are also grateful to all who filed issues or helped resolve them, asked and answered questions, and were part of inspiring discussions.

*************
Release 0.5.0
*************
Expand Down
1 change: 1 addition & 0 deletions doc/versions
Expand Up @@ -5,4 +5,5 @@
./0.3.1
./0.4.0
./0.5.0
./0.5.1
./latest
2 changes: 1 addition & 1 deletion gtda/_version.py
Expand Up @@ -19,4 +19,4 @@
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
#

__version__ = "0.5.0"
__version__ = "0.5.1"
26 changes: 20 additions & 6 deletions gtda/mapper/cluster.py
Expand Up @@ -16,6 +16,22 @@
from ..utils.validation import validate_params


def _sample_weight_computer(rel_indices, sample_weight):
return {"sample_weight": sample_weight[rel_indices]}


def _empty_dict(*args):
return {}


def _indices_computer_precomputed(rel_indices):
return np.ix_(rel_indices, rel_indices)


def _indices_computer_not_precomputed(rel_indices):
return rel_indices


class ParallelClustering(BaseEstimator):
"""Employ joblib parallelism to cluster different portions of a dataset.
Expand Down Expand Up @@ -129,16 +145,14 @@ def fit(self, X, y=None, sample_weight=None):

fit_params = signature(self.clusterer.fit).parameters
if sample_weight is not None and "sample_weight" in fit_params:
self._sample_weight_computer = lambda rel_indices, sample_weight: \
{"sample_weight": sample_weight[rel_indices]}
self._sample_weight_computer = _sample_weight_computer
else:
self._sample_weight_computer = lambda *args: {}
self._sample_weight_computer = _empty_dict

if self._precomputed:
self._indices_computer = lambda rel_indices: \
np.ix_(rel_indices, rel_indices)
self._indices_computer = _indices_computer_precomputed
else:
self._indices_computer = lambda rel_indices: rel_indices
self._indices_computer = _indices_computer_not_precomputed

# This seems necessary to avoid large overheads when running fit a
# second time. Probably due to refcounts. NOTE: Only works if done
Expand Down
15 changes: 14 additions & 1 deletion gtda/mapper/tests/test_cluster.py
Expand Up @@ -2,6 +2,9 @@
for ParallelClustering."""
# License: GNU AGPLv3

from shutil import rmtree
from tempfile import mkdtemp

import numpy as np
import pytest
import sklearn as sk
Expand All @@ -11,7 +14,8 @@
from numpy.testing import assert_almost_equal
from scipy.spatial import distance_matrix

from gtda.mapper import ParallelClustering, FirstHistogramGap, FirstSimpleGap
from gtda.mapper import ParallelClustering, FirstHistogramGap, \
FirstSimpleGap, make_mapper_pipeline


def test_parallel_clustering_bad_input():
Expand Down Expand Up @@ -233,3 +237,12 @@ def get_partition_from_preds(preds):

assert get_partition_from_preds(preds) == \
get_partition_from_preds(preds_mat)


def test_mapper_pipeline_picklable():
# Regression test for issue #596
X = np.random.random((100, 2))
cachedir = mkdtemp()
pipe = make_mapper_pipeline(memory=cachedir)
pipe.fit_transform(X)
rmtree(cachedir)
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -29,7 +29,7 @@
MAINTAINER_EMAIL = "maintainers@giotto.ai"
URL = "https://github.com/giotto-ai/giotto-tda"
LICENSE = "GNU AGPLv3"
DOWNLOAD_URL = "https://github.com/giotto-ai/giotto-tda/tarball/v0.5.0"
DOWNLOAD_URL = "https://github.com/giotto-ai/giotto-tda/tarball/v0.5.1"
VERSION = __version__ # noqa
CLASSIFIERS = ["Intended Audience :: Science/Research",
"Intended Audience :: Developers",
Expand Down

0 comments on commit 4c13c5d

Please sign in to comment.