Skip to content

Commit c2e889a

Browse files
committed
revert to private methods
1 parent 2255b1c commit c2e889a

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

src/aspire/abinitio/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# isort: off
44
from .commonline_utils import (
55
JSync,
6-
cl_angles_to_ind,
7-
estimate_third_rows,
8-
complete_third_row_to_rot,
9-
estimate_inplane_rotations,
6+
_cl_angles_to_ind,
7+
_estimate_third_rows,
8+
_complete_third_row_to_rot,
9+
_estimate_inplane_rotations,
1010
g_sync,
1111
)
1212
from .commonline_sdp import CommonlineSDP

src/aspire/abinitio/commonline_c2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
CLOrient3D,
88
JSync,
99
SyncVotingMixin,
10-
complete_third_row_to_rot,
11-
estimate_third_rows,
10+
_complete_third_row_to_rot,
11+
_estimate_third_rows,
1212
)
1313
from aspire.utils import J_conjugate, Rotation, all_pairs
1414

@@ -225,7 +225,7 @@ def estimate_rotations(self):
225225
viis = np.vstack((np.eye(3, dtype=self.dtype),) * self.n_img).reshape(
226226
self.n_img, 3, 3
227227
)
228-
vis = estimate_third_rows(vijs, viis)
228+
vis = _estimate_third_rows(vijs, viis)
229229

230230
logger.info("Estimating in-plane rotations and rotations matrices.")
231231
Ris = self._estimate_inplane_rotations(vis, Rijs, Rijgs)
@@ -302,7 +302,7 @@ def _estimate_inplane_rotations(self, vis, Rijs, Rijgs):
302302
H = np.zeros((self.n_img, self.n_img), dtype=complex)
303303
# Step 1: Construct all rotation matrices Ris_tilde whose third rows are equal to
304304
# the corresponding third rows vis.
305-
Ris_tilde = complete_third_row_to_rot(vis)
305+
Ris_tilde = _complete_third_row_to_rot(vis)
306306

307307
pairs = all_pairs(self.n_img)
308308
for idx, (i, j) in enumerate(pairs):

src/aspire/abinitio/commonline_c3_c4.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
CLOrient3D,
88
JSync,
99
SyncVotingMixin,
10-
estimate_inplane_rotations,
11-
estimate_third_rows,
10+
_estimate_inplane_rotations,
11+
_estimate_third_rows,
1212
)
1313
from aspire.operators import PolarFT
1414
from aspire.utils import J_conjugate, Rotation, all_pairs, anorm, trange
@@ -108,10 +108,10 @@ def estimate_rotations(self):
108108
vijs, viis = self._global_J_sync(vijs, viis)
109109

110110
logger.info("Estimating third rows of rotation matrices.")
111-
vis = estimate_third_rows(vijs, viis)
111+
vis = _estimate_third_rows(vijs, viis)
112112

113113
logger.info("Estimating in-plane rotations and rotations matrices.")
114-
Ris = estimate_inplane_rotations(self, vis)
114+
Ris = _estimate_inplane_rotations(self, vis)
115115

116116
self.rotations = Ris
117117

src/aspire/abinitio/commonline_cn.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from aspire.abinitio import (
77
CLOrient3D,
88
JSync,
9-
cl_angles_to_ind,
10-
complete_third_row_to_rot,
11-
estimate_inplane_rotations,
12-
estimate_third_rows,
9+
_cl_angles_to_ind,
10+
_complete_third_row_to_rot,
11+
_estimate_inplane_rotations,
12+
_estimate_third_rows,
1313
)
1414
from aspire.operators import PolarFT
1515
from aspire.utils import (
@@ -115,10 +115,10 @@ def estimate_rotations(self):
115115
vijs, viis = self._global_J_sync(vijs, viis)
116116

117117
logger.info("Estimating third rows of rotation matrices.")
118-
vis = estimate_third_rows(vijs, viis)
118+
vis = _estimate_third_rows(vijs, viis)
119119

120120
logger.info("Estimating in-plane rotations and rotations matrices.")
121-
Ris = estimate_inplane_rotations(self, vis)
121+
Ris = _estimate_inplane_rotations(self, vis)
122122

123123
self.rotations = Ris
124124

@@ -349,8 +349,8 @@ def relative_rots_to_cl_indices(relative_rots, n_theta):
349349
c1s = np.array((-relative_rots[:, 1, 2], relative_rots[:, 0, 2])).T
350350
c2s = np.array((relative_rots[:, 2, 1], -relative_rots[:, 2, 0])).T
351351

352-
c1s = cl_angles_to_ind(c1s, n_theta)
353-
c2s = cl_angles_to_ind(c2s, n_theta)
352+
c1s = _cl_angles_to_ind(c1s, n_theta)
353+
c2s = _cl_angles_to_ind(c2s, n_theta)
354354

355355
inds = np.where(c1s >= n_theta // 2)
356356
c1s[inds] -= n_theta // 2
@@ -382,7 +382,7 @@ def generate_candidate_rots(n, equator_threshold, order, degree_res, seed):
382382
while counter < n:
383383
third_row = randn(3)
384384
third_row /= anorm(third_row, axes=(-1,))
385-
Ri_tilde = complete_third_row_to_rot(third_row)
385+
Ri_tilde = _complete_third_row_to_rot(third_row)
386386

387387
# Exclude candidates that represent equator images. Equator candidates
388388
# induce collinear self-common-lines, which always have perfect correlation.

src/aspire/abinitio/commonline_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
logger = logging.getLogger(__name__)
1919

2020

21-
def estimate_third_rows(vijs, viis):
21+
def _estimate_third_rows(vijs, viis):
2222
"""
2323
Find the third row of each rotation matrix given a collection of matrices
2424
representing the outer products of the third rows from each rotation matrix.
@@ -68,7 +68,7 @@ def estimate_third_rows(vijs, viis):
6868
return vis
6969

7070

71-
def estimate_inplane_rotations(cl_class, vis):
71+
def _estimate_inplane_rotations(cl_class, vis):
7272
"""
7373
Estimate the rotation matrices for each image by constructing arbitrary rotation matrices
7474
populated with the given third rows, vis, and then rotating by an appropriate in-plane rotation.
@@ -89,7 +89,7 @@ def estimate_inplane_rotations(cl_class, vis):
8989

9090
# Step 1: Construct all rotation matrices Ri_tildes whose third rows are equal to
9191
# the corresponding third rows vis.
92-
Ri_tildes = complete_third_row_to_rot(vis)
92+
Ri_tildes = _complete_third_row_to_rot(vis)
9393

9494
# Step 2: Construct all in-plane rotation matrices, R_theta_ijs.
9595
max_angle = (360 // order) * order
@@ -146,8 +146,8 @@ def estimate_inplane_rotations(cl_class, vis):
146146
c2s = np.array([[U[2, 1], -U[2, 0]] for U in Us])
147147

148148
# Convert from angles to indices.
149-
c1s = cl_angles_to_ind(c1s, n_theta)
150-
c2s = cl_angles_to_ind(c2s, n_theta)
149+
c1s = _cl_angles_to_ind(c1s, n_theta)
150+
c2s = _cl_angles_to_ind(c2s, n_theta)
151151

152152
# Perform correlation, corrs is shape n_shifts x len(theta_ijs).
153153
corrs = np.array(
@@ -197,7 +197,7 @@ def estimate_inplane_rotations(cl_class, vis):
197197
return Ris
198198

199199

200-
def complete_third_row_to_rot(r3):
200+
def _complete_third_row_to_rot(r3):
201201
"""
202202
Construct rotation matrices whose third rows are equal to the given row vectors.
203203
For vector r3 = [a, b, c], where [a, b, c] != [0, 0, 1], we return the matrix
@@ -246,7 +246,7 @@ def complete_third_row_to_rot(r3):
246246
return rots
247247

248248

249-
def cl_angles_to_ind(cl_angles, n_theta):
249+
def _cl_angles_to_ind(cl_angles, n_theta):
250250
thetas = np.arctan2(cl_angles[:, 1], cl_angles[:, 0])
251251

252252
# Shift from [-pi,pi] to [0,2*pi).

tests/test_orient_symmetric.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
CLSymmetryC2,
88
CLSymmetryC3C4,
99
CLSymmetryCn,
10-
cl_angles_to_ind,
11-
complete_third_row_to_rot,
12-
estimate_third_rows,
10+
_cl_angles_to_ind,
11+
_complete_third_row_to_rot,
12+
_estimate_third_rows,
1313
g_sync,
1414
)
1515
from aspire.abinitio.commonline_cn import MeanOuterProductEstimator
@@ -494,7 +494,7 @@ def test_estimate_third_rows(dtype):
494494

495495
# Estimate third rows from outer products.
496496
# Due to factorization of V, these might be negated third rows.
497-
vis = estimate_third_rows(vijs, viis)
497+
vis = _estimate_third_rows(vijs, viis)
498498

499499
# Check if all-close up to difference of sign
500500
ground_truth = np.sign(gt_vis[0, 0]) * gt_vis
@@ -512,7 +512,7 @@ def test_complete_third_row(dtype):
512512
r3[0] = np.array([0, 0, 1], dtype=dtype)
513513

514514
# Generate rotations.
515-
R = complete_third_row_to_rot(r3)
515+
R = _complete_third_row_to_rot(r3)
516516

517517
# Assert that first rotation is the identity matrix.
518518
assert np.allclose(R[0], np.eye(3, dtype=dtype))
@@ -643,6 +643,6 @@ def _gt_cl_c2(n_theta, rots_gt):
643643
U = Ri.T @ g @ Rj
644644
c1 = np.array([-U[1, 2], U[0, 2]])
645645
c2 = np.array([U[2, 1], -U[2, 0]])
646-
clmatrix_gt[idx, i, j] = cl_angles_to_ind(c1[np.newaxis, :], n_theta)
647-
clmatrix_gt[idx, j, i] = cl_angles_to_ind(c2[np.newaxis, :], n_theta)
646+
clmatrix_gt[idx, i, j] = _cl_angles_to_ind(c1[np.newaxis, :], n_theta)
647+
clmatrix_gt[idx, j, i] = _cl_angles_to_ind(c2[np.newaxis, :], n_theta)
648648
return clmatrix_gt

0 commit comments

Comments
 (0)