Skip to content

Commit d97d035

Browse files
committed
use BiocGenerics::data
1 parent f64b557 commit d97d035

4 files changed

Lines changed: 7 additions & 13 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ exportMethods(translation)
115115
importFrom(BiocGenerics,as.data.frame)
116116
importFrom(BiocGenerics,colnames)
117117
importFrom(BiocGenerics,combine)
118+
importFrom(BiocGenerics,data)
118119
importFrom(BiocGenerics,rownames)
119120
importFrom(BiocGenerics,table)
120121
importFrom(BiocGenerics,transform)

R/AllGenerics.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@ setGeneric("instance_key<-", \(x, value) standardGeneric("instance_key<-"))
8383

8484
# uts ----
8585

86-
setGeneric("data", \(...) standardGeneric("data"))
8786
setGeneric("meta", \(x, ...) standardGeneric("meta"))
88-
89-
setGeneric("data<-", \(x, ..., value) standardGeneric("data<-"))
9087
setGeneric("meta<-", \(x, ..., value) standardGeneric("meta<-"))
88+
setGeneric("data<-", \(x, ..., value) standardGeneric("data<-"))
9189

9290
setGeneric("layer", \(x, i, ...) standardGeneric("layer"))
9391
setGeneric("element", \(x, i, ...) standardGeneric("element"))

R/methods.R

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,10 @@ setMethod("[[", c("SpatialData", "character"), \(x, i, ...) attr(x, i))
2727

2828
#' @export
2929
#' @rdname SpatialData
30-
setMethod("data", "ANY", \(...) {
31-
l <- list(...)
32-
x <- l[[1]]
33-
if (!is(x, "SpatialDataElement"))
34-
return(utils::data(...))
35-
if (!is(x, "SpatialDataArray"))
36-
return(x@data)
30+
#' @importFrom BiocGenerics data
31+
setMethod("data", "SpatialDataElement", \(x, k=1, ...) {
32+
if (!is(x, "SpatialDataArray")) return(x@data)
3733
# return list of available scales
38-
k <- if (length(l) == 1) 1 else l[[2]]
3934
if (is.null(k)) return(x@data)
4035
# should be a scalar positive integer
4136
ok <- length(k) == 1 && is.numeric(k) && k > 0 && k == round(k)

man/SpatialData.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)