Skip to content

Commit

Permalink
register all S3 methods
Browse files Browse the repository at this point in the history
* even private ones where the generic is not exported and will not be visible to outside users
  • Loading branch information
jefferis committed Oct 14, 2024
1 parent f3168f3 commit b242f3a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions R/hxsurf.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand All @@ -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), ...)
}
Expand Down
2 changes: 2 additions & 0 deletions R/im3d.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions R/neuron-io-neuroml.R
Original file line number Diff line number Diff line change
Expand Up @@ -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), ...)
}
Expand Down
6 changes: 4 additions & 2 deletions R/potential_synapses.R
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit b242f3a

Please sign in to comment.