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
dcad0572
Commit
dcad0572
authored
5 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
vec2d testing
parent
275e6691
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/core/grid/grid_utils.py
+12
-0
12 additions, 0 deletions
flatland/core/grid/grid_utils.py
tests/test_flatland_core_grid_grid_utils.py
+64
-0
64 additions, 0 deletions
tests/test_flatland_core_grid_grid_utils.py
with
76 additions
and
0 deletions
flatland/core/grid/grid_utils.py
+
12
−
0
View file @
dcad0572
...
@@ -172,6 +172,18 @@ class Vec2dOperations:
...
@@ -172,6 +172,18 @@ class Vec2dOperations:
"""
"""
return
int
(
np
.
ceil
(
node
[
0
])),
int
(
np
.
ceil
(
node
[
1
]))
return
int
(
np
.
ceil
(
node
[
0
])),
int
(
np
.
ceil
(
node
[
1
]))
@staticmethod
def
floor
(
node
:
Vector2D
)
->
IntVector2D
:
"""
floor the x and y coordinate and convert them to an integer values
:param node: tuple with coordinate (x,y) or 2d vector
:return:
-------
tuple with coordinate (x,y) or 2d vector
"""
return
int
(
np
.
floor
(
node
[
0
])),
int
(
np
.
floor
(
node
[
1
]))
@staticmethod
@staticmethod
def
bound
(
node
:
Vector2D
,
min_value
:
float
,
max_value
:
float
)
->
Vector2D
:
def
bound
(
node
:
Vector2D
,
min_value
:
float
,
max_value
:
float
)
->
Vector2D
:
"""
"""
...
...
This diff is collapsed.
Click to expand it.
tests/test_flatland_core_grid_grid_utils.py
0 → 100644
+
64
−
0
View file @
dcad0572
from
flatland.core.grid.grid_utils
import
Vec2dOperations
as
Vec2d
def
test_vec2d_add
():
node_a
=
(
1
,
2
)
node_b
=
(
2
,
3
)
res_1
=
Vec2d
.
add
(
node_a
,
node_b
)
res_2
=
Vec2d
.
add
(
node_b
,
node_a
)
assert
res_1
==
res_2
assert
res_1
==
(
3
,
5
)
def
test_vec2d_subtract
():
node_a
=
(
1
,
2
)
node_b
=
(
2
,
4
)
res_1
=
Vec2d
.
subtract
(
node_a
,
node_b
)
res_2
=
Vec2d
.
subtract
(
node_b
,
node_a
)
assert
res_1
!=
res_2
assert
res_1
==
(
-
1
,
-
2
)
assert
res_2
==
(
1
,
2
)
def
test_vec2d_make_orthogonal
():
node_a
=
(
1
,
2
)
res_1
=
Vec2d
.
make_orthogonal
(
node_a
)
assert
res_1
==
(
2
,
-
1
)
def
test_vec2d_subtract
():
node_a
=
(
1
,
2
)
node_b
=
(
2
,
4
)
node_c
=
(
1
,
2
)
res_1
=
Vec2d
.
is_equal
(
node_a
,
node_b
)
res_2
=
Vec2d
.
is_equal
(
node_a
,
node_c
)
assert
not
res_1
assert
res_2
def
test_vec2d_ceil
():
node_a
=
(
-
1.95
,
-
2.2
)
node_b
=
(
1.95
,
2.2
)
res_1
=
Vec2d
.
ceil
(
node_a
)
res_2
=
Vec2d
.
ceil
(
node_b
)
assert
res_1
==
(
-
1
,
-
2
)
assert
res_2
==
(
2
,
3
)
def
test_vec2d_floor
():
node_a
=
(
-
1.95
,
-
2.2
)
node_b
=
(
1.95
,
2.2
)
res_1
=
Vec2d
.
floor
(
node_a
)
res_2
=
Vec2d
.
floor
(
node_b
)
assert
res_1
==
(
-
2
,
-
3
)
assert
res_2
==
(
1
,
2
)
def
test_vec2d_bound
():
node_a
=
(
-
1.95
,
-
2.2
)
node_b
=
(
1.95
,
2.2
)
res_1
=
Vec2d
.
bound
(
node_a
,
-
1
,
0
)
res_2
=
Vec2d
.
bound
(
node_b
,
2
,
2.2
)
assert
res_1
==
(
-
1
,
-
1
)
assert
res_2
==
(
2
,
2.2
)
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