Skip to content

Commit

Permalink
version 0.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
markvanderloo authored and cran-robot committed May 24, 2022
1 parent 0db05e3 commit 268b95b
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 83 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Expand Up @@ -11,15 +11,15 @@ Description: Minimally adjust the values of numerical records in a data.frame, s
The core algorithms have recently been moved to the 'lintools' package,
refer to 'lintools' for a more basic interface and access to a version
of the algorithm that works with sparse matrices.
Version: 0.2.5
Version: 0.2.6
Depends: R (>= 2.13.0)
Imports: graphics, stats, validate, lintools
Suggests: editrules, tinytest
URL: https://github.com/markvanderloo/rspa
BugReports: https://github.com/markvanderloo/rspa/issues
RoxygenNote: 6.1.1
RoxygenNote: 7.2.0
Encoding: UTF-8
NeedsCompilation: yes
Packaged: 2019-06-19 15:03:09 UTC; mark
Packaged: 2022-05-24 09:27:23 UTC; mark
Repository: CRAN
Date/Publication: 2019-06-19 15:40:03 UTC
Date/Publication: 2022-05-24 10:00:02 UTC
26 changes: 13 additions & 13 deletions MD5
@@ -1,30 +1,30 @@
526898faec36d8add5b883c27f58da07 *DESCRIPTION
930d153518aeb59402b598f6559968f6 *DESCRIPTION
d7cd8491d6c2fe1f7c1c988045396313 *NAMESPACE
82b15ce7e77a21985c9726afadc094ea *NEWS
52b07203e251ccee75cd9cc3bdb1b9a6 *NEWS
ae35678160ec193a5e37daee1d1e0d89 *R/adjust.R
4f740070aa6a2782b18526270d9ecbe2 *R/adjustRecords.R
a1007a3e1930e5a81d3d8be4ece11f0c *R/adjusted.R
6d0982bc4b3b10bc7ff27fa122b501ea *R/adjustedRecords.R
20fcb8a300d4597967ebc193c10500ea *R/match_restrictions.R
6efece1a6095cb29824e6b2e08b8729e *R/rspa.R
d49258dca87018c9d359e401a02ce121 *R/match_restrictions.R
0121e1603d8fb609ccd3e48fcfd0f3b3 *R/rspa.R
4d69c2813e2879fcb4f489820ee677c5 *R/sparseConstraints.R
50c964a7ba218f3b4f747be9125035c8 *R/utils.R
4501cc21e34a943efcfe5277410facd3 *inst/CITATION
7e938fa4042097b15937a55eedf47189 *inst/tinytest/test_adjust.R
64c7990a58bd8aa64d18426f7d9b8e9c *inst/tinytest/test_adjustRecords.R
7dbeb7783c1706470868020b45dc4c6c *inst/tinytest/test_match_restrictions.R
0ec10c80e2e0745a967eff047eb61960 *inst/tinytest/test_match_restrictions.R
6879fe3be582aa2648a2027ba24a9a86 *inst/tinytest/test_sparseConstraints.R
b9523cc06c8876ebb77f67fcac29a950 *inst/tinytest/test_utils.R
df72ec142a5349c718d9e81c856374c7 *man/adjust.Rd
f4076dd6fddf9bbe1739883f1e378a53 *man/adjustRecords.Rd
0d31bffa149079d6ebd43a0b426c3d7d *man/adjust.Rd
e93e159ac1cab40bd3ef3a85a6e05a12 *man/adjustRecords.Rd
b74e941bae5c2756b279d1af32b2bde3 *man/adjusted.Rd
ccac36c8bebe8dce6de2d4e361bb0b40 *man/adjustedRecords.Rd
95d6450afd97865e882911b40524e269 *man/match_restrictions.Rd
369d9decd855c5bd8e92309998d034af *man/remove_tag.Rd
c40df0170c86d1c77ee17393b652cafd *man/rspa-package.Rd
88f91060edb81321b636756c957a0af2 *man/sparseConstraints.Rd
1e8150927a2255ca021776707c81b827 *man/tag_missing.Rd
ee67dbe5bff0e6b2a26d342587116cf7 *man/tagged_values.Rd
a75e0c5fa06e5873c997b2562e4ec872 *man/match_restrictions.Rd
7059ebdd630cbd5c9226bf36deabc687 *man/remove_tag.Rd
ddba4fde8966be873f6f38e594b90ded *man/rspa-package.Rd
5cad127b20c5d0a6400937c04f5de8ec *man/sparseConstraints.Rd
3e3058cb5887082906b2e26324e9ff62 *man/tag_missing.Rd
5de84e9a45155645d9c3ec0810174eff *man/tagged_values.Rd
4a385936366ecc111dd31f8c226312f2 *src/R_all_finite.c
1500f94e181af988688b0b251e961546 *src/R_dc_spa.c
b559b4a15560cf517738d19348db6290 *src/R_register_native.c
Expand Down
5 changes: 5 additions & 0 deletions NEWS
@@ -1,3 +1,8 @@
version 0.2.6
- 'match_restrictions' now warns in the case of strict inequalities.
- Fix: warning message on non convergence did not match the reason.


version 0.2.5
- Documentation format update by CRAN request.

Expand Down
12 changes: 10 additions & 2 deletions R/match_restrictions.R
Expand Up @@ -57,6 +57,15 @@ match_restrictions <- function(dat, restrictions

# Get linear restrictions, sort in normalized order.
L <- restrictions$linear_coefficients(normalize=TRUE)
strict_ineqs <- L$operators %in% c("<",">")
if (any(strict_ineqs)){
nm <- paste(names(restrictions)[strict_ineqs], collapse=", ")

warnf("Some restrictions are strict inequalities of the form
'a < b' or 'a > b'. These will be treated as 'a <= b' or 'a >= b'
Strict inequalities: %s",nm)
}

i <- order(L$operators, decreasing = TRUE)
L$A <- L$A[i,,drop=FALSE]
L$b <- L$b[i,,drop=FALSE]
Expand Down Expand Up @@ -110,8 +119,7 @@ match_restrictions <- function(dat, restrictions


CONV_MSG <- c(
""
, "could not allocate enough memory"
"could not allocate enough memory"
, "divergence detected (set of restrictions may be contradictory)"
, "maximum number of iterations reached"
)
Expand Down
7 changes: 5 additions & 2 deletions R/rspa.R
@@ -1,13 +1,16 @@
#' A package for minimal vector adjustment.
#'
#' @section Overview:
#'
#' @description
#'
#' Given a vector \eqn{\boldsymbol{x}^0}, and a set linear restrictions of the
#' form \eqn{\boldsymbol{a}_i\cdot\boldsymbol{x}_i=b_i} and/or
#' \eqn{\boldsymbol{a}_i\cdot\boldsymbol{x}_i\leq b_i} with \eqn{i=1,2,\ldots,m}.
#' This package finds the nearest vector to \eqn{\boldsymbol{x}^0}
#' (in the (weighted) euclidean sense) that satisfies all restrictions.
#'
#'
#' @section Details:
#'
#' Much of this package's functionality, including algorithms for working
#' with large, sparse problems has been moved to the \code{lintools} package.
#' This package will serve as a front-end for application of the succsessive
Expand Down
71 changes: 37 additions & 34 deletions inst/tinytest/test_match_restrictions.R
@@ -1,47 +1,50 @@

## match_restrictions
# adjusts correctly
library(validate)
v <- validator(x + y == 1, x > 0, y >= 0)
dat <- data.frame(x=1,y=2)
expect_equal( match_restrictions(dat,v)
, data.frame(x=0,y=1)
, tolerance=0.01
)

# extra, unrelated variable
dat <- data.frame(x=1,y=2,z=0)
expect_equal( match_restrictions(dat,v)
, data.frame(x=0,y=1,z=0)
, tolerance=0.01
)

# order of variables in data different from order of
# variables in validator.
dat <- data.frame(y=2,x=0.2)
v <- validator(x+y==1,x>=0)
expect_equal(match_restrictions(dat,v)
, data.frame(y=1, x=0), tolerance=0.01)

library(validate)
v <- validator(x + y == 1, x > 0, y >= 0)
dat <- data.frame(x=1,y=2)
expect_equal( suppressWarnings( match_restrictions(dat,v) )
, data.frame(x=0,y=1)
, tolerance=0.01
)

expect_warning(match_restrictions(dat,v))

# extra, unrelated variable
dat <- data.frame(x=1,y=2,z=0)
expect_equal( suppressWarnings(match_restrictions(dat,v))
, data.frame(x=0,y=1,z=0)
, tolerance=0.01
)

# order of variables in data different from order of
# variables in validator.
dat <- data.frame(y=2,x=0.2)
v <- validator(x+y==1,x>=0)
expect_equal(match_restrictions(dat,v)
, data.frame(y=1, x=0), tolerance=0.01)



## tagging

## tagging works
w <- women
w[1,1] <- NA
w <- tag_missing(w)
expect_identical(tagged_values(w),is.na(w))
w <- women
w[1,1] <- NA
w <- tag_missing(w)
expect_identical(tagged_values(w),is.na(w))

## tags are picked up
d <- data.frame(x=NA,y=0.5)
d <- tag_missing(d)
d$x <- 1
v <- validator(x + y == 1, x>0,y>0)
expect_equivalent(
match_restrictions(d,v)
, data.frame(x=0.5,y=0.5)
)
d <- data.frame(x=NA,y=0.5)
d <- tag_missing(d)
d$x <- 1
v <- validator(x + y == 1, x>0,y>0)
expect_equivalent(
suppressWarnings(match_restrictions(d,v))
, data.frame(x=0.5,y=0.5)
)




22 changes: 14 additions & 8 deletions man/adjust.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions man/adjustRecords.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions man/match_restrictions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/remove_tag.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions man/rspa-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions man/sparseConstraints.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/tag_missing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/tagged_values.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 268b95b

Please sign in to comment.