tdaverse / ggtda

ggplot2 extension to visualize persistent homology
https://tdaverse.github.io/ggtda/
GNU General Public License v3.0
21 stars 6 forks source link

Warnings with stat_vietoris2 and stat_cech2 #8

Closed rrrlw closed 4 years ago

rrrlw commented 4 years ago

The following code creates an equilateral triangle and uses stat_vietoris* and stat_cech* to visualize the faces of the resulting simplicial complex at a diameter of 1, but returns warnings that the computation failed in stat_vietoris2 and stat_cech2 due to argument length of 0. Any thoughts on what's going on, @corybrunson? (using this example in a vignette under cran-prep branch of this repo)

library("ggplot2")
library("ggtda")

# create equilateral triangle point cloud
eq_tri <- data.frame(x = c(0, 1, 0.5),
                     y = c(0, 0, sqrt(3)/2))

# VR complex
ggplot(eq_tri, aes(x = x, y = y)) +
  coord_fixed() +
  stat_vietoris2(diameter = 2, fill = "darkgoldenrod", alpha = 0.1) +
  stat_vietoris1(diameter = 2, alpha = 0.25) +
  stat_vietoris0() +
  theme_minimal()

# Čech complex
ggplot(eq_tri, aes(x = x, y = y)) +
  coord_fixed() +
  stat_cech2(diameter = 2) +
  stat_cech1(diameter = 2, alpha = 0.25) +
  stat_cech0() +
  theme_minimal()
corybrunson commented 4 years ago

This is resolved in 03d5ac04bd01f9383e0ce274d9cc5227e924e78f. The problem with a single simplex was due to having omitted , drop = FALSE from a data frame subsetting operation. There was also a problem with the case that no 2-simplices were created, due to my use of 1:n rather than seq_int(n). Good catches again!