Skip to content

Commit a102f67

Browse files
authored
Merge pull request #171 from lucasimi/develop
Develop
2 parents 6374e9e + e8a4c3c commit a102f67

File tree

9 files changed

+60
-68
lines changed

9 files changed

+60
-68
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ from sklearn.datasets import make_circles
7676
from sklearn.decomposition import PCA
7777
from sklearn.cluster import DBSCAN
7878

79-
from tdamapper.core import MapperAlgorithm
79+
from tdamapper.learn import MapperAlgorithm
8080
from tdamapper.cover import CubicalCover
8181
from tdamapper.plot import MapperPlot
8282

docs/source/notebooks/circles_online.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"from sklearn.decomposition import PCA\n",
4343
"from sklearn.cluster import DBSCAN\n",
4444
"\n",
45-
"from tdamapper.core import MapperAlgorithm\n",
45+
"from tdamapper.learn import MapperAlgorithm\n",
4646
"from tdamapper.cover import CubicalCover\n",
4747
"from tdamapper.plot import MapperPlot\n",
4848
"\n",

docs/source/notebooks/digits_online.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 1,
13+
"execution_count": 5,
1414
"id": "8cf55ffb",
1515
"metadata": {},
1616
"outputs": [],
@@ -21,7 +21,7 @@
2121
"from sklearn.cluster import AgglomerativeClustering\n",
2222
"from sklearn.decomposition import PCA\n",
2323
"\n",
24-
"from tdamapper.core import MapperAlgorithm\n",
24+
"from tdamapper.learn import MapperAlgorithm\n",
2525
"from tdamapper.cover import CubicalCover\n",
2626
"from tdamapper.clustering import FailSafeClustering\n",
2727
"from tdamapper.plot import MapperPlot\n",
@@ -41,7 +41,7 @@
4141
},
4242
{
4343
"cell_type": "code",
44-
"execution_count": 2,
44+
"execution_count": 6,
4545
"id": "02d341cc",
4646
"metadata": {},
4747
"outputs": [],
@@ -68,7 +68,7 @@
6868
},
6969
{
7070
"cell_type": "code",
71-
"execution_count": 3,
71+
"execution_count": 7,
7272
"id": "a20d99cf",
7373
"metadata": {},
7474
"outputs": [
@@ -163,7 +163,7 @@
163163
},
164164
{
165165
"cell_type": "code",
166-
"execution_count": 4,
166+
"execution_count": 8,
167167
"id": "ee374256",
168168
"metadata": {},
169169
"outputs": [

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "tda-mapper"
7-
version = "0.7.3"
7+
version = "0.8.0"
88
description = "A simple and efficient Python implementation of Mapper algorithm for Topological Data Analysis"
99
readme = "README.md"
1010
authors = [{ name = "Luca Simi", email = "lucasimi90@gmail.com" }]

src/tdamapper/_common.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
import numpy as np
77

88

9-
def warn_deprecated(deprecated, substitute):
10-
msg = f'{deprecated} is deprecated and will be removed in a future version. Use {substitute} instead.'
11-
warnings.warn(
12-
msg,
13-
DeprecationWarning,
14-
stacklevel=2
15-
)
9+
warnings.filterwarnings(
10+
'default',
11+
category=DeprecationWarning,
12+
module=r'^tdamapper\.'
13+
)
14+
15+
16+
def deprecated(msg):
17+
def deprecated_func(func):
18+
def wrapper(*args, **kwargs):
19+
warnings.warn(msg, DeprecationWarning, stacklevel=2)
20+
return func(*args, **kwargs)
21+
return wrapper
22+
return deprecated_func
1623

1724

1825
def warn_user(msg):

src/tdamapper/clustering.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ParamsMixin,
99
EstimatorMixin,
1010
clone,
11-
warn_deprecated,
11+
deprecated,
1212
)
1313

1414

@@ -17,25 +17,27 @@ class TrivialClustering(tdamapper.core.TrivialClustering):
1717
**DEPRECATED**: This class is deprecated and will be removed in a future
1818
release. Use :class:`tdamapper.core.TrivialClustering`.
1919
"""
20-
def __init__(self):
21-
warn_deprecated(
22-
TrivialClustering.__qualname__,
23-
tdamapper.core.TrivialClustering.__qualname__,
24-
)
25-
super().__init__()
20+
21+
@deprecated(
22+
'This class is deprecated and will be removed in a future release. '
23+
'Use tdamapper.core.TrivialClustering.'
24+
)
25+
def __init__(self, *args, **kwargs):
26+
super().__init__(*args, **kwargs)
2627

2728

2829
class FailSafeClustering(tdamapper.core.FailSafeClustering):
2930
"""
3031
**DEPRECATED**: This class is deprecated and will be removed in a future
3132
release. Use :class:`tdamapper.core.FailSafeClustering`.
3233
"""
33-
def __init__(self, clustering=None, verbose=True):
34-
warn_deprecated(
35-
FailSafeClustering.__qualname__,
36-
tdamapper.core.FailSafeClustering.__qualname__,
37-
)
38-
super().__init__(clustering, verbose)
34+
35+
@deprecated(
36+
'This class is deprecated and will be removed in a future release. '
37+
'Use tdamapper.core.FailSafeClustering.'
38+
)
39+
def __init__(self, *args, **kwargs):
40+
super().__init__(*args, **kwargs)
3941

4042

4143
class _MapperClustering(EstimatorMixin, ParamsMixin):
@@ -73,13 +75,9 @@ class MapperClustering(_MapperClustering):
7375
release. Use :class:`tdamapper.learn.MapperClustering`.
7476
"""
7577

76-
def __init__(self, cover=None, clustering=None, n_jobs=1):
77-
warn_deprecated(
78-
MapperClustering.__qualname__,
79-
'tdamapper.learn.MapperClustering',
80-
)
81-
super().__init__(
82-
cover=cover,
83-
clustering=clustering,
84-
n_jobs=n_jobs,
85-
)
78+
@deprecated(
79+
'This class is deprecated and will be removed in a future release. '
80+
'Use tdamapper.learn.MapperClustering.'
81+
)
82+
def __init__(self, *args, **kwargs):
83+
super().__init__(*args, **kwargs)

src/tdamapper/core.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from tdamapper.utils.unionfind import UnionFind
3636
from tdamapper._common import (
3737
clone,
38-
warn_deprecated,
38+
deprecated,
3939
ParamsMixin,
4040
EstimatorMixin,
4141
)
@@ -424,25 +424,12 @@ class MapperAlgorithm(_MapperAlgorithm):
424424
release. Use :class:`tdamapper.learn.MapperAlgorithm`.
425425
"""
426426

427-
def __init__(
428-
self,
429-
cover=None,
430-
clustering=None,
431-
failsafe=True,
432-
verbose=True,
433-
n_jobs=1,
434-
):
435-
warn_deprecated(
436-
MapperAlgorithm.__qualname__,
437-
'tdamapper.learn.MapperAlgorithm',
438-
)
439-
super().__init__(
440-
cover=cover,
441-
clustering=clustering,
442-
failsafe=failsafe,
443-
verbose=verbose,
444-
n_jobs=n_jobs,
445-
)
427+
@deprecated(
428+
'This class is deprecated and will be removed in a future release. '
429+
'Use tdamapper.learn.MapperAlgorithm.'
430+
)
431+
def __init__(self, *args, **kwargs):
432+
super().__init__(*args, **kwargs)
446433

447434

448435
class FailSafeClustering(ParamsMixin):

src/tdamapper/plot.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from tdamapper._plot_plotly import plot_plotly, plot_plotly_update
1010
from tdamapper._plot_pyvis import plot_pyvis
1111

12-
from tdamapper._common import warn_deprecated
12+
from tdamapper._common import deprecated
1313

1414

1515
class MapperPlot:
@@ -289,6 +289,10 @@ class MapperLayoutInteractive:
289289
:type cmap: str, optional
290290
"""
291291

292+
@deprecated(
293+
'This class is deprecated and will be removed in a future release. '
294+
'Use tdamapper.plot.MapperPlot.'
295+
)
292296
def __init__(
293297
self,
294298
graph,
@@ -302,10 +306,6 @@ def __init__(
302306
height=512,
303307
cmap='jet',
304308
):
305-
warn_deprecated(
306-
MapperLayoutInteractive.__qualname__,
307-
MapperPlot.__qualname__,
308-
)
309309
self.__graph = graph
310310
self.__dim = dim
311311
self.__iterations = iterations
@@ -450,6 +450,10 @@ class MapperLayoutStatic:
450450
:type cmap: str, optional
451451
"""
452452

453+
@deprecated(
454+
'This class is deprecated and will be removed in a future release. '
455+
'Use tdamapper.plot.MapperPlot.'
456+
)
453457
def __init__(
454458
self,
455459
graph,
@@ -463,10 +467,6 @@ def __init__(
463467
height=512,
464468
cmap='jet',
465469
):
466-
warn_deprecated(
467-
MapperLayoutStatic.__qualname__,
468-
MapperPlot.__qualname__,
469-
)
470470
self.__colors = colors
471471
self.__agg = agg
472472
self.__title = title

tests/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sklearn.decomposition import PCA
55
from sklearn.cluster import DBSCAN
66

7-
from tdamapper.core import MapperAlgorithm
7+
from tdamapper.learn import MapperAlgorithm
88
from tdamapper.cover import CubicalCover
99
from tdamapper.plot import MapperPlot
1010

0 commit comments

Comments
 (0)