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

Updated for #394 #396

Merged
merged 8 commits into from
Jun 20, 2019
Merged
4 changes: 4 additions & 0 deletions R/neuron-io.R
Expand Up @@ -645,6 +645,10 @@ write.neuron<-function(n, file=NULL, dir=NULL, format=NULL, ext=NULL,
}
}
if(is.null(file)){
#Check if the col name of InputFileName exists first..
if (!"InputFileName" %in% names(n)){
stop("No file specified and neuron does not have an InputFileName")
}
# no file was specified - use the one embedded in neuron
file=basename(n$InputFileName)
if(is.null(file))
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-neuron-io.R
Expand Up @@ -843,6 +843,15 @@ test_that("we can update an existing neuronlist",{

context("neurons writing")

test_that("neuron write without filename",{
y=Cell07PNs[[1]]
td=tempfile()
on.exit(unlink(td,recursive=TRUE))
if ("InputFileName" %in% names(y)){y["InputFileName"] <- NULL}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y$InputFileName is the same as y[["InputFileName"]] which is probably what you want.

expect_error(write.neuron(y, dir=td, MakeDir = F),
'No file specified and neuron does not have an InputFileName')
})

test_that("we can write neuron/dotprops to rds file",{
x=kcs20[[1]]
td=tempfile()
Expand Down