Skip to content

Commit

Permalink
Merge pull request #11 from zachmayer/master
Browse files Browse the repository at this point in the history
Fixed Travis tests
  • Loading branch information
terrytangyuan committed Aug 11, 2015
2 parents 7c81c0b + e033b5a commit d96d05d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
22 changes: 18 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,33 @@ sudo: required
env:
global:
- CRAN: http://cran.rstudio.com
- RGL_USE_NULL: true

notifications:
email:
on_success: change
on_failure: change

apt_packages:
- freeglut3-dev
- xvfb
- xserver-xorg-core
- xserver-xorg
- xorg
- openbox
- xauth

r_binary_packages:
- plyr
- rARPACK
- rgl

r_github_packages:
- hadley/devtools
- jimhester/covr

before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq r-cran-dev xorg-dev libglu1-mesa-dev

after_success:
- Rscript -e 'library(covr);coveralls()'

after_failure:
- Rscript -e 'devtools::load_all(); devtools::test()'
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Generated by roxygen2 (4.1.1): do not edit by hand

S3method(plot,lfda)
export("%^%")
export(Cols)
export(klfda)
export(kmatrixGauss)
export(lfda)
export(plot.lfda)
export(repmat)
import(grDevices)
import(rARPACK)
Expand Down
5 changes: 3 additions & 2 deletions R/klfda.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ klfda <- function (k, y, r, metric = c('weighted', 'orthonormalized', 'plain'),
)

Z = t(t(Tr) %*% k) # transformed data

return(list("T" = Tr, "Z" = Z))
out <- list("T" = Tr, "Z" = Z)
class(out) <- 'lfda'
return(out)
}
5 changes: 3 additions & 2 deletions R/lfda.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ lfda <- function(x, y, r, metric = c("orthonormalized","plain","weighted"),knn =
)

Z <- t(t(Tr) %*% x) # transformed data

return(list("T" = Tr, "Z" = Z))
out <- list("T" = Tr, "Z" = Z)
class(out) <- 'lfda'
return(out)
}
5 changes: 4 additions & 1 deletion R/lfda_visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Cols <- function(vec){
#'
#' @import rgl
#'
#' @export plot.lfda
#' @method plot lfda
#' @export
#'
#' @seealso See \code{\link{lfda}} and \code{\link{klfda}} for the metric learning method used for this visualization.
#'
Expand Down Expand Up @@ -57,6 +58,8 @@ plot.lfda <- function(x, labels, cleanText=FALSE, ...){
newData <- transformedData
}

#options(rgl.useNULL=TRUE) # deal with rgl in Travis

## Plot 3D Visualization of LFDA Result ##
rgl::text3d(newData[,2],newData[,3], newData[,4], col=Cols(transformedData$Class),
main="3D Visualization of Metric Transformed Data", size=4,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_klfda.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ test_that('klfda visualization works', {
r <- 3
result <- klfda(k,y,r,metric="plain")
options(rgl.useNULL=TRUE) # deal with rgl in Travis
expect_that(plot.lfda(result, iris[,5]), not(throws_error()))
plot(result, iris[,5])
})
2 changes: 1 addition & 1 deletion tests/testthat/test_lfda.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test_that('lfda visualization works', {
r <- 3
result <- lfda(k,y,r,metric="plain")
options(rgl.useNULL=TRUE) # deal with rgl in Travis
expect_that(plot.lfda(result, iris[,5]), not(throws_error()))
plot(result, iris[,5])
})


0 comments on commit d96d05d

Please sign in to comment.