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

Tests for plotting functions and methods, other increases in test coverage #384

Merged
merged 36 commits into from Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
877dad3
Bump version to 0.2.0, add release notes
Mar 23, 2020
6bc28c0
Add Adelie as contributor
Mar 23, 2020
a13f5e6
Add Mapper color bug
Mar 23, 2020
fb79a4d
Update ccache
Mar 23, 2020
50b372a
Add @ammermar as a contributor in release notes
Mar 23, 2020
804a161
List all classes in images subpackage
Mar 23, 2020
5aa2723
Add @ammedmar as a contributor in release notes
Mar 23, 2020
86be78f
List all classes in images subpackage
Mar 23, 2020
93747b6
Merge remote-tracking branch 'origin/master'
Mar 23, 2020
02cb3b9
Add new lines before bullet lists in rst
Mar 23, 2020
0da531d
Add forgotten line break
Mar 23, 2020
79c5d4a
Attempt at improving LaTeX rendering in mapper_quickstart
Mar 23, 2020
396d6b3
Fix broken URL in release notes
Mar 23, 2020
97ebebb
Merge branch 'master' of https://github.com/giotto-ai/giotto-tda
Mar 23, 2020
a11e75b
Add @rth to code authors and list of contributors for v0.2.0
Mar 23, 2020
439e49b
Add twine check to azure-pipelines.yml, attempt at fix to README
Mar 23, 2020
9045d95
Merge branch 'master' of https://github.com/giotto-ai/giotto-tda
Mar 23, 2020
89a5d63
Fix duplicate link, not accepted by twine
Mar 23, 2020
57eac94
Fix typo and remove another duplicate
Mar 23, 2020
44d76cb
Merge branch 'master' of https://github.com/giotto-ai/giotto-tda
Mar 23, 2020
96f8caa
Remove images subpackage from code omitted from coverage
Mar 29, 2020
fc85d35
Add tests for Filtering class
Mar 29, 2020
457e1a1
Add tests in diagrams subpackage, linting
Mar 30, 2020
0ce028c
Add fit_transform_plot test for GraphGeodesicDistance
Mar 30, 2020
0be4ada
Add fit_transform_plot tests in gtda.homology
Mar 30, 2020
03b5afa
Fix typo in voids_on_the_plane notebook
Mar 30, 2020
0bc60e0
Add fit_transform_plot tests for images subpackage
Mar 30, 2020
9acbb28
Add fit_transform_plot tests for point_clouds subpackage
Mar 30, 2020
550ba59
Add test for SlidingWindow.plot
Mar 30, 2020
62f9aa0
Linting
Mar 30, 2020
25f7b9b
Fix flake8 issues
Mar 30, 2020
612f35c
Exclude gtda.utils._doc and gtda.utils.intervals from coveragerc
Mar 30, 2020
b0d66c3
Implement @wreise's suggestions
Mar 30, 2020
8b69bb4
Upload coverage report only from macOS job
Mar 30, 2020
6e5b4fc
Fix typo
Mar 30, 2020
21f38b1
Exclude test folders from coverage reports
Mar 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions .coveragerc
@@ -1,14 +1,10 @@
[run]
omit =
*/gtda/externals/*
**/setup.py

*/gtda/compose/*
*/gtda/datasets/*
*/gtda/images/*
*/gtda/neural_network/*
*/gtda/model_selection/*

**/gtda/utils/intervals.py
**/gtda/utils/_docs.py
**/base.py
**/pipeline.py
**/_version.py
**/setup.py
**/_version.py
2 changes: 1 addition & 1 deletion examples/voids_on_the_plane.ipynb
Expand Up @@ -8,7 +8,7 @@
"\n",
"The classic example of a two-dimensional homology class is the \"void\" surrounded by a sphere in three-dimensional space.\n",
"Challenge question: **Can two-dimensional topological voids arise from point clouds in two-dimensional space?**\n",
"We will answer this question programmatically by computing Vietoris–Rips persistence homology of random point clouds in the square $[0, 1] \\times [0, 1] \\subset \\mathbb{R}^2$.\n",
"We will answer this question programmatically by computing Vietoris–Rips persistent homology of random point clouds in the square $[0, 1] \\times [0, 1] \\subset \\mathbb{R}^2$.\n",
"\n",
"If you are looking at a static version of this notebook and would like to run its contents, head over to [github](https://github.com/giotto-ai/giotto-tda/blob/master/examples/voids_on_the_plane.ipynb).\n",
"\n",
Expand Down
5 changes: 2 additions & 3 deletions gtda/diagrams/distance.py
Expand Up @@ -102,9 +102,8 @@ class PairwiseDistance(BaseEstimator, TransformerMixin):

See also
--------
Amplitude, Scaler, Filtering, \
BettiCurve, PersistenceLandscape, \
HeatKernel, Silhouette, \
Amplitude, Scaler, Filtering, BettiCurve, PersistenceLandscape, \
PersistenceImage, HeatKernel, Silhouette, \
gtda.homology.VietorisRipsPersistence

Notes
Expand Down
185 changes: 92 additions & 93 deletions gtda/diagrams/representations.py
Expand Up @@ -179,51 +179,51 @@ def plot(self, Xt, sample=0, homology_dimensions=None):
for dim in homology_dimensions:
if dim not in self.homology_dimensions_:
raise ValueError(
f'All homology dimensions must be in '
f'self.homology_dimensions_ which is '
f'{self.homology_dimensions_}. {dim} is not.')
f"All homology dimensions must be in "
Copy link
Collaborator Author

@ulupo ulupo Mar 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to use these quotation marks consistently in sentence-like strings as they are safe when apostrophes have to be used inside as well.

f"self.homology_dimensions_ which is "
f"{self.homology_dimensions_}. {dim} is not.")
else:
homology_dimensions_arr = np.array(
self.homology_dimensions_)
ix = np.flatnonzero(homology_dimensions_arr == dim)[0]
_homology_dimensions.append((ix, dim))

layout = {
"xaxis1": {
"title": "Filtration parameter",
"side": "bottom",
"type": "linear",
"ticks": "outside",
"anchor": "x1",
"showline": True,
"zeroline": True,
"showexponent": "all",
"exponentformat": "e"
},
"yaxis1": {
"title": "Betti number",
"side": "left",
"type": "linear",
"ticks": "outside",
"anchor": "y1",
"showline": True,
"zeroline": True,
"showexponent": "all",
"exponentformat": "e"
},
"plot_bgcolor": "white"
}
layout = dict(
xaxis1=dict(
title="Filtration parameter",
side="bottom",
type="linear",
ticks="outside",
anchor="x1",
showline=True,
zeroline=True,
showexponent="all",
exponentformat="e"
),
yaxis1=dict(
title="Betti number",
side="left",
type="linear",
ticks="outside",
anchor="y1",
showline=True,
zeroline=True,
showexponent="all",
exponentformat="e"
),
plot_bgcolor="white"
)
wreise marked this conversation as resolved.
Show resolved Hide resolved
fig = gobj.Figure(layout=layout)
fig.update_xaxes(zeroline=True, linewidth=1, linecolor='black',
fig.update_xaxes(zeroline=True, linewidth=1, linecolor="black",
mirror=False)
fig.update_yaxes(zeroline=True, linewidth=1, linecolor='black',
fig.update_yaxes(zeroline=True, linewidth=1, linecolor="black",
mirror=False)

for ix, dim in _homology_dimensions:
fig.add_trace(gobj.Scatter(x=self.samplings_[dim],
y=Xt[sample][ix],
mode='lines', showlegend=True,
name=f'H{int(dim)}'))
name=f"H{int(dim)}"))

fig.show()

Expand Down Expand Up @@ -395,48 +395,48 @@ def plot(self, Xt, sample=0, homology_dimensions=None):
for dim in homology_dimensions:
if dim not in self.homology_dimensions_:
raise ValueError(
f'All homology dimensions must be in '
f'self.homology_dimensions_ which is '
f'{self.homology_dimensions_}. {dim} is not.')
f"All homology dimensions must be in "
f"self.homology_dimensions_ which is "
f"{self.homology_dimensions_}. {dim} is not.")
else:
homology_dimensions_arr = np.array(
self.homology_dimensions_)
ix = np.flatnonzero(homology_dimensions_arr == dim)[0]
_homology_dimensions.append((ix, dim))

layout = {
"xaxis1": {
"side": "bottom",
"type": "linear",
"ticks": "outside",
"anchor": "y1",
"showline": True,
"zeroline": True,
"showexponent": "all",
"exponentformat": "e"
},
"yaxis1": {
"side": "left",
"type": "linear",
"ticks": "outside",
"anchor": "x1",
"showline": True,
"zeroline": True,
"showexponent": "all",
"exponentformat": "e"
},
"plot_bgcolor": "white"
}
layout = dict(
xaxis1=dict(
side="bottom",
type="linear",
ticks="outside",
anchor="y1",
showline=True,
zeroline=True,
showexponent="all",
exponentformat="e"
),
yaxis1=dict(
side="left",
type="linear",
ticks="outside",
anchor="x1",
showline=True,
zeroline=True,
showexponent="all",
exponentformat="e"
),
plot_bgcolor="white"
)

Xt_sample = Xt[sample]
for ix, dim in _homology_dimensions:
layout_dim = layout.copy()
layout_dim['title'] = "Persistence landscape for homology " + \
"dimension {}".format(int(dim))
fig = gobj.Figure(layout=layout_dim)
fig.update_xaxes(zeroline=True, linewidth=1, linecolor='black',
fig.update_xaxes(zeroline=True, linewidth=1, linecolor="black",
mirror=False)
fig.update_yaxes(zeroline=True, linewidth=1, linecolor='black',
fig.update_yaxes(zeroline=True, linewidth=1, linecolor="black",
mirror=False)

n_layers = Xt_sample.shape[1]
Expand Down Expand Up @@ -598,8 +598,7 @@ def transform(self, X, y=None):
transpose((1, 0, 2, 3))
return Xt

def plot(self, Xt, sample=0, homology_dimension_ix=0,
colorscale='blues'):
def plot(self, Xt, sample=0, homology_dimension_ix=0, colorscale='blues'):
"""Plot a single channel – corresponding to a given homology
dimension – in a sample from a collection of heat kernel images.

Expand Down Expand Up @@ -1014,50 +1013,50 @@ def plot(self, Xt, sample=0, homology_dimensions=None):
for dim in homology_dimensions:
if dim not in self.homology_dimensions_:
raise ValueError(
f'All homology dimensions must be in '
f'self.homology_dimensions_ which is '
f'{self.homology_dimensions_}. {dim} is not.')
f"All homology dimensions must be in "
f"self.homology_dimensions_ which is "
f"{self.homology_dimensions_}. {dim} is not.")
else:
homology_dimensions_arr = np.array(
self.homology_dimensions_)
ix = np.flatnonzero(homology_dimensions_arr == dim)[0]
_homology_dimensions.append((ix, dim))

layout = {
"xaxis1": {
"title": "Filtration parameter",
"side": "bottom",
"type": "linear",
"ticks": "outside",
"anchor": "x1",
"showline": True,
"zeroline": True,
"showexponent": "all",
"exponentformat": "e"
},
"yaxis1": {
"side": "left",
"type": "linear",
"ticks": "outside",
"anchor": "y1",
"showline": True,
"zeroline": True,
"showexponent": "all",
"exponentformat": "e"
},
"plot_bgcolor": "white"
}
layout = dict(
xaxis1=dict(
title="Filtration parameter",
side="bottom",
type="linear",
ticks="outside",
anchor="x1",
showline=True,
zeroline=True,
showexponent="all",
exponentformat="e"
),
yaxis1=dict(
side="left",
type="linear",
ticks="outside",
anchor="y1",
showline=True,
zeroline=True,
showexponent="all",
exponentformat="e"
),
plot_bgcolor="white"
)
fig = gobj.Figure(layout=layout)
fig.update_xaxes(zeroline=True, linewidth=1, linecolor='black',
fig.update_xaxes(zeroline=True, linewidth=1, linecolor="black",
mirror=False)
fig.update_yaxes(zeroline=True, linewidth=1, linecolor='black',
fig.update_yaxes(zeroline=True, linewidth=1, linecolor="black",
mirror=False)

for ix, dim in _homology_dimensions:
fig.add_trace(gobj.Scatter(x=self.samplings_[dim],
y=Xt[sample][ix],
mode='lines', showlegend=True,
hoverinfo='none',
name=f'H{int(dim)}'))
mode="lines", showlegend=True,
hoverinfo="none",
name=f"H{int(dim)}"))

fig.show()