Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
navipy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olivier Bertrand
navipy
Commits
3724cbec
Commit
3724cbec
authored
6 years ago
by
Olivier Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Use columns naming from trajectories in database for homogeneity
parent
576f3d35
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
navipy/database/__init__.py
+11
-23
11 additions, 23 deletions
navipy/database/__init__.py
navipy/database/test.py
+3
-30
3 additions, 30 deletions
navipy/database/test.py
with
14 additions
and
53 deletions
navipy/database/__init__.py
+
11
−
23
View file @
3724cbec
...
...
@@ -10,6 +10,7 @@ import io
from
navipy.scene
import
is_numeric_array
,
check_scene
from
navipy.maths
import
constants
as
mconst
from
navipy.trajectories
import
Trajectory
from
navipy.trajectories
import
posorient_columns
import
logging
import
numbers
...
...
@@ -552,7 +553,7 @@ class DataBase():
if
self
.
rotation_convention
is
not
None
:
posorients
=
Trajectory
()
posorients
.
from_dataframe
(
posorient
,
rotconv
=
self
.
__convention
)
return
posorients
return
posorients
.
astype
(
float
)
@property
def
normalisations
(
self
):
...
...
@@ -612,40 +613,27 @@ class DataBase():
# toreturn = toreturn.astype(float)
posorient
=
None
convention
=
toreturn
.
rotconv_id
tuples
=
posorient_columns
(
convention
)
index
=
pd
.
MultiIndex
.
from_tuples
(
tuples
)
posorient
=
pd
.
Series
(
index
=
index
)
posorient
[
'
location
'
][
'
x
'
]
=
toreturn
.
loc
[
'
x
'
]
posorient
[
'
location
'
][
'
y
'
]
=
toreturn
.
loc
[
'
y
'
]
posorient
[
'
location
'
][
'
z
'
]
=
toreturn
.
loc
[
'
z
'
]
if
convention
!=
'
quaternion
'
:
tuples
=
[(
'
location
'
,
'
x
'
),
(
'
location
'
,
'
y
'
),
(
'
location
'
,
'
z
'
),
(
'
xyz
'
,
'
alpha_0
'
),
(
'
xyz
'
,
'
alpha_1
'
),
(
'
xyz
'
,
'
alpha_2
'
)]
index
=
pd
.
MultiIndex
.
from_tuples
(
tuples
,
names
=
[
'
position
'
,
'
orientation
'
])
posorient
=
pd
.
Series
(
index
=
index
)
posorient
[
'
location
'
][
'
x
'
]
=
toreturn
.
loc
[
'
x
'
]
posorient
[
'
location
'
][
'
y
'
]
=
toreturn
.
loc
[
'
y
'
]
posorient
[
'
location
'
][
'
z
'
]
=
toreturn
.
loc
[
'
z
'
]
posorient
[
convention
][
'
alpha_0
'
]
=
toreturn
.
loc
[
'
q_0
'
]
posorient
[
convention
][
'
alpha_1
'
]
=
toreturn
.
loc
[
'
q_1
'
]
posorient
[
convention
][
'
alpha_2
'
]
=
toreturn
.
loc
[
'
q_2
'
]
posorient
.
name
=
toreturn
.
name
else
:
tuples
=
[(
'
location
'
,
'
x
'
),
(
'
location
'
,
'
y
'
),
(
'
location
'
,
'
z
'
),
(
convention
,
'
q_0
'
),
(
convention
,
'
q_1
'
),
(
convention
,
'
q_2
'
),
(
convention
,
'
q_3
'
)]
index
=
pd
.
MultiIndex
.
from_tuples
(
tuples
,
names
=
[
'
position
'
,
'
orientation
'
])
posorient
=
pd
.
Series
(
index
=
index
)
posorient
[
'
location
'
][
'
x
'
]
=
toreturn
.
loc
[
'
x
'
]
posorient
[
'
location
'
][
'
y
'
]
=
toreturn
.
loc
[
'
y
'
]
posorient
[
'
location
'
][
'
z
'
]
=
toreturn
.
loc
[
'
z
'
]
posorient
[
convention
][
'
q_0
'
]
=
toreturn
.
loc
[
'
q_0
'
]
posorient
[
convention
][
'
q_1
'
]
=
toreturn
.
loc
[
'
q_1
'
]
posorient
[
convention
][
'
q_2
'
]
=
toreturn
.
loc
[
'
q_2
'
]
posorient
[
convention
][
'
q_3
'
]
=
toreturn
.
loc
[
'
q_3
'
]
posorient
.
name
=
toreturn
.
name
return
posorient
return
posorient
.
astype
(
float
)
def
scene
(
self
,
posorient
=
None
,
rowid
=
None
):
"""
Read an image at a given position-orientation or given id of row in the
\
...
...
This diff is collapsed.
Click to expand it.
navipy/database/test.py
+
3
−
30
View file @
3724cbec
...
...
@@ -146,27 +146,9 @@ class TestCase(unittest.TestCase):
and checks if the returned entry for rowid 1 is correct
- that it all columns and correct values
"""
conn
=
sqlite3
.
connect
(
self
.
mydb_filename
)
c
=
conn
.
cursor
()
c
.
execute
(
"""
SELECT * FROM position_orientation WHERE (rowid=1)
"""
)
rows
=
c
.
fetchall
()[
0
]
# working case
tuples
=
[(
'
location
'
,
'
x
'
),
(
'
location
'
,
'
y
'
),
(
'
location
'
,
'
z
'
),
(
'
xyz
'
,
'
alpha_0
'
),
(
'
xyz
'
,
'
alpha_1
'
),
(
'
xyz
'
,
'
alpha_2
'
)]
index
=
pd
.
MultiIndex
.
from_tuples
(
tuples
,
names
=
[
'
position
'
,
'
orientation
'
])
posorient
=
pd
.
Series
(
index
=
index
)
posorient
[
'
location
'
][
'
x
'
]
=
rows
[
6
]
posorient
[
'
location
'
][
'
y
'
]
=
rows
[
7
]
posorient
[
'
location
'
][
'
z
'
]
=
rows
[
8
]
posorient
[
'
xyz
'
][
'
alpha_0
'
]
=
rows
[
3
]
posorient
[
'
xyz
'
][
'
alpha_1
'
]
=
rows
[
5
]
posorient
[
'
xyz
'
][
'
alpha_2
'
]
=
rows
[
4
]
posorient
=
self
.
mydb
.
posorients
.
iloc
[
0
,
:]
for
rowid
in
[
0
,
-
2
]:
with
self
.
assertRaises
(
ValueError
):
# print("rowid",rowid)
self
.
mydb
.
read_posorient
(
rowid
=
rowid
)
with
self
.
assertRaises
(
TypeError
):
self
.
mydb
.
read_posorient
(
rowid
=
'
T
'
)
...
...
@@ -179,15 +161,7 @@ class TestCase(unittest.TestCase):
for
rowid
in
[
1
]:
posoriend2
=
self
.
mydb
.
read_posorient
(
rowid
=
rowid
)
assert
posoriend2
[
'
location
'
][
'
x
'
]
==
posorient
[
'
location
'
][
'
x
'
]
assert
posoriend2
[
'
location
'
][
'
y
'
]
==
posorient
[
'
location
'
][
'
y
'
]
assert
posoriend2
[
'
location
'
][
'
z
'
]
==
posorient
[
'
location
'
][
'
z
'
]
assert
(
posoriend2
[
'
xyz
'
][
'
alpha_0
'
]
==
posorient
[
'
xyz
'
][
'
alpha_0
'
])
assert
(
posoriend2
[
'
xyz
'
][
'
alpha_1
'
]
==
posorient
[
'
xyz
'
][
'
alpha_1
'
])
assert
(
posoriend2
[
'
xyz
'
][
'
alpha_2
'
]
==
posorient
[
'
xyz
'
][
'
alpha_2
'
])
pd
.
testing
.
assert_series_equal
(
posoriend2
,
posorient
)
def
test_scene_id
(
self
):
"""
...
...
@@ -247,7 +221,7 @@ class TestCase(unittest.TestCase):
# incorrect case missing column
posorient2
=
posorient
.
copy
()
posorient2
.
drop
((
'
location
'
,
'
x
'
))
posorient2
=
posorient2
.
drop
((
'
location
'
,
'
x
'
))
with
self
.
assertRaises
(
Exception
):
image
=
self
.
mydb
.
scene
(
posorient
=
posorient2
)
...
...
@@ -270,7 +244,6 @@ class TestCase(unittest.TestCase):
# not working case empty
posorient2
=
pd
.
Series
(
index
=
posorient
.
index
)
with
self
.
assertRaises
(
Exception
):
image
=
self
.
mydb
.
scene
(
posorient
=
posorient2
)
...
...
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