Skip to content

Commit

Permalink
Merge pull request #468 from dokato/printneuronlistz
Browse files Browse the repository at this point in the history
[add] print method for neuronlistz
  • Loading branch information
jefferis authored Jun 12, 2021
2 parents 88507a8 + 0bc9ef3 commit a155984
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ S3method(potential_synapses,neuronlist)
S3method(print,dotprops)
S3method(print,neuron)
S3method(print,neuronlist)
S3method(print,neuronlistz)
S3method(prune,default)
S3method(prune,dotprops)
S3method(prune,neuron)
Expand Down
19 changes: 19 additions & 0 deletions R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,22 @@ print.neuronlist <- function(x, ...) {
format(object.size(x), units='auto', standard="SI"),
"]", "\n", sep="")
}

#' @export
print.neuronlistz <- function(x, ...) {
firstclass <- function(x) class(x)[[1]]

cat("'",firstclass(x),"'", " containing ", length(x),
" neurons ",
ifelse(length(x)==1, "object", "objects"), " ", sep=""
)
nc=ncol(as.data.frame(x))
cat("and 'data.frame' with ",nc,' vars [',
format(object.size(x), units='auto', standard="SI")
, ' in RAM].\n', sep="")
f_path=attr(x, "db")
f_size=format(structure(file.info(f_path)$size, class='object_size'),
units='auto',standard="SI")
cat("Loaded on demand from '", normalizePath(f_path), "' [",
f_size, " on disk].\n", sep="")
}
2 changes: 2 additions & 0 deletions tests/testthat/test-neuronlistz.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ test_that("neuronlistz works", {
expect_true(is.neuronlist(nz <- neuronlistz(tf)))
expect_equal(nz[1:5], Cell07PNs[1:5])

expect_output(print(nz), 'Loaded on demand.*on disk')

tf2=tempfile(fileext = '.zip')
on.exit(unlink(tf2), add = T)
skip_if_not_installed('qs')
Expand Down

0 comments on commit a155984

Please sign in to comment.