Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yoogottamk
Flatland
Commits
275e6691
Commit
275e6691
authored
5 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
test infrastructure generator
parent
d5ffef87
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_flatland_core_grid4_generators_util.py
+62
-0
62 additions, 0 deletions
tests/test_flatland_core_grid4_generators_util.py
with
62 additions
and
0 deletions
tests/test_flatland_core_grid4_generators_util.py
0 → 100644
+
62
−
0
View file @
275e6691
import
numpy
as
np
from
flatland.core.grid.grid_utils
import
Vec2dOperations
as
Vec2d
from
flatland.core.grid.rail_env_grid
import
RailEnvTransitions
from
flatland.core.transition_map
import
GridTransitionMap
from
flatland.envs.grid4_generators_utils
import
connect_rail
,
connect_nodes
,
connect_from_nodes
,
connect_to_nodes
def
test_build_railway_infrastructure
():
rail_trans
=
RailEnvTransitions
()
grid_map
=
GridTransitionMap
(
width
=
20
,
height
=
20
,
transitions
=
rail_trans
)
grid_map
.
grid
.
fill
(
0
)
np
.
random
.
seed
(
0
)
start_point
=
(
2
,
2
)
end_point
=
(
8
,
8
)
connection_001
=
connect_rail
(
rail_trans
,
grid_map
,
start_point
,
end_point
,
Vec2d
.
get_manhattan_distance
)
connection_001_expected
=
[(
2
,
2
),
(
3
,
2
),
(
3
,
3
),
(
4
,
3
),
(
4
,
4
),
(
5
,
4
),
(
5
,
5
),
(
5
,
6
),
(
6
,
6
),
(
6
,
7
),
(
7
,
7
),
(
8
,
7
),
(
8
,
8
)]
start_point
=
(
1
,
3
)
end_point
=
(
1
,
7
)
connection_002
=
connect_nodes
(
rail_trans
,
grid_map
,
start_point
,
end_point
,
Vec2d
.
get_manhattan_distance
)
connection_002_expected
=
[(
1
,
3
),
(
1
,
4
),
(
1
,
5
),
(
1
,
6
),
(
1
,
7
)]
start_point
=
(
6
,
2
)
end_point
=
(
6
,
5
)
connection_003
=
connect_from_nodes
(
rail_trans
,
grid_map
,
start_point
,
end_point
,
Vec2d
.
get_manhattan_distance
)
connection_003_expected
=
[(
6
,
2
),
(
6
,
3
),
(
6
,
4
),
(
6
,
5
)]
start_point
=
(
7
,
5
)
end_point
=
(
8
,
9
)
connection_004
=
connect_to_nodes
(
rail_trans
,
grid_map
,
start_point
,
end_point
,
Vec2d
.
get_manhattan_distance
)
connection_004_expected
=
[(
7
,
5
),
(
7
,
6
),
(
7
,
7
),
(
7
,
8
),
(
7
,
9
),
(
8
,
9
)]
assert
connection_001
==
connection_001_expected
assert
connection_002
==
connection_002_expected
assert
connection_003
==
connection_003_expected
assert
connection_004
==
connection_004_expected
grid_map_grid_expected
=
[[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
1025
,
1025
,
1025
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
8192
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
72
,
4608
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
72
,
4608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0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]]
assert
np
.
all
(
grid_map
.
grid
==
grid_map_grid_expected
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment