From adabf96a965895a50f1a7650843660350fd2a5de Mon Sep 17 00:00:00 2001 From: Julia Kukulies <julia.kukulies@gu.se> Date: Fri, 21 Jun 2024 12:22:52 -0600 Subject: [PATCH 1/3] updated docstrings for n_min_threshold --- tobac/feature_detection.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tobac/feature_detection.py b/tobac/feature_detection.py index b937a0c0..f8128f50 100644 --- a/tobac/feature_detection.py +++ b/tobac/feature_detection.py @@ -390,7 +390,7 @@ def feature_detection_threshold( ] = "center", sigma_threshold: float = 0.5, n_erosion_threshold: int = 0, - n_min_threshold: int = 0, + n_min_threshold: Union[int, dict, list] = 0 , min_distance: float = 0, idx_start: int = 0, PBC_flag: Literal["none", "hdim_1", "hdim_2", "both"] = "none", @@ -428,8 +428,10 @@ def feature_detection_threshold( Number of pixels by which to erode the identified features. Default is 0. - n_min_threshold : int, optional + n_min_threshold : int, dict or list, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. + If given as a list, the number of elements must match number of thresholds. + If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. min_distance : float, optional Minimum distance between detected features (in meters). Default is 0. @@ -897,7 +899,7 @@ def feature_detection_multithreshold_timestep( ] = "center", sigma_threshold: float = 0.5, n_erosion_threshold: int = 0, - n_min_threshold: int = 0, + n_min_threshold: Union[int, dict, list] = 0, min_distance: float = 0, feature_number_start: int = 1, PBC_flag: Literal["none", "hdim_1", "hdim_2", "both"] = "none", @@ -944,8 +946,10 @@ def feature_detection_multithreshold_timestep( Number of pixels by which to erode the identified features. Default is 0. - n_min_threshold : int, optional + n_min_threshold : int, dict or list, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. + If given as a list, the number of elements must match number of thresholds. + If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. min_distance : float, optional Minimum distance between detected features (in meters). Default is 0. @@ -1026,7 +1030,7 @@ def feature_detection_multithreshold_timestep( ): raise ValueError( "Ambiguous input for threshold values. If n_min_threshold is given as a dict," - " the keys not to correspond to the values in threshold." + " the keys must correspond to the values in threshold." ) # sort dictionary by keys (threshold values) so that they match sorted thresholds and # get values for n_min_threshold @@ -1139,7 +1143,7 @@ def feature_detection_multithreshold( ] = "center", sigma_threshold: float = 0.5, n_erosion_threshold: int = 0, - n_min_threshold: int = 0, + n_min_threshold: Union[int, dict, list] = 0, min_distance: float = 0, feature_number_start: int = 1, PBC_flag: Literal["none", "hdim_1", "hdim_2", "both"] = "none", @@ -1183,9 +1187,11 @@ def feature_detection_multithreshold( n_erosion_threshold: int, optional Number of pixels by which to erode the identified features. Default is 0. - - n_min_threshold : int, optional + + n_min_threshold : int, dict or list, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. + If given as a list, the number of elements must match number of thresholds. + If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. min_distance : float, optional Minimum distance between detected features (in meters). Default is 0. From 3a18cfb52adbceca6cb1d410be63377fe2914de5 Mon Sep 17 00:00:00 2001 From: Julia Kukulies <julia.kukulies@gu.se> Date: Fri, 21 Jun 2024 12:37:53 -0600 Subject: [PATCH 2/3] black formatting --- tobac/feature_detection.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tobac/feature_detection.py b/tobac/feature_detection.py index f8128f50..564aa03f 100644 --- a/tobac/feature_detection.py +++ b/tobac/feature_detection.py @@ -390,7 +390,7 @@ def feature_detection_threshold( ] = "center", sigma_threshold: float = 0.5, n_erosion_threshold: int = 0, - n_min_threshold: Union[int, dict, list] = 0 , + n_min_threshold: Union[int, dict, list] = 0, min_distance: float = 0, idx_start: int = 0, PBC_flag: Literal["none", "hdim_1", "hdim_2", "both"] = "none", @@ -428,10 +428,10 @@ def feature_detection_threshold( Number of pixels by which to erode the identified features. Default is 0. - n_min_threshold : int, dict or list, optional + n_min_threshold : int, dict or list, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. If given as a list, the number of elements must match number of thresholds. - If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. + If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. min_distance : float, optional Minimum distance between detected features (in meters). Default is 0. @@ -946,10 +946,10 @@ def feature_detection_multithreshold_timestep( Number of pixels by which to erode the identified features. Default is 0. - n_min_threshold : int, dict or list, optional + n_min_threshold : int, dict or list, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. If given as a list, the number of elements must match number of thresholds. - If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. + If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. min_distance : float, optional Minimum distance between detected features (in meters). Default is 0. @@ -1187,11 +1187,11 @@ def feature_detection_multithreshold( n_erosion_threshold: int, optional Number of pixels by which to erode the identified features. Default is 0. - - n_min_threshold : int, dict or list, optional + + n_min_threshold : int, dict or list, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. If given as a list, the number of elements must match number of thresholds. - If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. + If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. min_distance : float, optional Minimum distance between detected features (in meters). Default is 0. From 5551fb7cc32dcb81ea363aba07b9b33f1fa7c1b7 Mon Sep 17 00:00:00 2001 From: Julia Kukulies <44163060+JuliaKukulies@users.noreply.github.com> Date: Wed, 14 Aug 2024 12:07:36 -0600 Subject: [PATCH 3/3] fixed docstrings and type hint according to Fabians comments --- tobac/feature_detection.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tobac/feature_detection.py b/tobac/feature_detection.py index 564aa03f..0ac5fa8f 100644 --- a/tobac/feature_detection.py +++ b/tobac/feature_detection.py @@ -390,7 +390,7 @@ def feature_detection_threshold( ] = "center", sigma_threshold: float = 0.5, n_erosion_threshold: int = 0, - n_min_threshold: Union[int, dict, list] = 0, + n_min_threshold: Union[int, dict[float, int], list[int]] = 0, min_distance: float = 0, idx_start: int = 0, PBC_flag: Literal["none", "hdim_1", "hdim_2", "both"] = "none", @@ -428,7 +428,7 @@ def feature_detection_threshold( Number of pixels by which to erode the identified features. Default is 0. - n_min_threshold : int, dict or list, optional + n_min_threshold : int, dict of float to int, or list of int, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. If given as a list, the number of elements must match number of thresholds. If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. @@ -899,7 +899,7 @@ def feature_detection_multithreshold_timestep( ] = "center", sigma_threshold: float = 0.5, n_erosion_threshold: int = 0, - n_min_threshold: Union[int, dict, list] = 0, + n_min_threshold: Union[int, dict[float, int], list[int]] = 0, min_distance: float = 0, feature_number_start: int = 1, PBC_flag: Literal["none", "hdim_1", "hdim_2", "both"] = "none", @@ -946,7 +946,7 @@ def feature_detection_multithreshold_timestep( Number of pixels by which to erode the identified features. Default is 0. - n_min_threshold : int, dict or list, optional + n_min_threshold : int, dict of float to int, or list of int, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. If given as a list, the number of elements must match number of thresholds. If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold. @@ -1143,7 +1143,7 @@ def feature_detection_multithreshold( ] = "center", sigma_threshold: float = 0.5, n_erosion_threshold: int = 0, - n_min_threshold: Union[int, dict, list] = 0, + n_min_threshold: Union[int, dict[float, int], list[int]] = 0, min_distance: float = 0, feature_number_start: int = 1, PBC_flag: Literal["none", "hdim_1", "hdim_2", "both"] = "none", @@ -1188,7 +1188,7 @@ def feature_detection_multithreshold( Number of pixels by which to erode the identified features. Default is 0. - n_min_threshold : int, dict or list, optional + n_min_threshold : int, dict of float to int, or list of int, optional Minimum number of identified contiguous pixels for a feature to be detected. Default is 0. If given as a list, the number of elements must match number of thresholds. If given as a dict, the keys need to match the thresholds and the values are the minimum number of identified contiguous pixels for a feature using that specific threshold.