Skip to content

Commit

Permalink
alternate fix for CRAN check
Browse files Browse the repository at this point in the history
  • Loading branch information
felixcheung committed Aug 21, 2016
1 parent 58b7677 commit 4d0edb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion R/pkg/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Imports from base R
# Do not include stats:: "rpois", "runif" - causes error at runtime
importFrom("methods", "setGeneric", "setMethod", "setOldClass")
importFrom("methods", "is", "new", "signature", "show")
importFrom("stats", "gaussian", "rpois", "runif", "setNames")
importFrom("stats", "gaussian", "setNames")
importFrom("utils", "download.file", "packageVersion", "untar")

# Disable native libraries till we figure out how to package it
Expand Down
10 changes: 5 additions & 5 deletions R/pkg/R/RDD.R
Original file line number Diff line number Diff line change
Expand Up @@ -887,17 +887,17 @@ setMethod("sampleRDD",

# Discards some random values to ensure each partition has a
# different random seed.
runif(partIndex)
stats::runif(partIndex)

for (elem in part) {
if (withReplacement) {
count <- rpois(1, fraction)
count <- stats::rpois(1, fraction)
if (count > 0) {
res[ (len + 1) : (len + count) ] <- rep(list(elem), count)
len <- len + count
}
} else {
if (runif(1) < fraction) {
if (stats::runif(1) < fraction) {
len <- len + 1
res[[len]] <- elem
}
Expand Down Expand Up @@ -965,15 +965,15 @@ setMethod("takeSample", signature(x = "RDD", withReplacement = "logical",

set.seed(seed)
samples <- collectRDD(sampleRDD(x, withReplacement, fraction,
as.integer(ceiling(runif(1,
as.integer(ceiling(stats::runif(1,
-MAXINT,
MAXINT)))))
# If the first sample didn't turn out large enough, keep trying to
# take samples; this shouldn't happen often because we use a big
# multiplier for thei initial size
while (length(samples) < total)
samples <- collectRDD(sampleRDD(x, withReplacement, fraction,
as.integer(ceiling(runif(1,
as.integer(ceiling(stats::runif(1,
-MAXINT,
MAXINT)))))

Expand Down
6 changes: 3 additions & 3 deletions R/pkg/R/pairRDD.R
Original file line number Diff line number Diff line change
Expand Up @@ -917,19 +917,19 @@ setMethod("sampleByKey",
len <- 0

# mixing because the initial seeds are close to each other
runif(10)
stats::runif(10)

for (elem in part) {
if (elem[[1]] %in% names(fractions)) {
frac <- as.numeric(fractions[which(elem[[1]] == names(fractions))])
if (withReplacement) {
count <- rpois(1, frac)
count <- stats::rpois(1, frac)
if (count > 0) {
res[ (len + 1) : (len + count) ] <- rep(list(elem), count)
len <- len + count
}
} else {
if (runif(1) < frac) {
if (stats::runif(1) < frac) {
len <- len + 1
res[[len]] <- elem
}
Expand Down

0 comments on commit 4d0edb5

Please sign in to comment.