tdaverse/ggtda

Warnings with stat_vietoris2 and stat_cech2

Closed this issue · 1 comments

rrrlw commented

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()

This is resolved in 03d5ac0. 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!