diff --git a/src/robofish/evaluate/evaluate.py b/src/robofish/evaluate/evaluate.py index 79c85f0b900c06be2d0350d3994ef20fad4714a2..97d07f29483edf85ff81343655ebcf2d723d2f99 100644 --- a/src/robofish/evaluate/evaluate.py +++ b/src/robofish/evaluate/evaluate.py @@ -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 diff --git a/src/robofish/io/io.py b/src/robofish/io/io.py index b1c41c692cf25932689df2f0c0a21cd07c8599fc..b3305b1a5378ff64bdae63c4bc55a51fd45a453e 100644 --- a/src/robofish/io/io.py +++ b/src/robofish/io/io.py @@ -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]