-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3187b50
commit cf2df93
Showing
5 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ | |
^\.binder$ | ||
^\.vscode$ | ||
^CRAN-SUBMISSION$ | ||
^ad-hoc-tests$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.quarto/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
format: gfm | ||
--- | ||
|
||
This document tests the new `max-dist` functionality in PR [#48](https://github.com/ITSLeeds/od/pull/48). | ||
|
||
Let's start the test documented in the PR with the installed version of the package. | ||
|
||
```{r} | ||
remotes::install_cran("od") | ||
library(sf) | ||
``` | ||
|
||
# Test 1: 1000 points | ||
|
||
|
||
```{r} | ||
p = pct::get_centroids_ew() | ||
p = p[1:1000,] | ||
system.time(r1 <- od::points_to_od(p)) | ||
head(r1) | ||
nrow(r1) | ||
``` | ||
|
||
Now let's test the new `max-dist` functionality. | ||
|
||
|
||
```{r} | ||
if (!file.exists("DESCRIPTION")) { | ||
setwd("..") | ||
} | ||
devtools::load_all() | ||
system.time(r2 <- points_to_od(p)) | ||
head(r2) | ||
nrow(r2) | ||
``` | ||
|
||
|
||
```{r} | ||
system.time(r3 <- points_to_od(p, max_dist = 1000)) | ||
head(r3) | ||
nrow(r3) | ||
``` | ||
|
||
The benchmark shows that the new `max-dist` functionality is faster than the original implementation for large datasets. | ||
|
||
Let's compare the results. | ||
|
||
|
||
```{r} | ||
waldo::compare(head(r1), head(r2)) | ||
r2_sorted = r2 |> | ||
dplyr::arrange(desc(O), desc(D)) | ||
r1_sorted = r1 |> | ||
dplyr::arrange(desc(O), desc(D)) | ||
waldo::compare(head(r1_sorted), head(r2_sorted)) | ||
``` | ||
|
||
Let's plot the results for the max-dist = 1000 case. | ||
|
||
|
||
```{r} | ||
r3_sf = od::od_to_sf(r3, p) | ||
plot(sf::st_geometry(p), col = "red") | ||
plot(sf::st_geometry(r3_sf), add = TRUE) | ||
``` | ||
|
||
# Test 2: od_coordinates |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.