From b242f3a9e59113b9f1329af553d80a8e0c133b4e Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Mon, 14 Oct 2024 14:16:37 +0100 Subject: [PATCH] register all S3 methods * even private ones where the generic is not exported and will not be visible to outside users --- NAMESPACE | 10 ++++++++++ R/hxsurf.R | 4 ++++ R/im3d.R | 2 ++ R/neuron-io-neuroml.R | 2 ++ R/potential_synapses.R | 6 ++++-- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 9d3825b9..bd32d4cf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,8 @@ S3method("[[",neuronlistz) S3method("[[<-",neuronlistfh) S3method("boundingbox<-",default) S3method("data.frame<-",neuronlist) +S3method("materials<-",default) +S3method("materials<-",hxsurf) S3method("xyzmatrix<-",character) S3method("xyzmatrix<-",default) S3method("xyzmatrix<-",dotprops) @@ -29,6 +31,8 @@ S3method(Ops,dotprops) S3method(Ops,hxsurf) S3method(Ops,mesh3d) S3method(Ops,neuron) +S3method(PotentialSynapses,default) +S3method(PotentialSynapses,dotprops) S3method(all,equal.dotprops) S3method(all,equal.im3d) S3method(all,equal.neuron) @@ -47,6 +51,7 @@ S3method(as.mesh3d,hxsurf) S3method(as.neuron,data.frame) S3method(as.neuron,default) S3method(as.neuron,igraph) +S3method(as.neuron,morphml_cell) S3method(as.neuron,neuron) S3method(as.neuron,ngraph) S3method(as.neuronlist,default) @@ -55,6 +60,7 @@ S3method(as.neuronlist,neuronlistz) S3method(as.neuronlistfh,neuronlist) S3method(as.ngraph,data.frame) S3method(as.ngraph,igraph) +S3method(as.ngraph,morphml_cell) S3method(as.ngraph,neuron) S3method(as.ngraph,ngraph) S3method(as.seglist,default) @@ -76,6 +82,10 @@ S3method(cmtk.targetvolume,character) S3method(cmtk.targetvolume,default) S3method(cmtk.targetvolume,im3d) S3method(cmtk.targetvolume,list) +S3method(contains_points,ashape3d) +S3method(contains_points,boundingbox) +S3method(contains_points,hxsurf) +S3method(contains_points,mesh3d) S3method(coord2ind,default) S3method(dim,im3d) S3method(dimnames,neuronlist) diff --git a/R/hxsurf.R b/R/hxsurf.R index 1e866628..4e812bd6 100644 --- a/R/hxsurf.R +++ b/R/hxsurf.R @@ -738,12 +738,14 @@ pointsinside.default<-function(x, surf, ..., rval=c('logical','distance', contains_points <- function(obj, points, ...) UseMethod("contains_points") +#' @export contains_points.boundingbox <- function(obj, points, ...) { xyz=xyzmatrix(points) xyz[,1] >= obj[1,1] & xyz[,2] >= obj[1,2] & xyz[,3] >= obj[1,3] & xyz[,1] <= obj[2,1] & xyz[,2] <= obj[2,2] & xyz[,3] <= obj[2,3] } +#' @export contains_points.mesh3d <- function(obj, points, ...) { xyz=xyzmatrix(points) inbb=contains_points(boundingbox(obj), xyz, ...) @@ -754,8 +756,10 @@ contains_points.mesh3d <- function(obj, points, ...) { res } +#' @export contains_points.hxsurf<-contains_points.mesh3d +#' @export contains_points.ashape3d<-function(obj, points, ...) { alphashape3d::inashape3d(obj, points=xyzmatrix(points), ...) } diff --git a/R/im3d.R b/R/im3d.R index c8300042..caa9524b 100644 --- a/R/im3d.R +++ b/R/im3d.R @@ -1236,10 +1236,12 @@ materials.hxsurf<-function(x, ...) { `materials<-`<-function(x, value) UseMethod("materials<-") +#' @export `materials<-.hxsurf`<-function(x, value) { stop("materials<-.hxsurf is not implemented") } +#' @export `materials<-.default`<-function(x, value) { if(!is.data.frame(value)) stop("materials<- expects a data.frame") diff --git a/R/neuron-io-neuroml.R b/R/neuron-io-neuroml.R index db9cc675..35a8ce83 100644 --- a/R/neuron-io-neuroml.R +++ b/R/neuron-io-neuroml.R @@ -208,8 +208,10 @@ as.data.frame.morphml_cell<-function(x, ...){ structure(r[in_names], .Names=out_names) } +#' @export as.neuron.morphml_cell<-function(x, ...) as.neuron(as.data.frame(x, ...)) +#' @export as.ngraph.morphml_cell<-function(x, ...) { as.ngraph(as.data.frame(x), ...) } diff --git a/R/potential_synapses.R b/R/potential_synapses.R index 7343d256..052b9915 100644 --- a/R/potential_synapses.R +++ b/R/potential_synapses.R @@ -94,7 +94,8 @@ potential_synapses.dotprops<-function(a, b, s, sigma=s, seglength=1, bounds=NULL PotentialSynapses <- function(a, b, s, sigma, ...) UseMethod("PotentialSynapses") -PotentialSynapses.default <- function(a, b, s=2, sigma=2) { +#' @export +PotentialSynapses.default <- function(a, b, s=2, sigma=2, ...) { #Compare for matrices of input data rather than neurons # short circuit if there are no points to check in one list or other! @@ -144,7 +145,8 @@ PotentialSynapses.default <- function(a, b, s=2, sigma=2) { return(rval) } -PotentialSynapses.dotprops <- function(a, b, s, sigma, seglength) { +#' @export +PotentialSynapses.dotprops <- function(a, b, s, sigma, seglength, ...) { # short circuit if there are no points to check in one list or other! if(nrow(a$points) * nrow(b$points) == 0) return(0)