Skip to content

Commit

Permalink
upgrade pyre version in fbcode/mapillary - batch 1
Browse files Browse the repository at this point in the history
Differential Revision: D60994471

fbshipit-source-id: 9fdcfea8f07fc6b2c711a03ec1c919d37623d852
  • Loading branch information
generatedunixname89002005307016 authored and facebook-github-bot committed Aug 9, 2024
1 parent f953531 commit ef872b2
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions opensfm/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ def extract_features_hahog(
uchar_scaling = 512

if config["hahog_normalize_to_uchar"]:
# pyre-fixme[16]: `int` has no attribute `clip`.
desc = (uchar_scaling * desc).clip(0, 255).round()

logger.debug("Found {0} points in {1}s".format(len(points), time.time() - t))
Expand Down
1 change: 1 addition & 0 deletions opensfm/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ def reconstruction_to_ply(
for depth in np.linspace(0, 2, 10):
p = o + depth * R[axis]
s = "{} {} {} {} {} {}".format(
# pyre-fixme[16]: `int` has no attribute `__getitem__`.
p[0], p[1], p[2], int(c[0]), int(c[1]), int(c[2])
)
if point_num_views:
Expand Down
1 change: 1 addition & 0 deletions opensfm/multiview.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ def R_from_homography(
def project_to_rotation_matrix(A: np.ndarray) -> Optional[np.ndarray]:
try:
u, d, vt = np.linalg.svd(A)
# pyre-fixme[16]: Module `linalg` has no attribute `LinAlgError`.
except np.linalg.linalg.LinAlgError:
return None
return u.dot(vt)
Expand Down
2 changes: 2 additions & 0 deletions opensfm/synthetic_data/synthetic_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def _gps_dop(shot: pymap.Shot) -> float:
origin = shot.pose.get_origin()

if causal_gps_noise:
# pyre-fixme[61]: `perturbations_2d` is undefined, or not always
# defined.
gps_perturbation = [perturbations_2d[j][i] for j in range(2)] + [0]
else:
gps_noise = _gps_dop(shot)
Expand Down
13 changes: 13 additions & 0 deletions opensfm/test/test_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,27 @@ def test_bundle_projection_fixed_internals(scene_synthetic) -> None:
color = g_obs["feature_color"]
pt = g_obs["feature"]
obs = pymap.Observation(
# pyre-fixme[6]: For 1st argument expected `str` but got `int`.
pt[0],
# pyre-fixme[6]: For 1st argument expected `str` but got `int`.
pt[1],
# pyre-fixme[6]: For 3rd argument expected `float` but got
# `Dict[str, typing.Any]`.
g_obs["feature_scale"],
# pyre-fixme[6]: For 1st argument expected `str` but got `int`.
color[0],
# pyre-fixme[6]: For 1st argument expected `str` but got `int`.
color[1],
# pyre-fixme[6]: For 1st argument expected `str` but got `int`.
color[2],
# pyre-fixme[6]: For 7th argument expected `int` but got
# `Dict[str, typing.Any]`.
g_obs["feature_id"],
# pyre-fixme[6]: For 8th argument expected `int` but got
# `Dict[str, typing.Any]`.
g_obs["feature_segmentation"],
# pyre-fixme[6]: For 9th argument expected `int` but got
# `Dict[str, typing.Any]`.
g_obs["feature_instance"],
)
reference.map.add_observation(shot_id, point_id, obs)
Expand Down
3 changes: 3 additions & 0 deletions opensfm/test/test_multiview.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ def normalized(x: np.ndarray) -> np.ndarray:

def test_motion_from_plane_homography() -> None:
R = tf.random_rotation_matrix()[:3, :3]
# pyre-fixme[6]: For 1st argument expected `ndarray` but got `int`.
t = normalized(2 * np.random.rand(3) - 1)
# pyre-fixme[6]: For 1st argument expected `ndarray` but got `int`.
n = normalized(2 * np.random.rand(3) - 1)
d = 2 * np.random.rand() - 1
scale = 2 * np.random.rand() - 1
H = scale * (d * R - np.outer(t, n))

# pyre-fixme[6]: For 1st argument expected `ndarray` but got `int`.
motions = multiview.motion_from_plane_homography(H)
assert motions is not None
goodness = []
Expand Down
1 change: 1 addition & 0 deletions opensfm/test/test_robust.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def test_outliers_relative_pose_ransac(pairs_and_their_E) -> None:
inliers_count = (1 - ratio_outliers) * len(points)
assert np.isclose(len(result.inliers_indices), inliers_count, rtol=tolerance)

# pyre-fixme[61]: `expected` is undefined, or not always defined.
assert np.linalg.norm(expected - result.lo_model, ord="fro") < 16e-2


Expand Down

0 comments on commit ef872b2

Please sign in to comment.