Skip to content

Commit dfde37a

Browse files
committed
fix tests
1 parent 75546e4 commit dfde37a

File tree

3 files changed

+107
-84
lines changed

3 files changed

+107
-84
lines changed

cran-comments.md

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,4 @@
1-
## Test environments
1+
── R CMD check results ───────────────────────────────────────────────────────────────── accessibility 1.5.0 ────
2+
Duration: 2m 15.7s
23

3-
- Local Ubuntu 20.04 installation (R 4.3.2)
4-
- GitHub Actions:
5-
- Windows (release, oldrel)
6-
- MacOS (release, oldrel)
7-
- Ubuntu 20.04 (devel, release, oldrel)
8-
- r-hub:
9-
- Windows Server 2022, R-devel, 64 bit
10-
- win-builder (devel, release, oldrel)
11-
12-
## R CMD check results
13-
14-
In most platforms we got this result:
15-
16-
0 errors | 0 warnings | 1 note
17-
18-
Possibly misspelled words in DESCRIPTION:
19-
FGT (22:45)
20-
Palma (21:49)
21-
Theil (22:23)
22-
23-
The words flagged as misspelled are spelled correctly and represent either
24-
acronyms or names widely known by the target audience of the package.
25-
Therefore, we believe that there is no need to change their spelling in the
26-
description.
27-
28-
However, when using win-builder we algo got the following note:
29-
30-
Found the following (possibly) invalid URLs:
31-
URL: https://doi.org/10.1068/b29120
32-
From: inst/doc/accessibility.html
33-
Status: 403
34-
Message: Forbidden
35-
URL: https://doi.org/10.2307/1913475
36-
From: inst/doc/inequality_and_poverty.html
37-
Status: 403
38-
Message: Forbidden
39-
40-
We believe this note is a false positive, since we haven't had any problems
41-
accessing the mentioned URLs.
4+
0 errors ✔ | 0 warnings ✔ | 0 notes ✔

man/accessibility.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-constrained-essentials.R

Lines changed: 102 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,51 @@ test_that("total-constrained: preserves totals on supply/demand sides", {
3030
lu <- make_lu_large()
3131

3232
# Supply-side output (returns accessible opportunities)
33-
det_supply <- constrained_accessibility("total", tm, lu,
34-
travel_cost = "travel_time", decay_function = exp_decay_01,
35-
demand = NULL, supply = "jobs",
36-
detailed_results = TRUE, active = TRUE
33+
det_supply <- constrained_accessibility(
34+
constraint = "total",
35+
travel_matrix = tm,
36+
land_use_data = lu,
37+
travel_cost = "travel_time",
38+
decay_function = exp_decay_01,
39+
demand = NULL,
40+
supply = "jobs",
41+
detailed_results = TRUE,
42+
active = TRUE
3743
)
38-
agg_supply <- constrained_accessibility("total", tm, lu,
39-
travel_cost = "travel_time", decay_function = exp_decay_01,
40-
demand = NULL, supply = "jobs",
41-
detailed_results = FALSE, active = TRUE
44+
agg_supply <- constrained_accessibility(
45+
constraint = "total",
46+
travel_matrix = tm,
47+
land_use_data = lu,
48+
travel_cost = "travel_time",
49+
decay_function = exp_decay_01,
50+
demand = NULL,
51+
supply = "jobs",
52+
detailed_results = FALSE,
53+
active = TRUE
4254
)
4355

4456
# Demand-side output (returns accessible population)
45-
det_demand <- constrained_accessibility("total", tm, lu,
46-
travel_cost = "travel_time", decay_function = exp_decay_01,
47-
demand = "population", supply = NULL,
48-
detailed_results = TRUE, active = FALSE
57+
det_demand <- constrained_accessibility(
58+
constraint = "total",
59+
travel_matrix = tm,
60+
land_use_data = lu,
61+
travel_cost = "travel_time",
62+
decay_function = exp_decay_01,
63+
demand = "population",
64+
supply = NULL,
65+
detailed_results = TRUE,
66+
active = FALSE
4967
)
50-
agg_demand <- constrained_accessibility("total", tm, lu,
51-
travel_cost = "travel_time", decay_function = exp_decay_01,
52-
demand = "population", supply = NULL,
53-
detailed_results = FALSE, active = FALSE
68+
agg_demand <- constrained_accessibility(
69+
constraint = "total",
70+
travel_matrix = tm,
71+
land_use_data = lu,
72+
travel_cost = "travel_time",
73+
decay_function = exp_decay_01,
74+
demand = "population",
75+
supply = NULL,
76+
detailed_results = FALSE,
77+
active = FALSE
5478
)
5579

5680
expect_equal(sum(det_supply$supply), sum(lu$jobs))
@@ -65,27 +89,51 @@ test_that("singly-constrained: preserves totals and kappa properties", {
6589
lu <- make_lu_large()
6690

6791
# Supply-constrained (returns accessible opportunities)
68-
det_supply <- constrained_accessibility("singly", tm, lu,
69-
travel_cost = "travel_time", decay_function = exp_decay_01,
70-
demand = "population", supply = "jobs",
71-
detailed_results = TRUE, active = TRUE
92+
det_supply <- constrained_accessibility(
93+
travel_matrix = tm,
94+
land_use_data = lu,
95+
constraint = "singly",
96+
travel_cost = "travel_time",
97+
decay_function = exp_decay_01,
98+
demand = "population",
99+
supply = "jobs",
100+
detailed_results = TRUE,
101+
active = TRUE
72102
)
73-
agg_supply <- constrained_accessibility("singly", tm, lu,
74-
travel_cost = "travel_time", decay_function = exp_decay_01,
75-
demand = "population", supply = "jobs",
76-
detailed_results = FALSE, active = TRUE
103+
agg_supply <- constrained_accessibility(
104+
constraint = "singly",
105+
travel_matrix = tm,
106+
land_use_data = lu,
107+
travel_cost = "travel_time",
108+
decay_function = exp_decay_01,
109+
demand = "population",
110+
supply = "jobs",
111+
detailed_results = FALSE,
112+
active = TRUE
77113
)
78114

79115
# Demand-constrained (returns accessible population)
80-
det_demand <- constrained_accessibility("singly", tm, lu,
81-
travel_cost = "travel_time", decay_function = exp_decay_01,
82-
demand = "population", supply = "jobs",
83-
detailed_results = TRUE, active = FALSE
116+
det_demand <- constrained_accessibility(
117+
constraint = "singly",
118+
travel_matrix = tm,
119+
land_use_data = lu,
120+
travel_cost = "travel_time",
121+
decay_function = exp_decay_01,
122+
demand = "population",
123+
supply = "jobs",
124+
detailed_results = TRUE,
125+
active = FALSE
84126
)
85-
agg_demand <- constrained_accessibility("singly", tm, lu,
86-
travel_cost = "travel_time", decay_function = exp_decay_01,
87-
demand = "population", supply = "jobs",
88-
detailed_results = FALSE, active = FALSE
127+
agg_demand <- constrained_accessibility(
128+
constraint = "singly",
129+
travel_matrix = tm,
130+
land_use_data = lu,
131+
travel_cost = "travel_time",
132+
decay_function = exp_decay_01,
133+
demand = "population",
134+
supply = "jobs",
135+
detailed_results = FALSE,
136+
active = FALSE
89137
)
90138

91139
# Totals
@@ -110,12 +158,17 @@ test_that("doubly-constrained: errors when totals mismatch", {
110158
lu_bad[id == "3", jobs := jobs + 1] # break equality
111159

112160
expect_error(
113-
constrained_accessibility("doubly", tm, lu_bad,
114-
travel_cost = "travel_time", decay_function = exp_decay_01,
115-
demand = "population", supply = "jobs",
116-
detailed_results = TRUE, active = NULL
117-
),
118-
"sum of origins must equal the sum of destinations"
161+
constrained_accessibility(
162+
constraint = "doubly",
163+
travel_matrix = tm,
164+
land_use_data = lu_bad,
165+
travel_cost = "travel_time",
166+
decay_function = exp_decay_01,
167+
demand = "population",
168+
supply = "jobs",
169+
detailed_results = TRUE,
170+
active = NULL
171+
), "sum of origins must equal the sum of destinations"
119172
)
120173
})
121174

@@ -126,10 +179,16 @@ test_that("doubly-constrained: OD flows match marginals", {
126179
lu <- make_lu_match20()
127180
decay <- pow_decay_3
128181

129-
det <- constrained_accessibility("doubly", tm, lu,
130-
travel_cost = "travel_time", decay_function = decay,
131-
demand = "population", supply = "jobs",
132-
detailed_results = TRUE, active = NULL
182+
det <- constrained_accessibility(
183+
constraint = "doubly",
184+
travel_matrix = tm,
185+
land_use_data = lu,
186+
travel_cost = "travel_time",
187+
decay_function = decay,
188+
demand = "population",
189+
supply = "jobs",
190+
detailed_results = TRUE,
191+
active = NULL
133192
)
134193

135194
# Robustly pick the numeric flow column
@@ -149,3 +208,4 @@ test_that("doubly-constrained: OD flows match marginals", {
149208
expect_equal(by_origin$sum_flow, O, tolerance = 1e-3)
150209
expect_equal(by_dest$sum_flow, D, tolerance = 1e-3)
151210
})
211+

0 commit comments

Comments
 (0)