Commit aacf06f
mavenlin
Type checking Action/State (#265)
## Description
- Introduce `TArray` to have better type checking than `Array`.
- Fix several bugs that can be detected when test is run in dbg mode.
## Motivation and Context
`Array` was a temporary design which is very unsafe. e.g. in atari
`state["done"_]` has integer type, while the return value of
`game_over()` is subject to change in the thirdparty code. We need
automatic type casting rather than manually checking them.
- [x] I have NOT raised an issue to propose this change
([required](https://envpool.readthedocs.io/en/latest/pages/contributing.html)
for new features and bug fixes)
## Types of changes
What types of changes does your code introduce? Put an `x` in all the
boxes that apply:
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds core functionality)
- [ ] New environment (non-breaking change which adds 3rd-party
environment)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation (update in the documentation)
- [ ] Example (update in the folder of example)
## Implemented Tasks
- [x] TArray.
- [x] Utilities to cast `std::vector<Array>` to `Dict<Keys,
TupleOfTArray>`.
- [x] Fix several bugs.
- [x] Replace `State`/`Action` in `Env` to be the type safe version.
- [x] Replace all uses of `Array` to `TArray`
## Checklist
Go over all the following points, and put an `x` in all the boxes that
apply.
If you are unsure about any of these, don't hesitate to ask. We are here
to help!
- [x] I have read the
[CONTRIBUTION](https://envpool.readthedocs.io/en/latest/pages/contributing.html)
guide (**required**)
- [ ] My change requires a change to the documentation.
- [x] I have updated the tests accordingly (*required for a bug fix or a
new feature*).
- [ ] I have updated the documentation accordingly.
- [x] I have reformatted the code using `make format` (**required**)
- [x] I have checked the code using `make lint` (**required**)
- [x] I have ensured `make bazel-test` pass. (**required**)1 parent 51f4686 commit aacf06f
File tree
33 files changed
+280
-194
lines changed- benchmark
- envpool
- atari
- box2d
- core
- dummy
- mujoco/gym
- procgen
- python
- toy_text
- utils
- vizdoom
- examples
- acme_examples
- cleanrl_examples
- ppo_atari
33 files changed
+280
-194
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 85 | + | |
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 36 | + | |
| 37 | + | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
| |||
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
129 | | - | |
130 | | - | |
131 | | - | |
| 127 | + | |
132 | 128 | | |
133 | 129 | | |
134 | 130 | | |
| |||
178 | 174 | | |
179 | 175 | | |
180 | 176 | | |
181 | | - | |
182 | | - | |
183 | | - | |
| 177 | + | |
184 | 178 | | |
185 | 179 | | |
186 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
| 106 | + | |
| 107 | + | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 109 | + | |
| 110 | + | |
113 | 111 | | |
114 | 112 | | |
115 | 113 | | |
| |||
128 | 126 | | |
129 | 127 | | |
130 | 128 | | |
131 | | - | |
| 129 | + | |
132 | 130 | | |
133 | 131 | | |
134 | 132 | | |
| |||
149 | 147 | | |
150 | 148 | | |
151 | 149 | | |
152 | | - | |
| 150 | + | |
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
156 | 154 | | |
157 | | - | |
158 | | - | |
| 155 | + | |
159 | 156 | | |
160 | 157 | | |
161 | | - | |
162 | | - | |
| 158 | + | |
163 | 159 | | |
164 | 160 | | |
165 | 161 | | |
| |||
169 | 165 | | |
170 | 166 | | |
171 | 167 | | |
172 | | - | |
| 168 | + | |
173 | 169 | | |
174 | 170 | | |
175 | 171 | | |
| |||
188 | 184 | | |
189 | 185 | | |
190 | 186 | | |
191 | | - | |
| 187 | + | |
192 | 188 | | |
193 | 189 | | |
194 | 190 | | |
195 | 191 | | |
196 | | - | |
197 | | - | |
| 192 | + | |
198 | 193 | | |
199 | 194 | | |
200 | 195 | | |
201 | | - | |
202 | | - | |
| 196 | + | |
203 | 197 | | |
204 | 198 | | |
205 | 199 | | |
| |||
211 | 205 | | |
212 | 206 | | |
213 | 207 | | |
214 | | - | |
| 208 | + | |
215 | 209 | | |
216 | 210 | | |
217 | 211 | | |
| |||
225 | 219 | | |
226 | 220 | | |
227 | 221 | | |
228 | | - | |
229 | | - | |
| 222 | + | |
230 | 223 | | |
231 | 224 | | |
232 | 225 | | |
| |||
250 | 243 | | |
251 | 244 | | |
252 | 245 | | |
253 | | - | |
| 246 | + | |
254 | 247 | | |
255 | 248 | | |
256 | 249 | | |
| |||
271 | 264 | | |
272 | 265 | | |
273 | 266 | | |
274 | | - | |
| 267 | + | |
275 | 268 | | |
276 | 269 | | |
277 | 270 | | |
278 | 271 | | |
279 | 272 | | |
280 | | - | |
281 | | - | |
| 273 | + | |
282 | 274 | | |
283 | 275 | | |
284 | 276 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 277 | + | |
| 278 | + | |
290 | 279 | | |
291 | 280 | | |
292 | 281 | | |
| |||
326 | 315 | | |
327 | 316 | | |
328 | 317 | | |
329 | | - | |
| 318 | + | |
330 | 319 | | |
331 | 320 | | |
332 | 321 | | |
| |||
351 | 340 | | |
352 | 341 | | |
353 | 342 | | |
354 | | - | |
| 343 | + | |
355 | 344 | | |
356 | 345 | | |
357 | 346 | | |
358 | 347 | | |
359 | | - | |
360 | | - | |
361 | | - | |
| 348 | + | |
| 349 | + | |
362 | 350 | | |
363 | 351 | | |
364 | 352 | | |
365 | 353 | | |
366 | 354 | | |
367 | 355 | | |
368 | | - | |
369 | | - | |
| 356 | + | |
370 | 357 | | |
371 | 358 | | |
372 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
267 | | - | |
| 265 | + | |
268 | 266 | | |
269 | 267 | | |
270 | 268 | | |
| |||
0 commit comments