Skip to content

Commit f58729c

Browse files
authored
Fix pl plotting (#55)
* Fix labels for plots The previous label keyword had no effect; this fixes that and adds doc string entries for labels. * Add max_depth attribute to PersLandscapeApprox * Fix depth axis The tick marks on the y-axis (corresponding to depth of the landscapes) were completely off and mislabeled. * Add 'depth_range' parameter to signature The new 'depth_range' parameter allows the user to specify a range of depths to be plotted. Omitting it plots all depths. * Clean up doc strings and signatures The doc strings were previously in the helper functions, which were not publicly accessible. Move the docstrings into the two main plotting functions and clean up the signatures of the plotting functions. * Fix padding The previous way of padding the figures changed their values slightly. The 'padding' parameter now adds a slight margin to the plot, especially useful for 2-d 'simple' plots. * Remove depth_spacing/depth_padding `depth_spacing` caused overcrowding issues with labelling. If it needs to be modified, it should be done on a case by case basis by passing an axis. * Fix "gca('3d') deprecation warning" * Update notebooks
1 parent e1fb188 commit f58729c

9 files changed

+308
-147
lines changed

.readthedocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
version: 2
22

3+
build:
4+
os: "ubuntu-22.04"
5+
tools:
6+
python: "3.11"
7+
38
python:
4-
version: 3.7
59
install:
610
- requirements: docs/requirements.txt
711
- method: pip

RELEASE.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.3.3
2+
- Fix plotting methods of Persistence Landscapes, add doc strings.
3+
- Update to notebooks.
4+
15
0.3.2
26
- Update codebase to support python 3.7 - 3.12.
37
- Change `PersistenceLandscaper` API for sklearn compatibility.

docs/notebooks/Classification with persistence images.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@
361361
],
362362
"metadata": {
363363
"kernelspec": {
364-
"display_name": "persimenv",
364+
"display_name": "Python 3",
365365
"language": "python",
366-
"name": "persimenv"
366+
"name": "python3"
367367
},
368368
"language_info": {
369369
"codemirror_mode": {
@@ -375,7 +375,7 @@
375375
"name": "python",
376376
"nbconvert_exporter": "python",
377377
"pygments_lexer": "ipython3",
378-
"version": "3.7.9"
378+
"version": "3.8.5"
379379
}
380380
},
381381
"nbformat": 4,

docs/notebooks/Differentiation with Persistence Landscapes.ipynb

Lines changed: 11 additions & 11 deletions
Large diffs are not rendered by default.

docs/notebooks/Persistence Landscapes and Machine Learning.ipynb

Lines changed: 44 additions & 47 deletions
Large diffs are not rendered by default.

persim/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.2"
1+
__version__ = "0.3.3"

persim/landscapes/approximate.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def __init__(
152152
self.start = start
153153
self.stop = stop
154154
self.values = values
155+
self.max_depth = len(self.values)
155156
self.num_steps = num_steps
156157
if compute:
157158
self.compute_landscape()
@@ -178,7 +179,6 @@ def compute_landscape(self, verbose: bool = False) -> list:
178179
if self.values.size:
179180
verboseprint("values was stored, exiting")
180181
return
181-
182182
verboseprint("values was empty, computing values")
183183
# make grid
184184
grid_values, step = np.linspace(
@@ -214,17 +214,14 @@ def compute_landscape(self, verbose: bool = False) -> list:
214214
j += 1
215215
# j*step: adding points from a line with slope 1
216216
W[ind_in_Wb + j].append(j * step)
217-
218217
j = 0
219218
# j in (b+d/2, d)
220219
for _ in range(mid_pt + 1, ind_in_Wd):
221220
j += 1
222221
W[ind_in_Wd - j].append(j * step)
223-
224222
# sort each list in W
225223
for i in range(len(W)):
226224
W[i] = sorted(W[i], reverse=True)
227-
228225
# calculate k: max length of lists in W
229226
K = max([len(_) for _ in W])
230227

@@ -235,13 +232,12 @@ def compute_landscape(self, verbose: bool = False) -> list:
235232
for i in range(self.num_steps):
236233
for k in range(len(W[i])):
237234
L[k][i] = W[i][k]
238-
239235
# check if L is empty
240236
if not L.size:
241237
L = np.array(["empty"])
242238
print("Bad choice of grid, values is empty")
243-
244239
self.values = L
240+
self.max_depth = len(L)
245241
return
246242

247243
def values_to_pairs(self):

0 commit comments

Comments
 (0)