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
f8afd304
Commit
f8afd304
authored
5 years ago
by
u214892
Browse files
Options
Downloads
Patches
Plain Diff
#66 cleanup
parent
9a78df3c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
flatland/envs/env_utils.py
+0
-12
0 additions, 12 deletions
flatland/envs/env_utils.py
tests/envs/__init__.py
+0
-0
0 additions, 0 deletions
tests/envs/__init__.py
tests/envs/test_env_utils.py
+7
-7
7 additions, 7 deletions
tests/envs/test_env_utils.py
with
7 additions
and
19 deletions
flatland/envs/env_utils.py
+
0
−
12
View file @
f8afd304
...
...
@@ -291,18 +291,6 @@ def distance_on_rail(pos1, pos2):
return
abs
(
pos1
[
0
]
-
pos2
[
0
])
+
abs
(
pos1
[
1
]
-
pos2
[
1
])
def
get_new_position
(
position
,
movement
):
"""
Utility function that converts a compass movement over a 2D grid to new positions (r, c).
"""
if
movement
==
Grid4TransitionsEnum
.
NORTH
:
return
(
position
[
0
]
-
1
,
position
[
1
])
elif
movement
==
Grid4TransitionsEnum
.
EAST
:
return
(
position
[
0
],
position
[
1
]
+
1
)
elif
movement
==
Grid4TransitionsEnum
.
SOUTH
:
return
(
position
[
0
]
+
1
,
position
[
1
])
elif
movement
==
Grid4TransitionsEnum
.
WEST
:
return
(
position
[
0
],
position
[
1
]
-
1
)
def
get_rnd_agents_pos_tgt_dir_on_rail
(
rail
,
num_agents
):
"""
Given a `rail
'
GridTransitionMap, return a random placement of agents (initial position, direction and target).
...
...
This diff is collapsed.
Click to expand it.
tests/envs/__init__.py
0 → 100644
+
0
−
0
View file @
f8afd304
This diff is collapsed.
Click to expand it.
tests/test_env_utils.py
→
tests/
envs/
test_env_utils.py
+
7
−
7
View file @
f8afd304
...
...
@@ -24,10 +24,10 @@ def test_coordinate_to_position():
def
test_get_direction
():
assert
get_direction
((
0
,
0
),(
0
,
1
))
==
Grid4TransitionsEnum
.
EAST
assert
get_direction
((
0
,
0
),(
0
,
2
))
==
Grid4TransitionsEnum
.
EAST
assert
get_direction
((
0
,
0
),(
1
,
0
))
==
Grid4TransitionsEnum
.
SOUTH
assert
get_direction
((
1
,
0
),(
0
,
0
))
==
Grid4TransitionsEnum
.
NORTH
assert
get_direction
((
1
,
0
),(
0
,
0
))
==
Grid4TransitionsEnum
.
NORTH
with
pytest
.
raises
(
Exception
,
match
=
"
Could not determine direction
"
):
get_direction
((
0
,
0
),(
0
,
0
))
==
Grid4TransitionsEnum
.
NORTH
assert
get_direction
((
0
,
0
),
(
0
,
1
))
==
Grid4TransitionsEnum
.
EAST
assert
get_direction
((
0
,
0
),
(
0
,
2
))
==
Grid4TransitionsEnum
.
EAST
assert
get_direction
((
0
,
0
),
(
1
,
0
))
==
Grid4TransitionsEnum
.
SOUTH
assert
get_direction
((
1
,
0
),
(
0
,
0
))
==
Grid4TransitionsEnum
.
NORTH
assert
get_direction
((
1
,
0
),
(
0
,
0
))
==
Grid4TransitionsEnum
.
NORTH
with
pytest
.
raises
(
Exception
,
match
=
"
Could not determine direction
"
):
get_direction
((
0
,
0
),
(
0
,
0
))
==
Grid4TransitionsEnum
.
NORTH
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