Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
bioroboticslab
robofish
io
Commits
16e029d0
Commit
16e029d0
authored
1 month ago
by
Andi Gerken
Browse files
Options
Downloads
Patches
Plain Diff
Lazy import for pandas and seaborn.
parent
58ed1c08
Branches
develop
master
Branches containing commit
Tags
0.4.0
1 merge request
!54
robofish-io-evaluate2 and lazy imports
Pipeline
#66656
passed
1 month ago
Stage: package
Stage: test
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/robofish/evaluate/evaluate.py
+25
-5
25 additions, 5 deletions
src/robofish/evaluate/evaluate.py
src/robofish/io/io.py
+2
-3
2 additions, 3 deletions
src/robofish/io/io.py
with
27 additions
and
8 deletions
src/robofish/evaluate/evaluate.py
+
25
−
5
View file @
16e029d0
...
...
@@ -15,9 +15,8 @@ from pathlib import Path
import
matplotlib
import
matplotlib.pyplot
as
plt
import
matplotlib.gridspec
as
gridspec
import
seaborn
as
sns
import
numpy
as
np
import
pandas
as
pd
from
typing
import
Iterable
,
Union
,
Callable
,
List
from
scipy
import
stats
from
tqdm
import
tqdm
...
...
@@ -408,6 +407,12 @@ def evaluate_tank_position(
matplotlib.figure.Figure: The figure of the heatmap.
"""
try
:
import
seaborn
as
sns
except
ImportError
:
print
(
"
Seaborn is not installed and could not be imported
"
)
return
if
poses_from_paths
is
None
:
poses_from_paths
,
file_settings
=
utils
.
get_all_poses_from_paths
(
paths
,
predicate
,
max_files
=
max_files
...
...
@@ -653,6 +658,8 @@ def evaluate_single_plot_tracks(
ax
[
i
].
plot
(
e
[:,
0
],
e
[:,
1
],
c
=
cmap
(
fi
/
len
(
poses_per_path
)),
alpha
=
0.5
)
ax
[
i
].
set_xlim
(
-
50
,
50
)
ax
[
i
].
set_ylim
(
-
50
,
50
)
ax
[
i
].
set_title
(
labels
[
i
])
ax
[
i
].
set_xlabel
(
"
x [cm]
"
)
ax
[
i
].
set_ylabel
(
"
y [cm]
"
)
...
...
@@ -742,6 +749,13 @@ def evaluate_follow_iid(
matplotlib.figure.Figure: The figure of the follow iids.
"""
try
:
import
pandas
as
pd
import
seaborn
as
sns
except
ImportError
:
print
(
"
pandas or seaborn is not installed and could not be imported
"
)
return
if
poses_from_paths
is
None
:
poses_from_paths
,
file_settings
=
utils
.
get_all_poses_from_paths
(
paths
,
predicate
,
max_files
=
max_files
...
...
@@ -1377,9 +1391,9 @@ class SeabornFig2Grid:
def
__init__
(
self
,
seaborngrid
:
sns
.
axisgrid
.
Grid
,
fig
:
matplotlib
.
figure
.
Figure
,
subplot_spec
:
matplotlib
.
gridspec
.
SubplotSpec
,
seaborngrid
,
fig
,
subplot_spec
,
)
->
None
:
"""
Init function.
...
...
@@ -1388,6 +1402,12 @@ class SeabornFig2Grid:
fig(matplotlib.figure.Figure): The figure.
subplot_spec(matplotlib.gridspec.SubplotSpec): The subplot spec.
"""
try
:
import
seaborn
as
sns
except
ImportError
:
print
(
"
Pandas is not installed and could not be imported
"
)
return
self
.
fig
=
fig
self
.
sg
=
seaborngrid
self
.
subplot
=
subplot_spec
...
...
This diff is collapsed.
Click to expand it.
src/robofish/io/io.py
+
2
−
3
View file @
16e029d0
...
...
@@ -5,7 +5,6 @@ from pathlib import Path
import
logging
import
numpy
as
np
import
pandas
import
random
import
deprecation
...
...
@@ -47,7 +46,7 @@ def read_multiple_files(
logging
.
info
(
f
"
Reading files from path
{
paths
}
"
)
list_types
=
(
list
,
np
.
ndarray
,
pandas
.
core
.
series
.
Series
)
list_types
=
(
list
,
np
.
ndarray
)
if
not
isinstance
(
paths
,
list_types
):
paths
=
[
paths
]
...
...
@@ -114,7 +113,7 @@ def read_property_from_multiple_files(
),
"
Please select an entity property e.g.
'
Entity.poses_rad
'"
logging
.
info
(
f
"
Reading files from path
{
paths
}
"
)
list_types
=
(
list
,
np
.
ndarray
,
pandas
.
core
.
series
.
Series
)
list_types
=
(
list
,
np
.
ndarray
)
if
not
isinstance
(
paths
,
list_types
):
paths
=
[
paths
]
...
...
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