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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
elrichgro
Flatland
Commits
fdc4d2af
Commit
fdc4d2af
authored
5 years ago
by
spiglerg
Browse files
Options
Downloads
Patches
Plain Diff
fixed pylint errors in test_transitions.py
parent
af0fa935
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_transitions.py
+39
-25
39 additions, 25 deletions
tests/test_transitions.py
with
39 additions
and
25 deletions
tests/test_transitions.py
+
39
−
25
View file @
fdc4d2af
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
"""
Tests for `flatland` package.
"""
"""
Tests for `flatland` package.
"""
from
flatland.core.transitions
import
RailEnvTransitions
,
GridTransitions
from
flatland.core.transitions
import
RailEnvTransitions
,
GridTransitions
import
pytest
def
test_valid_railenv_transitions
():
def
test_valid_railenv_transitions
():
...
@@ -15,37 +14,52 @@ def test_valid_railenv_transitions():
...
@@ -15,37 +14,52 @@ def test_valid_railenv_transitions():
# 'W': 3}
# 'W': 3}
for
i
in
range
(
2
):
for
i
in
range
(
2
):
assert
(
rail_env_trans
.
get_transitions_from_orientation
(
int
(
'
1100110000110011
'
,
2
),
i
)
==
(
1
,
1
,
0
,
0
))
assert
(
rail_env_trans
.
get_transitions_from_orientation
(
assert
(
rail_env_trans
.
get_transitions_from_orientation
(
int
(
'
1100110000110011
'
,
2
),
2
+
i
)
==
(
0
,
0
,
1
,
1
))
int
(
'
1100110000110011
'
,
2
),
i
)
==
(
1
,
1
,
0
,
0
))
assert
(
rail_env_trans
.
get_transitions_from_orientation
(
int
(
'
1100110000110011
'
,
2
),
2
+
i
)
==
(
0
,
0
,
1
,
1
))
no_transition_cell
=
int
(
'
0000000000000000
'
,
2
)
no_transition_cell
=
int
(
'
0000000000000000
'
,
2
)
for
i
in
range
(
4
):
for
i
in
range
(
4
):
assert
(
rail_env_trans
.
get_transitions_from_orientation
(
no_transition_cell
,
i
)
==
(
0
,
0
,
0
,
0
))
assert
(
rail_env_trans
.
get_transitions_from_orientation
(
no_transition_cell
,
i
)
==
(
0
,
0
,
0
,
0
))
# Facing south, going south
# Facing south, going south
north_south_transition
=
rail_env_trans
.
set_transitions_from_orientation
(
no_transition_cell
,
2
,
(
0
,
0
,
1
,
0
))
north_south_transition
=
rail_env_trans
.
set_transitions_from_orientation
(
assert
(
rail_env_trans
.
set_transition_from_orientation_to_direction
(
north_south_transition
,
2
,
2
,
0
)
==
no_transition_cell
,
2
,
(
0
,
0
,
1
,
0
))
no_transition_cell
)
assert
(
rail_env_trans
.
set_transition_from_orientation_to_direction
(
assert
(
rail_env_trans
.
get_transition_from_orientation_to_direction
(
north_south_transition
,
2
,
2
))
north_south_transition
,
2
,
2
,
0
)
==
no_transition_cell
)
assert
(
rail_env_trans
.
get_transition_from_orientation_to_direction
(
north_south_transition
,
2
,
2
))
# Facing north, going east
# Facing north, going east
south_east_transition
=
rail_env_trans
.
set_transition_from_orientation_to_direction
(
no_transition_cell
,
0
,
1
,
1
)
south_east_transition
=
\
assert
(
rail_env_trans
.
get_transition_from_orientation_to_direction
(
south_east_transition
,
0
,
1
))
rail_env_trans
.
set_transition_from_orientation_to_direction
(
no_transition_cell
,
0
,
1
,
1
)
assert
(
rail_env_trans
.
get_transition_from_orientation_to_direction
(
south_east_transition
,
0
,
1
))
# The opposite transitions are not feasible
# The opposite transitions are not feasible
assert
(
not
rail_env_trans
.
get_transition_from_orientation_to_direction
(
north_south_transition
,
2
,
0
))
assert
(
not
rail_env_trans
.
get_transition_from_orientation_to_direction
(
assert
(
not
rail_env_trans
.
get_transition_from_orientation_to_direction
(
south_east_transition
,
2
,
1
))
north_south_transition
,
2
,
0
))
assert
(
not
rail_env_trans
.
get_transition_from_orientation_to_direction
(
south_east_transition
,
2
,
1
))
east_west_transition
=
rail_env_trans
.
rotate_transition
(
north_south_transition
,
90
)
east_west_transition
=
rail_env_trans
.
rotate_transition
(
north_west_transition
=
rail_env_trans
.
rotate_transition
(
south_east_transition
,
180
)
north_south_transition
,
90
)
north_west_transition
=
rail_env_trans
.
rotate_transition
(
south_east_transition
,
180
)
# Facing west, going west
# Facing west, going west
assert
(
rail_env_trans
.
get_transition_from_orientation_to_direction
(
east_west_transition
,
3
,
3
))
assert
(
rail_env_trans
.
get_transition_from_orientation_to_direction
(
east_west_transition
,
3
,
3
))
# Facing south, going west
# Facing south, going west
assert
(
rail_env_trans
.
get_transition_from_orientation_to_direction
(
north_west_transition
,
2
,
3
))
assert
(
rail_env_trans
.
get_transition_from_orientation_to_direction
(
north_west_transition
,
2
,
3
))
assert
(
south_east_transition
==
rail_env_trans
.
rotate_transition
(
south_east_transition
,
360
))
assert
(
south_east_transition
==
rail_env_trans
.
rotate_transition
(
south_east_transition
,
360
))
def
test_diagonal_transitions
():
def
test_diagonal_transitions
():
...
@@ -53,13 +67,13 @@ def test_diagonal_transitions():
...
@@ -53,13 +67,13 @@ def test_diagonal_transitions():
# Facing north, going north-east
# Facing north, going north-east
south_northeast_transition
=
int
(
'
01000000
'
+
'
0
'
*
8
*
7
,
2
)
south_northeast_transition
=
int
(
'
01000000
'
+
'
0
'
*
8
*
7
,
2
)
assert
(
diagonal_trans_env
.
get_transitions_from_orientation
(
south_northeast_transition
,
0
)
==
assert
(
diagonal_trans_env
.
get_transitions_from_orientation
(
(
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
))
south_northeast_transition
,
0
)
==
(
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
))
# Allowing transition from north to southwest: Facing south, going southwest
north_southwest_transition
=
diagonal_trans_env
.
set_transitions_from_orientation
(
int
(
'
0
'
*
64
,
2
),
4
,
(
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
))
assert
(
diagonal_trans_env
.
rotate_transition
(
south_northeast_transition
,
180
)
==
north_southwest_transition
)
# Allowing transition from north to southwest: Facing south, going SW
north_southwest_transition
=
\
diagonal_trans_env
.
set_transitions_from_orientation
(
int
(
'
0
'
*
64
,
2
),
4
,
(
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
))
assert
(
diagonal_trans_env
.
rotate_transition
(
south_northeast_transition
,
180
)
==
north_southwest_transition
)
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