Loading src/imars3d/backend/diagnostics/tilt.py +6 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) def find_180_deg_pairs_idx( angles: np.ndarray, atol: float = 1e-3, atol: float = None, in_degrees: bool = True, ) -> Tuple[np.ndarray, np.ndarray]: """ Loading @@ -29,7 +29,7 @@ def find_180_deg_pairs_idx( Parameters ---------- angles: The list of angles as a 1d array. The list of sorted angles as a 1d array. atol: The absolute tolerance in degree for the 180 degree pairs. in_degrees: Loading @@ -45,6 +45,10 @@ def find_180_deg_pairs_idx( raise ValueError("angles must be a 1d array") # ensure angles are in degrees angles = angles if in_degrees else np.degrees(angles) # compute atol if not specified if atol is None: atol = np.min(np.absolute(np.diff(angles))) / 2.0 logger.debug(f"use computed atol = {atol}") # compute the self difference matrix angles = angles[..., np.newaxis] diff_matrix = angles.T - angles Loading tests/unit/backend/diagnostics/test_tilt.py +1 −1 Original line number Diff line number Diff line Loading @@ -220,7 +220,7 @@ def test_calculate_shift(): def test_find_180_deg_pairs(): # prepare the input list of angles in radians omegas = np.random.random(5) * np.pi omegas = np.sort(np.random.random(5) * np.pi) omegas = np.array(list(omegas) + list(omegas + np.pi)) # get the pairs low_range_idx, high_range_idx = find_180_deg_pairs_idx(omegas, in_degrees=False) Loading Loading
src/imars3d/backend/diagnostics/tilt.py +6 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) def find_180_deg_pairs_idx( angles: np.ndarray, atol: float = 1e-3, atol: float = None, in_degrees: bool = True, ) -> Tuple[np.ndarray, np.ndarray]: """ Loading @@ -29,7 +29,7 @@ def find_180_deg_pairs_idx( Parameters ---------- angles: The list of angles as a 1d array. The list of sorted angles as a 1d array. atol: The absolute tolerance in degree for the 180 degree pairs. in_degrees: Loading @@ -45,6 +45,10 @@ def find_180_deg_pairs_idx( raise ValueError("angles must be a 1d array") # ensure angles are in degrees angles = angles if in_degrees else np.degrees(angles) # compute atol if not specified if atol is None: atol = np.min(np.absolute(np.diff(angles))) / 2.0 logger.debug(f"use computed atol = {atol}") # compute the self difference matrix angles = angles[..., np.newaxis] diff_matrix = angles.T - angles Loading
tests/unit/backend/diagnostics/test_tilt.py +1 −1 Original line number Diff line number Diff line Loading @@ -220,7 +220,7 @@ def test_calculate_shift(): def test_find_180_deg_pairs(): # prepare the input list of angles in radians omegas = np.random.random(5) * np.pi omegas = np.sort(np.random.random(5) * np.pi) omegas = np.array(list(omegas) + list(omegas + np.pi)) # get the pairs low_range_idx, high_range_idx = find_180_deg_pairs_idx(omegas, in_degrees=False) Loading