Skip to content

Commit

Permalink
Excised rounding.default and generic rounding() to spatstat.univar
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed Jun 12, 2024
1 parent d02a68b commit a4a243f
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 124 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: spatstat.geom
Version: 3.2-9.018
Date: 2024-06-07
Version: 3.2-9.019
Date: 2024-06-12
Title: Geometrical Functionality of the 'spatstat' Family
Authors@R: c(person("Adrian", "Baddeley",
role = c("aut", "cre", "cph"),
Expand All @@ -24,7 +24,7 @@ Authors@R: c(person("Adrian", "Baddeley",
person("Dominic", "Schuhmacher", role = "ctb"),
person("Rasmus", "Waagepetersen", role = "ctb"))
Maintainer: Adrian Baddeley <Adrian.Baddeley@curtin.edu.au>
Depends: R (>= 3.5.0), spatstat.data (>= 3.0), spatstat.univar (>= 2.0-3.003), stats, graphics, grDevices, utils, methods
Depends: R (>= 3.5.0), spatstat.data (>= 3.0), spatstat.univar (>= 2.0-3.005), stats, graphics, grDevices, utils, methods
Imports: spatstat.utils (>= 3.0-4), deldir (>= 1.0-2), polyclip (>= 1.10-0)
Suggests: spatstat.random, spatstat.explore, spatstat.model, spatstat.linnet, spatial, fftwtools (>= 0.9-8), spatstat (>= 3.0)
Description: Defines spatial data types and supports geometrical operations
Expand Down
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,6 @@ export("rotate.psp")
export("rotate.tess")
export("rotxy")
export("rotxypolygon")
export("rounding")
export("rounding.default")
export("rounding.pp3")
export("rounding.ppp")
export("rounding.ppx")
Expand Down Expand Up @@ -1621,7 +1619,6 @@ S3method("rotate", "infline")
S3method("rotate", "ppp")
S3method("rotate", "psp")
S3method("rotate", "tess")
S3method("rounding", "default")
S3method("rounding", "pp3")
S3method("rounding", "ppp")
S3method("rounding", "ppx")
Expand Down
8 changes: 6 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHANGES IN spatstat.geom VERSION 3.2-9.018
CHANGES IN spatstat.geom VERSION 3.2-9.019

OVERVIEW

Expand Down Expand Up @@ -76,7 +76,11 @@ DELETED FUNCTIONS
o quantilefun, quantilefun.ewcdf
The generic 'quantilefun' and the method 'quantile.ewcdf'
have been moved to the new package 'spatstat.univar'.


o rounding, rounding.default
The generic 'rounding' and the method 'rounding.default'
have been moved to the new package 'spatstat.univar'.

o transformquantiles
This function has been moved to the new package 'spatstat.univar'.

Expand Down
6 changes: 3 additions & 3 deletions R/randombasic.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' rsyst() systematic random (randomly-displaced grid)
#' rjitter() random perturbation
#'
#' $Revision: 1.16 $ $Date: 2023/01/14 08:19:51 $
#' $Revision: 1.17 $ $Date: 2024/06/09 00:11:04 $


simulationresult <- function(resultlist, nsim=length(resultlist), drop=TRUE, NameBase="Simulation") {
Expand Down Expand Up @@ -127,7 +127,7 @@ rjitter.ppp <- function(X, radius, retry=TRUE, giveup=10000, trim=FALSE, ...,
} else {
## either one radius, or a vector of radii
check.nvector(radius, nX, oneok=TRUE, vname="radius")
check.finite(radius)
check.finite(radius, xname="radius")
if(min(radius) < 0) {
warning("Negative values of jitter radius were set to zero")
radius <- pmax(0, radius)
Expand Down Expand Up @@ -207,7 +207,7 @@ rexplode.ppp <- function(X, radius, ..., nsim=1, drop=TRUE) {
} else {
## either one radius, or a vector of radii
check.nvector(radius, nX, oneok=TRUE, vname="radius")
check.finite(radius)
check.finite(radius, xname="radius")
if(min(radius) < 0) {
warning("Negative values of jitter radius were set to zero")
radius <- pmax(0, radius)
Expand Down
30 changes: 1 addition & 29 deletions R/round.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,14 @@
#
# discretisation of coordinates
#
# $Revision: 1.6 $ $Date: 2019/02/20 03:34:50 $
# $Revision: 1.7 $ $Date: 2024/06/12 06:23:53 $

round.ppp <- round.pp3 <- round.ppx <- function(x, digits=0, ...) {
coords(x) <- round(as.matrix(coords(x)), digits=digits, ...)
return(x)
}

rounding <- function(x) {
UseMethod("rounding")
}

rounding.ppp <- rounding.pp3 <- rounding.ppx <- function(x) {
rounding(as.matrix(coords(x)))
}

rounding.default <- function(x) {
# works for numeric, complex, matrix etc
if(all(x == 0))
return(NULL)
if(isTRUE(all.equal(x, round(x)))) {
# integers: go up
k <- 0
smallk <- -log10(.Machine$double.xmax)
repeat {
if(k < smallk || !isTRUE(all.equal(x, round(x, k-1))))
return(k)
k <- k-1
}
} else {
# not integers: go down
k <- 1
bigk <- -log10(.Machine$double.eps)
repeat {
if(k > bigk || isTRUE(all.equal(x, round(x, k))))
return(k)
k <- k+1
}
}
}
2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
"2023-10-20" "3.2-7" 451 1203 0 35983 15822
"2024-01-26" "3.2-8" 452 1204 0 36234 15822
"2024-02-28" "3.2-9" 452 1209 0 36325 15824
"2024-06-07" "3.2-9.018" 443 1188 0 35718 15596
"2024-06-12" "3.2-9.019" 443 1186 0 35690 15596
83 changes: 0 additions & 83 deletions man/rounding.Rd

This file was deleted.

70 changes: 70 additions & 0 deletions man/rounding.ppp.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
\name{rounding.ppp}
\alias{rounding.ppp}
\alias{rounding.pp3}
\alias{rounding.ppx}
\title{
Detect Numerical Rounding
}
\description{
Given a numeric vector, or an object containing numeric spatial
coordinates, determine whether the values have been rounded
to a certain number of decimal places.
}
\usage{
\method{rounding}{ppp}(x)

\method{rounding}{pp3}(x)

\method{rounding}{ppx}(x)
}
\arguments{
\item{x}{
A point pattern (object of class \code{ppp}, \code{pp3} or \code{ppx}).
}
}
\details{
The functions documented here are methods for the generic
\code{\link[spatstat.univar]{rounding}}.
They determine whether the coordinates of a spatial object
have been rounded to a certain number of decimal places.
\itemize{
\item
If the coordinates of the points in \code{x} are not all integers, then
\code{rounding(x)} returns the smallest number of digits \code{d}
after the decimal point
such that \code{\link[base]{round}(coords(x), digits=d)} is identical to
\code{coords(x)}.
For example if \code{rounding(x) = 2} then the coordinates of the
points in \code{x} appear to have been rounded to 2 decimal places,
and are multiples of 0.01.
\item
If all the coordinates of the points in \code{x} are integers, then
\code{rounding(x)} returns \code{-d}, where
\code{d} is the smallest number of digits \emph{before} the decimal point
such that \code{\link[base]{round}(coords(x), digits=-d)} is identical to
\code{coords(x)}.
For example if \code{rounding(x) = -3} then the coordinates of all
points in \code{x} are multiples of 1000.
If \code{rounding(x) = 0} then the entries of \code{x} are integers
but not multiples of 10.
\item
If all coordinates of points in \code{x} are equal to 0,
a value of 0 is returned.
}
}
\value{
An integer.
}
\author{
\adrian
and \rolf
}
\seealso{
\code{\link{round.ppp}},
\code{\link[spatstat.univar]{rounding}}
}
\examples{
rounding(cells)
}
\keyword{spatial}
\keyword{math}

0 comments on commit a4a243f

Please sign in to comment.