Skip to content

Commit

Permalink
added regression test, updated NEWS
Browse files Browse the repository at this point in the history
  • Loading branch information
markvanderloo committed Jul 23, 2018
1 parent c5be698 commit 2ea6203
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pkg/NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
version 0.2.0
version 0.2.2
- bugfix: match_restrictions would try and alter the wrong variables in cases where
variable order in the rule set was different from variable order in the data.

version 0.2.1
- Pakcage now imports from 'validate'
- Imported package 'editrules' is now suggested
- New function 'match_constraints' Works with 'validate::validator' objects.
Expand Down
3 changes: 2 additions & 1 deletion pkg/R/match_restrictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ match_restrictions <- function(dat, restrictions
, b = constr$b
, x = x
, neq = sum(L$operators=="==")
, nleq = sum(L$operators=="<="))
, nleq = sum(L$operators=="<=")
, implied_equations=FALSE)

wt <- weight[i, names(constr$x)]
out <- lintools::project(x = constr$x
Expand Down
8 changes: 7 additions & 1 deletion pkg/tests/testthat/test_match_restrictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ test_that("adjusts correctly",{
, 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)

})

Expand Down

0 comments on commit 2ea6203

Please sign in to comment.