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

Unexpected behaviour in frozen_tour() #104

Open
nspyrison opened this issue Apr 12, 2021 · 2 comments
Open

Unexpected behaviour in frozen_tour() #104

nspyrison opened this issue Apr 12, 2021 · 2 comments

Comments

@nspyrison
Copy link

nspyrison commented Apr 12, 2021

  1. works for some but not all variables
  2. Only seems to check the column norm, not the row (variable norm)
  3. see other comments in the example section, not run
require(tourr)
#> Loading required package: tourr
#> Warning: package 'tourr' was built under R version 4.0.5
?frozen_tour ## Also not the Not run: code and comments in the examples section.

#### Works for some variables but not others. ------
## Example case; expected success
frozen <- matrix(NA, nrow = 4, ncol = 2)
frozen[3, ] <- .5
if(interactive())
  animate_xy(flea[, 1:4], frozen_tour(2, frozen)) 

## Trivial variable change; unexpected error
frozen <- matrix(NA, nrow = 4, ncol = 2)
frozen[1, ] <- .5
animate_xy(flea[, 1:4], frozen_tour(2, frozen))
#> Converting input data to the required matrix format.
#> target_dist - cur_dist: 0 
#> generation:  dist =   1.815423
#> Error in svd(t(Fa) %*% Fz): infinite or missing values in 'x'

#### Check is column norm >1, also need to check row norm? ------
## Norm > 1; expected error
frozen <- matrix(NA, nrow = 4, ncol = 2)
frozen[3, ] <- 1.1 
animate_xy(flea[, 1:4], frozen_tour(2, frozen))
#> Converting input data to the required matrix format.
#> Error: Columns of frozen matrix must have squared norm < 1

## Norm > 1, variable contribution larger than 1; unexpected success
frozen <- matrix(NA, nrow = 4, ncol = 2)
frozen[3, ] <- .9
if(interactive())
  animate_xy(flea[, 1:4], frozen_tour(2, frozen))

## Norm > 1, each row < 1, but col norm > 1; expected error
frozen <- matrix(NA, nrow = 4, ncol = 2)
frozen[c(3, 4), ] <- .9
animate_xy(flea[, 1:4], frozen_tour(2, frozen))
#> Converting input data to the required matrix format.
#> Error: Columns of frozen matrix must have squared norm < 1

Created on 2021-04-12 by the reprex package (v1.0.0)

@dicook
Copy link
Member

dicook commented Apr 29, 2021

@nspyrison try out the code again. I fixed one problem that the initialisation wasn't happening correctly if one of the first variables was frozen.

@nspyrison
Copy link
Author

@dicook, that fixed the first issue! To list the remaining issue and re-hash 2 cases from the example section of ?frozen_tour:

require(tourr) ## SHA1 (272a2f88) from 30/05/2021
#> Loading required package: tourr
#install.packages("ellipsis") ## required newer ver
#install.packages("vctrs") ## required newer ver


print("Case 4 remains unexpected success.")
#> [1] "Case 4 remains unexpected success."
## Norm > 1, variable contribution larger than 1; unexpected success
frozen <- matrix(NA, nrow = 4, ncol = 2)
frozen[3, ] <- .9
if(interactive())
  animate_xy(flea[, 1:4], frozen_tour(2, frozen))


print("Now working, but sometimes has discrete jumps, step size seem much larger than ussual for 2 consecutive frames, seems undesirable.")
#> [1] "Now working, but sometimes has discrete jumps, step size seem much larger than ussual for 2 consecutive frames, seems undesirable."
# Doesn't work - a bug?
frozen <- matrix(NA, nrow = 4, ncol = 2)
frozen[1:2, 1] <- 1 / 4
if(interactive())
  animate_xy(flea[, 1:4], frozen_tour(2, frozen))

print("Less importantly, when norm = 1, error code should suggest use of dependence_tour() to set 1 variable to 1 axis. As pointed out in this example code:")
#> [1] "Less importantly, when norm = 1, error code should suggest use of dependence_tour() to set 1 variable to 1 axis. As pointed out in this example code:"
## Not run: 
# This freezes one entire direction which causes a problem,
# and is caught by error handling.
# If you want to do this it would be best with a dependence
# tour, with one variable set one axis, eg 3rd variable to
# x axis would be indicated from the code below
frozen <- matrix(NA, nrow = 4, ncol = 2)
frozen[3, ] <- c(0, 1)
animate_xy(flea[, 1:4], frozen_tour(2, frozen))
#> Converting input data to the required matrix format.
#> Error: Columns of frozen matrix must have squared norm < 1

Created on 2021-05-30 by the reprex package (v2.0.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants