Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Flatland
Flatland
Commits
a186d58b
Commit
a186d58b
authored
Sep 10, 2021
by
nimishsantosh107
Browse files
test persistence - added, file name typo in tests fixed
parent
0d809435
Pipeline
#8456
failed with stages
in 5 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/test_flatland_envs_persistence.py
0 → 100644
View file @
a186d58b
import
numpy
as
np
from
flatland.envs.rail_env
import
RailEnv
from
flatland.envs.rail_generators
import
rail_from_grid_transition_map
from
flatland.envs.line_generators
import
sparse_line_generator
from
flatland.utils.simple_rail
import
make_simple_rail
from
flatland.envs.persistence
import
RailEnvPersister
def
test_load_new
():
filename
=
"test_load_new.pkl"
rail
,
rail_map
,
optionals
=
make_simple_rail
()
n_agents
=
2
env_initial
=
RailEnv
(
width
=
rail_map
.
shape
[
1
],
height
=
rail_map
.
shape
[
0
],
rail_generator
=
rail_from_grid_transition_map
(
rail
,
optionals
),
line_generator
=
sparse_line_generator
(),
number_of_agents
=
n_agents
)
env_initial
.
reset
(
False
,
False
)
rails_initial
=
env_initial
.
rail
.
grid
agents_initial
=
env_initial
.
agents
RailEnvPersister
.
save
(
env_initial
,
filename
)
env_loaded
,
_
=
RailEnvPersister
.
load_new
(
filename
)
rails_loaded
=
env_loaded
.
rail
.
grid
agents_loaded
=
env_loaded
.
agents
assert
np
.
all
(
np
.
array_equal
(
rails_initial
,
rails_loaded
))
assert
agents_initial
==
agents_loaded
def
main
():
pass
if
__name__
==
"__main__"
:
main
()
tests/test_fla
l
tland_rail_agent_status.py
→
tests/test_flatland_rail_agent_status.py
View file @
a186d58b
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment