Skip to content

Commit

Permalink
no pre compute function result
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr committed Sep 12, 2024
1 parent 183aac4 commit 0eb0229
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 27 deletions.
1 change: 0 additions & 1 deletion R/read_emigration.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ read_emigration <- function(year = 2010,
}

### output format
df <- dplyr::compute(df)
if (isTRUE(as_data_frame)) { return( dplyr::collect(df) )
} else {
return(df)
Expand Down
1 change: 0 additions & 1 deletion R/read_families.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ read_families <- function(year = 2000,
}

### output format
df <- dplyr::compute(df)
if (isTRUE(as_data_frame)) { return( dplyr::collect(df) )
} else {
return(df)
Expand Down
1 change: 0 additions & 1 deletion R/read_households.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ read_households <- function(year = 2010,
}

### output format
df <- dplyr::compute(df)
if (isTRUE(as_data_frame)) { return( dplyr::collect(df) )
} else {
return(df)
Expand Down
1 change: 0 additions & 1 deletion R/read_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ read_mortality <- function(year = 2010,
}

### output format
df <- dplyr::compute(df)
if (isTRUE(as_data_frame)) { return( dplyr::collect(df) )
} else {
return(df)
Expand Down
1 change: 0 additions & 1 deletion R/read_population.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ read_population <- function(year = 2010,
}

### output format
df <- dplyr::compute(df)
if (isTRUE(as_data_frame)) { return( dplyr::collect(df) )
} else {
return(df)
Expand Down
1 change: 0 additions & 1 deletion R/read_tracts.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ read_tracts <- function(year = 2010,
# }

### output format
df <- dplyr::compute(df)
if (isTRUE(as_data_frame)) { return( dplyr::collect(df) )
} else {
return(df)
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_rafa/test_rafa.R
Original file line number Diff line number Diff line change
Expand Up @@ -571,4 +571,6 @@ By default, this setting utilizes the available disk space on the drive where th
You can adjust this setting, by using (for example) PRAGMA max_temp_directory_size='10GiB'


families
pop

4 changes: 2 additions & 2 deletions tests/testthat/test_labels_households.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ test_that("add_labels_households", {
add_labels = NULL,
columns = c('abbrev_state', 'V1006'),
showProgress = FALSE) |>
filter(abbrev_state == 'RO')
dplyr::filter(abbrev_state == 'RO')

# com labels
test2b <- censobr:::add_labels_households(arrw = test2a,
year=2000,
lang = 'pt') |>
filter(abbrev_state == 'RO')
dplyr::filter(abbrev_state == 'RO')

test2a <- dplyr::collect(test2a)
test2b <- dplyr::collect(test2b)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_read_emigration.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_that("read_emigration reading", {
# (default) arrow table
test1 <- tester()
testthat::expect_true(is(test1, "ArrowObject"))
testthat::expect_true(is(test1, "FileSystemDataset"))
testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test1) >0 )

# data.frame
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_read_families.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ testthat::skip_if_not_installed("arrow")
tester <- function(year = 2000,
columns = NULL,
add_labels = NULL,
merge_households = FALSE,
# merge_households = FALSE,
as_data_frame = FALSE,
showProgress = FALSE,
cache = TRUE) {
read_families(
year,
columns,
add_labels,
merge_households,
# merge_households,
as_data_frame,
showProgress,
cache
Expand All @@ -31,7 +31,7 @@ test_that("read_families read", {
# (default) arrow table
test1 <- tester()
testthat::expect_true(is(test1, "ArrowObject"))
testthat::expect_true(is(test1, "FileSystemDataset"))
testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test1) >0 )

# # data.frame
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test_read_households.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@ test_that("read_households reading", {
# (default) arrow table
test1 <- tester()
testthat::expect_true(is(test1, "ArrowObject"))
testthat::expect_true(is(test1, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test1) >0 )

# year 2000
# (default) arrow table
test2 <- tester(year = 2000)
testthat::expect_true(is(test2, "ArrowObject"))
testthat::expect_true(is(test2, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test2) >0 )

# year 1991
# (default) arrow table
test2 <- tester(year = 1991)
testthat::expect_true(is(test2, "ArrowObject"))
testthat::expect_true(is(test2, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test2) >0 )

# year 1980
# (default) arrow table
test2 <- tester(year = 1980)
testthat::expect_true(is(test2, "ArrowObject"))
testthat::expect_true(is(test2, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test2) >0 )

# year 1970
# (default) arrow table
test2 <- tester(year = 1970)
testthat::expect_true(is(test2, "ArrowObject"))
testthat::expect_true(is(test2, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test2) >0 )
# # data.frame
# test2 <- tester(as_data_frame = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_read_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_that("read_mortality reading", {
# (default) arrow table
test1 <- tester()
testthat::expect_true(is(test1, "ArrowObject"))
testthat::expect_true(is(test1, "FileSystemDataset"))
testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test1) >0 )

# data.frame
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test_read_population.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ testthat::skip_if_not_installed("arrow")
tester <- function(year = 2010,
columns = NULL,
add_labels = NULL,
merge_households = FALSE,
# merge_households = FALSE,
as_data_frame = FALSE,
showProgress = FALSE,
cache = TRUE) {
read_population(
year,
columns,
add_labels,
merge_households,
# merge_households,
as_data_frame,
showProgress,
cache
Expand All @@ -32,7 +32,7 @@ test_that("read_population read", {
# (default) arrow table
test1 <- tester( showProgress = TRUE)
testthat::expect_true(is(test1, "ArrowObject"))
testthat::expect_true(is(test1, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test1) >0 )
rm(test1); gc(TRUE)
gc(TRUE)
Expand All @@ -41,28 +41,28 @@ test_that("read_population read", {
# (default) arrow table
test2 <- tester(year = 2000)
testthat::expect_true(is(test2, "ArrowObject"))
testthat::expect_true(is(test2, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test2) >0 )

# year 1991
# (default) arrow table
test2 <- tester(year = 1991)
testthat::expect_true(is(test2, "ArrowObject"))
testthat::expect_true(is(test2, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test2) >0 )

# year 1980
# (default) arrow table
test2 <- tester(year = 1980)
testthat::expect_true(is(test2, "ArrowObject"))
testthat::expect_true(is(test2, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test2) >0 )

# year 1970
# (default) arrow table
test2 <- tester(year = 1970)
testthat::expect_true(is(test2, "ArrowObject"))
testthat::expect_true(is(test2, "FileSystemDataset"))
# testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test2) >0 )

# # data.frame
Expand All @@ -89,7 +89,7 @@ test_that("read_population read", {




gc()

# check totals -----------------------

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_read_tracts.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test_that("read_tracts", {
# arrow table
test1 <- tester(year = 2010, dataset = 'Basico')
testthat::expect_true(is(test1, "ArrowObject"))
testthat::expect_true(is(test1, "FileSystemDataset"))
testthat::expect_true(is(test1, "Table"))
testthat::expect_true(nrow(test1) >0 )

# data.frame
Expand Down

0 comments on commit 0eb0229

Please sign in to comment.