Skip to content

Commit

Permalink
test lazy = FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
agila5 committed Aug 23, 2021
1 parent 160c6e8 commit 5d0336d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ read_accidents = function(year = NULL,
silent = FALSE) {
# Set the local edition for readr.
# See https://github.com/ropensci/stats19/issues/205
if (.Platform$OS.type == "windows" && utils::packageVersion("readr") >= "2.0.0") {
readr::local_edition(1)
}
# if (.Platform$OS.type == "windows" && utils::packageVersion("readr") >= "2.0.0") {
# readr::local_edition(1)
# }

path = check_input_file(
filename = filename,
Expand All @@ -56,7 +56,8 @@ read_accidents = function(year = NULL,
Time = readr::col_character(),
`Local_Authority_(Highway)` = readr::col_character(),
LSOA_of_Accident_Location = readr::col_character()
)
),
lazy = FALSE

This comment has been minimized.

Copy link
@Robinlovelace

Robinlovelace Aug 24, 2021

Member

Did the test work? Could be useful with reference to tidyverse/readr#1266, will be worth thinking about +s and -s of different options but lazy=FALSE sounds less invasive and more consistent between OSs.

This comment has been minimized.

Copy link
@agila5

agila5 Aug 24, 2021

Author Collaborator

Hi @Robinlovelace! Sorry, I forgot to add more details here. Anyway, I tested the current implementation (i.e. if (...) {local_edition(1)})) and the lazy = FALSE approach and they are more or less identical. Anyway, I think it should be tested a little bit more since I don't have a non-windows laptop and I run those tests on a VM. I will create a script in a few minutes.

This comment has been minimized.

Copy link
@Robinlovelace

Robinlovelace Aug 24, 2021

Member

Great, we could also ask readr devs to review the PR, I guess they will approve , seems sensible approach to me. Many thanks.

)
})

Expand Down Expand Up @@ -171,21 +172,21 @@ check_input_file = function(filename = NULL,
read_ve_ca = function(path) {
# Set the local edition for readr.
# See https://github.com/ropensci/stats19/issues/205
if (.Platform$OS.type == "windows" && utils::packageVersion("readr") >= "2.0.0") {
readr::local_edition(1)
}
# if (.Platform$OS.type == "windows" && utils::packageVersion("readr") >= "2.0.0") {
# readr::local_edition(1)
# }

h = utils::read.csv(path, nrows = 1)
if(grepl("Accident_Index", names(h)[1])) {
readr::read_csv(path, col_types = readr::cols(
.default = readr::col_integer(),
Accident_Index = readr::col_character()
))
), lazy = FALSE)
} else {
x = readr::read_csv(path, col_types = readr::cols(
.default = readr::col_integer(),
Acc_Index = readr::col_character()
))
), lazy = FALSE)
names(x)[names(x) == "Acc_Index"] = "Accident_Index"
x
}
Expand Down

0 comments on commit 5d0336d

Please sign in to comment.