Commit 8b4c33dc authored by Zhang, Chen's avatar Zhang, Chen
Browse files

handle unit in one location

parent fd2880d6
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ class find_rotation_center(param.ParameterizedFunction):
            arrays=params.arrays,
            angles=params.angles,
            in_degrees=params.in_degrees,
            atol_deg=params.atol_deg,
            atol=params.atol_deg,
            num_pairs=params.num_pairs,
            max_workers=self.max_workers,
            tqdm_class=params.tqdm_class,
@@ -85,7 +85,7 @@ class find_rotation_center(param.ParameterizedFunction):
        arrays: np.ndarray,
        angles: np.ndarray,
        in_degrees: bool = True,
        atol_deg: float = None,
        atol: float = None,
        num_pairs: int = 1,
        max_workers: int = -1,
        tqdm_class=None,
@@ -96,10 +96,9 @@ class find_rotation_center(param.ParameterizedFunction):
            logger.error(msg)
            raise ValueError(msg)
        # locate 180 degree pairs
        if atol_deg is None:
        if atol is None:
            idx_low, idx_hgh = find_180_deg_pairs_idx(angles, in_degrees=in_degrees)
        else:
            atol = atol_deg if in_degrees else np.radians(atol_deg)
            idx_low, idx_hgh = find_180_deg_pairs_idx(angles, atol=atol, in_degrees=in_degrees)
        # decide how many pairs to use
        if num_pairs <= 0 or num_pairs >= idx_low.size:
+3 −2
Original line number Diff line number Diff line
@@ -228,8 +228,9 @@ def test_find_180_deg_pairs():
    np.testing.assert_equal(low_range_idx, np.array([0, 1, 2, 3, 4]))
    np.testing.assert_equal(high_range_idx, np.array([5, 6, 7, 8, 9]))
    # test explicit atol
    omegas = np.sort(omegas)
    atol = np.min(np.diff(omegas)) / 2.0
    # NOTE: use the same formula to compute atol outside the function
    sorted_indices = np.argsort(omegas)
    atol = np.min(np.diff(omegas[sorted_indices])) / 2.0
    low_range_idx, high_range_idx = find_180_deg_pairs_idx(omegas, in_degrees=False, atol=atol)
    np.testing.assert_equal(low_range_idx, np.array([0, 1, 2, 3, 4]))
    np.testing.assert_equal(high_range_idx, np.array([5, 6, 7, 8, 9]))