From 5fd7cb149e6c9fb84827b5d9678c462ed817e9e3 Mon Sep 17 00:00:00 2001 From: sronilsson Date: Wed, 28 Aug 2024 16:50:19 +0000 Subject: [PATCH] cleaned --- simba/data_processors/cuda/convex_hull.py | 2 +- .../data_processors/cuda/convex_hull_area.py | 4 +++- .../BENTO_appender.py | 17 +++++++++----- simba/third_party_label_appenders/tools.py | 22 ++++++++++--------- simba/utils/read_write.py | 11 +++++----- 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/simba/data_processors/cuda/convex_hull.py b/simba/data_processors/cuda/convex_hull.py index b56a2d735..ba56f8f89 100644 --- a/simba/data_processors/cuda/convex_hull.py +++ b/simba/data_processors/cuda/convex_hull.py @@ -1,8 +1,8 @@ __author__ = "Simon Nilsson" __email__ = "sronilsson@gmail.com" -from numba import cuda, njit import numpy as np +from numba import cuda, njit THREADS_PER_BLOCK = 128 diff --git a/simba/data_processors/cuda/convex_hull_area.py b/simba/data_processors/cuda/convex_hull_area.py index 03c1a6956..44fd775f2 100644 --- a/simba/data_processors/cuda/convex_hull_area.py +++ b/simba/data_processors/cuda/convex_hull_area.py @@ -1,10 +1,12 @@ from typing import Optional + import cupy as cp +import numpy as np from simba.utils.checks import check_float, check_valid_array -import numpy as np from simba.utils.enums import Formats + def poly_area(data: np.ndarray, pixels_per_mm: Optional[float] = 1.0, batch_size: Optional[int] = int(0.5e+7)) -> np.ndarray: diff --git a/simba/third_party_label_appenders/BENTO_appender.py b/simba/third_party_label_appenders/BENTO_appender.py index 691941396..b1b01ecb7 100644 --- a/simba/third_party_label_appenders/BENTO_appender.py +++ b/simba/third_party_label_appenders/BENTO_appender.py @@ -3,16 +3,23 @@ import glob import os from copy import deepcopy -import pandas as pd -from typing import Union, Dict, Optional +from typing import Dict, Optional, Union + import numpy as np +import pandas as pd from simba.mixins.config_reader import ConfigReader -from simba.utils.checks import check_if_filepath_list_is_empty, check_if_dir_exists, check_all_file_names_are_represented_in_video_log +from simba.utils.checks import ( + check_all_file_names_are_represented_in_video_log, check_if_dir_exists, + check_if_filepath_list_is_empty) from simba.utils.errors import NoFilesFoundError from simba.utils.printing import stdout_success -from simba.utils.read_write import get_fn_ext, read_df, write_df, find_files_of_filetypes_in_directory, bento_file_reader -from simba.utils.warnings import (ThirdPartyAnnotationsClfMissingWarning, ThirdPartyAnnotationsOutsidePoseEstimationDataWarning) +from simba.utils.read_write import (bento_file_reader, + find_files_of_filetypes_in_directory, + get_fn_ext, read_df, write_df) +from simba.utils.warnings import ( + ThirdPartyAnnotationsClfMissingWarning, + ThirdPartyAnnotationsOutsidePoseEstimationDataWarning) class BentoAppender(ConfigReader): diff --git a/simba/third_party_label_appenders/tools.py b/simba/third_party_label_appenders/tools.py index 3a10b1ac8..35b4b710b 100644 --- a/simba/third_party_label_appenders/tools.py +++ b/simba/third_party_label_appenders/tools.py @@ -1,25 +1,27 @@ -from typing import Dict, List, Union, Optional +from typing import Dict, List, Optional, Union + try: from typing import Literal except: from typing_extensions import Literal +import os + import numpy as np import pandas as pd -import os +from simba.utils.checks import ( + check_all_file_names_are_represented_in_video_log, + check_file_exist_and_readable, check_if_dir_exists, check_str, + check_valid_boolean, check_valid_dataframe, check_valid_lst) from simba.utils.data import detect_bouts from simba.utils.enums import Methods from simba.utils.errors import ColumnNotFoundError, InvalidFileTypeError -from simba.utils.read_write import get_fn_ext, read_video_info, bento_file_reader, read_video_info_csv, find_files_of_filetypes_in_directory +from simba.utils.read_write import (bento_file_reader, + find_files_of_filetypes_in_directory, + get_fn_ext, read_video_info, + read_video_info_csv) from simba.utils.warnings import ThirdPartyAnnotationsInvalidFileFormatWarning -from simba.utils.checks import (check_valid_lst, - check_valid_dataframe, - check_all_file_names_are_represented_in_video_log, - check_str, - check_valid_boolean, - check_file_exist_and_readable, - check_if_dir_exists) BENTO = "Bento" diff --git a/simba/utils/read_write.py b/simba/utils/read_write.py index bdd361e95..795b03cb4 100644 --- a/simba/utils/read_write.py +++ b/simba/utils/read_write.py @@ -37,8 +37,9 @@ check_if_dir_exists, check_if_filepath_list_is_empty, check_if_string_value_is_valid_video_timestamp, - check_instance, check_int, check_str, - check_nvidea_gpu_available, check_valid_lst) + check_instance, check_int, + check_nvidea_gpu_available, check_str, + check_valid_lst) from simba.utils.enums import ConfigKey, Dtypes, Formats, Keys, Options from simba.utils.errors import (DataHeaderError, DuplicationError, FFMPEGCodecGPUError, FileExistError, @@ -49,9 +50,9 @@ NoFilesFoundError, NotDirectoryError, ParametersFileError, PermissionError) from simba.utils.printing import SimbaTimer, stdout_success -from simba.utils.warnings import (FileExistWarning, InvalidValueWarning, - NoDataFoundWarning, NoFileFoundWarning, - ThirdPartyAnnotationsInvalidFileFormatWarning) +from simba.utils.warnings import ( + FileExistWarning, InvalidValueWarning, NoDataFoundWarning, + NoFileFoundWarning, ThirdPartyAnnotationsInvalidFileFormatWarning) # from simba.utils.keyboard_listener import KeyboardListener