Skip to content

Commit

Permalink
Fix pl plotting (#55)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
catanzaromj authored Feb 11, 2024
1 parent e1fb188 commit f58729c
Show file tree
Hide file tree
Showing 9 changed files with 308 additions and 147 deletions.
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.11"

python:
version: 3.7
install:
- requirements: docs/requirements.txt
- method: pip
Expand Down
4 changes: 4 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.3.3
- Fix plotting methods of Persistence Landscapes, add doc strings.
- Update to notebooks.

0.3.2
- Update codebase to support python 3.7 - 3.12.
- Change `PersistenceLandscaper` API for sklearn compatibility.
Expand Down
6 changes: 3 additions & 3 deletions docs/notebooks/Classification with persistence images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "persimenv",
"display_name": "Python 3",
"language": "python",
"name": "persimenv"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -375,7 +375,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.8.5"
}
},
"nbformat": 4,
Expand Down
22 changes: 11 additions & 11 deletions docs/notebooks/Differentiation with Persistence Landscapes.ipynb

Large diffs are not rendered by default.

91 changes: 44 additions & 47 deletions docs/notebooks/Persistence Landscapes and Machine Learning.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion persim/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.2"
__version__ = "0.3.3"
8 changes: 2 additions & 6 deletions persim/landscapes/approximate.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def __init__(
self.start = start
self.stop = stop
self.values = values
self.max_depth = len(self.values)
self.num_steps = num_steps
if compute:
self.compute_landscape()
Expand All @@ -178,7 +179,6 @@ def compute_landscape(self, verbose: bool = False) -> list:
if self.values.size:
verboseprint("values was stored, exiting")
return

verboseprint("values was empty, computing values")
# make grid
grid_values, step = np.linspace(
Expand Down Expand Up @@ -214,17 +214,14 @@ def compute_landscape(self, verbose: bool = False) -> list:
j += 1
# j*step: adding points from a line with slope 1
W[ind_in_Wb + j].append(j * step)

j = 0
# j in (b+d/2, d)
for _ in range(mid_pt + 1, ind_in_Wd):
j += 1
W[ind_in_Wd - j].append(j * step)

# sort each list in W
for i in range(len(W)):
W[i] = sorted(W[i], reverse=True)

# calculate k: max length of lists in W
K = max([len(_) for _ in W])

Expand All @@ -235,13 +232,12 @@ def compute_landscape(self, verbose: bool = False) -> list:
for i in range(self.num_steps):
for k in range(len(W[i])):
L[k][i] = W[i][k]

# check if L is empty
if not L.size:
L = np.array(["empty"])
print("Bad choice of grid, values is empty")

self.values = L
self.max_depth = len(L)
return

def values_to_pairs(self):
Expand Down
Loading

0 comments on commit f58729c

Please sign in to comment.