From 7514c2107fa8fe3ae757968a3ec14926ddba721f Mon Sep 17 00:00:00 2001 From: generatedunixname89002005307016 Date: Mon, 30 Sep 2024 15:54:51 -0700 Subject: [PATCH] Convert .pyre_configuration.local to fast by default architecture] [batch:44/100] [shard:2/N] [A] Reviewed By: MaggieMoss Differential Revision: D63644535 fbshipit-source-id: f4118078d10c24b1fd5c400659c5f3c70ae2c781 --- opensfm/actions/export_colmap.py | 2 ++ opensfm/actions/export_geocoords.py | 2 ++ opensfm/align.py | 4 ++++ opensfm/dataset.py | 2 ++ opensfm/feature_loading.py | 1 + opensfm/features_processing.py | 2 ++ opensfm/multiview.py | 11 ++++++++++- opensfm/pairs_selection.py | 2 ++ opensfm/reconstruction.py | 7 +++++++ opensfm/synthetic_data/synthetic_generator.py | 2 ++ opensfm/synthetic_data/synthetic_scene.py | 6 ++++++ opensfm/test/test_bundle.py | 5 ----- opensfm/test/test_dataset.py | 2 ++ opensfm/test/test_multiview.py | 1 - opensfm/test/test_triangulation.py | 1 + opensfm/tracking.py | 4 ++++ opensfm/transformations.py | 10 ++++++++++ 17 files changed, 57 insertions(+), 7 deletions(-) diff --git a/opensfm/actions/export_colmap.py b/opensfm/actions/export_colmap.py index c86e38fa9..a8b7a5ccb 100644 --- a/opensfm/actions/export_colmap.py +++ b/opensfm/actions/export_colmap.py @@ -185,11 +185,13 @@ def array_to_blob(array) -> bytes: if IS_PYTHON3: return array.tobytes() else: + # pyre-fixme[16]: Module `numpy` has no attribute `getbuffer`. return np.getbuffer(array) def blob_to_array(blob, dtype, shape: Tuple[int] = (-1,)): if IS_PYTHON3: + # pyre-fixme[20]: Argument `sep` expected. return np.fromstring(blob, dtype=dtype).reshape(*shape) else: return np.frombuffer(blob, dtype=dtype).reshape(*shape) diff --git a/opensfm/actions/export_geocoords.py b/opensfm/actions/export_geocoords.py index aad9d7910..42ab9df76 100644 --- a/opensfm/actions/export_geocoords.py +++ b/opensfm/actions/export_geocoords.py @@ -146,7 +146,9 @@ def _transform_dense_point_cloud( fout.write(line) else: x, y, z, nx, ny, nz, red, green, blue = line.split() + # pyre-fixme[6]: For 2nd argument expected `Union[Sequence[Sequen... x, y, z = np.dot(A, map(float, [x, y, z])) + b + # pyre-fixme[6]: For 2nd argument expected `Union[Sequence[Sequen... nx, ny, nz = np.dot(A, map(float, [nx, ny, nz])) fout.write( "{} {} {} {} {} {} {} {} {}\n".format( diff --git a/opensfm/align.py b/opensfm/align.py index 48d7d60c3..f07aa004f 100644 --- a/opensfm/align.py +++ b/opensfm/align.py @@ -282,7 +282,11 @@ def compute_orientation_prior_similarity( max_scale = 1000 current_scale = np.linalg.norm(b) if two_shots and current_scale > max_scale: + # pyre-fixme[58]: `/` is not supported for operand types `int` and + # `floating[typing.Any]`. b = max_scale * b / current_scale + # pyre-fixme[58]: `/` is not supported for operand types `int` and + # `floating[typing.Any]`. s = max_scale / current_scale else: try: diff --git a/opensfm/dataset.py b/opensfm/dataset.py index 12af6a344..fa96fc6fb 100644 --- a/opensfm/dataset.py +++ b/opensfm/dataset.py @@ -334,6 +334,8 @@ def load_words(self, image: str) -> np.ndarray: def save_words(self, image: str, words: np.ndarray) -> None: with self.io_handler.open(self._words_file(image), "wb") as f: + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsWrite[bytes], + # PathLike[str], str]` but got `IO[typing.Any]`. np.savez_compressed(f, words=words.astype(np.uint16)) def _matches_path(self) -> str: diff --git a/opensfm/feature_loading.py b/opensfm/feature_loading.py index 7ff3d4934..1f3c63a69 100644 --- a/opensfm/feature_loading.py +++ b/opensfm/feature_loading.py @@ -133,6 +133,7 @@ def _add_segmentation_in_descriptor( return features desc_augmented = np.concatenate( + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[ty... ( features.descriptors, (np.array([segmentation]).T).astype(np.float32), diff --git a/opensfm/features_processing.py b/opensfm/features_processing.py index 94889eac9..671facfde 100644 --- a/opensfm/features_processing.py +++ b/opensfm/features_processing.py @@ -219,6 +219,8 @@ def bake_segmentation( new_width=new_width, new_height=new_height, ).astype(int) + # pyre-fixme[6]: For 2nd argument expected `None` but got + # `ndarray[typing.Any, typing.Any]`. panoptic_data[i] = p_data[ps[:, 1], ps[:, 0]] return tuple(panoptic_data) diff --git a/opensfm/multiview.py b/opensfm/multiview.py index e164fd1f0..97b7e2b18 100644 --- a/opensfm/multiview.py +++ b/opensfm/multiview.py @@ -182,6 +182,9 @@ def ransac(kernel: Any, threshold: float) -> TRansacSolution: max_iterations, ransac_max_iterations(kernel, best_inliers, 0.01) ) i += 1 + # pyre-fixme[7]: Expected `Tuple[ndarray[typing.Any, typing.Any], + # ndarray[typing.Any, typing.Any], float]` but got `Tuple[typing.Any, + # Union[List[typing.Any], ndarray[typing.Any, dtype[typing.Any]]], typing.Any]`. return best_model, best_inliers, best_error @@ -211,6 +214,8 @@ def num_samples(self) -> int: def fit(self, samples: np.ndarray) -> List[float]: x = self.x[samples[0]] y = self.y[samples[0]] + # pyre-fixme[7]: Expected `List[float]` but got `List[ndarray[typing.Any, + # dtype[typing.Any]]]`. return [y / x] def evaluate(self, model: np.ndarray) -> np.ndarray: @@ -416,6 +421,9 @@ def fit_similarity_transform( errors = np.sqrt(np.sum((p2h.T - np.dot(best_T, p1h.T)) ** 2, axis=0)) best_inliers = np.argwhere(errors < threshold)[:, 0] + # pyre-fixme[7]: Expected `Tuple[ndarray[typing.Any, typing.Any], + # ndarray[typing.Any, typing.Any]]` but got `Tuple[ndarray[typing.Any, + # typing.Any], Union[List[typing.Any], ndarray[typing.Any, dtype[typing.Any]]]]`. return best_T, best_inliers @@ -453,7 +461,9 @@ def focal_from_homography(H: np.ndarray) -> np.ndarray: def R_from_homography( H: np.ndarray, f1: np.ndarray, f2: np.ndarray ) -> Optional[np.ndarray]: + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[typing.Any... K1 = np.diag([f1, f1, 1]) + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[typing.Any... K2 = np.diag([f2, f2, 1]) K2inv = np.linalg.inv(K2) R = K2inv.dot(H).dot(K1) @@ -464,7 +474,6 @@ 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) diff --git a/opensfm/pairs_selection.py b/opensfm/pairs_selection.py index 214e251b3..2bae00157 100644 --- a/opensfm/pairs_selection.py +++ b/opensfm/pairs_selection.py @@ -472,6 +472,8 @@ def construct_pairs( order = np.argsort(distances) if enforce_other_cameras: pairs.update( + # pyre-fixme[6]: For 4th argument expected `List[int]` but got + # `ndarray[typing.Any, dtype[typing.Any]]`. pairs_from_neighbors(im, exifs, distances, order, other, max_neighbors) ) else: diff --git a/opensfm/reconstruction.py b/opensfm/reconstruction.py index ad242f9ee..1c07b9f62 100644 --- a/opensfm/reconstruction.py +++ b/opensfm/reconstruction.py @@ -284,6 +284,8 @@ def _two_view_reconstruction_inliers( ) -> List[int]: """Returns indices of matches that can be triangulated.""" ok = matching.compute_inliers_bearings(b1, b2, R, t, threshold) + # pyre-fixme[7]: Expected `List[int]` but got `ndarray[typing.Any, + # dtype[typing.Any]]`. return np.nonzero(ok)[0] @@ -318,6 +320,7 @@ def two_view_reconstruction_plane_based( inliers = _two_view_reconstruction_inliers(b1, b2, R.T, -R.T.dot(t), threshold) motion_inliers.append(inliers) + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[typing.Any... best = np.argmax(map(len, motion_inliers)) R, t, n, d = motions[best] inliers = motion_inliers[best] @@ -370,6 +373,8 @@ def _two_view_rotation_inliers( ) -> List[int]: br2 = R.dot(b2.T).T ok = np.linalg.norm(br2 - b1, axis=1) < threshold + # pyre-fixme[7]: Expected `List[int]` but got `ndarray[typing.Any, + # dtype[typing.Any]]`. return np.nonzero(ok)[0] @@ -1048,6 +1053,8 @@ def triangulate_dlt( if len(Rts) >= 2: e, X = pygeometry.triangulate_bearings_dlt( + # pyre-fixme[6]: For 1st argument expected `List[ndarray[typing.Any, + # typing.Any]]` but got `ndarray[typing.Any, dtype[typing.Any]]`. np.asarray(Rts), np.asarray(bs), reproj_threshold, diff --git a/opensfm/synthetic_data/synthetic_generator.py b/opensfm/synthetic_data/synthetic_generator.py index 0dd20c840..f856af382 100644 --- a/opensfm/synthetic_data/synthetic_generator.py +++ b/opensfm/synthetic_data/synthetic_generator.py @@ -201,6 +201,8 @@ def _gps_dop(shot: pymap.Shot) -> float: ): pose = rig_instance.pose.get_origin() if previous_pose is not None: + # pyre-fixme[58]: `+` is not supported for operand types `int` and + # `floating[typing.Any]`. previous_time += np.linalg.norm(pose - previous_pose) / speed_ms previous_pose = pose for shot_id in rig_instance.shots: diff --git a/opensfm/synthetic_data/synthetic_scene.py b/opensfm/synthetic_data/synthetic_scene.py index f8fcc8140..6dcae3206 100644 --- a/opensfm/synthetic_data/synthetic_scene.py +++ b/opensfm/synthetic_data/synthetic_scene.py @@ -177,9 +177,11 @@ def __init__( def combine(self, other_scene: "SyntheticStreetScene") -> "SyntheticStreetScene": combined_scene = SyntheticStreetScene(None) combined_scene.wall_points = np.concatenate( + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[ty... (self.wall_points, other_scene.wall_points) ) combined_scene.floor_points = np.concatenate( + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[ty... (self.floor_points, other_scene.floor_points) ) combined_scene.cameras = self.cameras + other_scene.cameras @@ -400,7 +402,11 @@ def get_reconstruction(self) -> types.Reconstruction: wall_color = [10, 90, 130] return sg.create_reconstruction( + # pyre-fixme[6]: For 1st argument expected `List[ndarray[typing.Any, + # typing.Any]]` but got `ndarray[typing.Any, dtype[typing.Any]]`. points=np.asarray([self.floor_points, self.wall_points], dtype=object), + # pyre-fixme[6]: For 2nd argument expected `List[ndarray[typing.Any, + # typing.Any]]` but got `ndarray[typing.Any, dtype[typing.Any]]`. colors=np.asarray([floor_color, wall_color]), cameras=self.cameras, shot_ids=self.shot_ids, diff --git a/opensfm/test/test_bundle.py b/opensfm/test/test_bundle.py index d3d499560..27aff4d8e 100644 --- a/opensfm/test/test_bundle.py +++ b/opensfm/test/test_bundle.py @@ -108,18 +108,13 @@ 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]`. diff --git a/opensfm/test/test_dataset.py b/opensfm/test/test_dataset.py index 142887c82..17db15e38 100644 --- a/opensfm/test/test_dataset.py +++ b/opensfm/test/test_dataset.py @@ -26,6 +26,7 @@ def test_dataset_load_features_sift(tmpdir) -> None: after = data.load_features(image) assert after assert np.allclose(points, after.points) + # pyre-fixme[6]: For 2nd argument expected `Union[_SupportsArray[dtype[typing.Any... assert np.allclose(descriptors, after.descriptors) assert np.allclose(colors, after.colors) semantic = after.semantic @@ -34,4 +35,5 @@ def test_dataset_load_features_sift(tmpdir) -> None: segmentations, semantic.segmentation, ) + # pyre-fixme[6]: For 2nd argument expected `Union[_SupportsArray[dtype[typing.Any... assert np.allclose(instances, semantic.instances) diff --git a/opensfm/test/test_multiview.py b/opensfm/test/test_multiview.py index 8edc8cc8b..6911ad26c 100644 --- a/opensfm/test/test_multiview.py +++ b/opensfm/test/test_multiview.py @@ -21,7 +21,6 @@ def test_motion_from_plane_homography() -> None: 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 = [] diff --git a/opensfm/test/test_triangulation.py b/opensfm/test/test_triangulation.py index 734be5d6c..ee9f8ceaf 100644 --- a/opensfm/test/test_triangulation.py +++ b/opensfm/test/test_triangulation.py @@ -50,6 +50,7 @@ def test_track_triangulator_spherical() -> None: def unit_vector(x: object) -> np.ndarray: + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[typing.Any... return np.array(x) / np.linalg.norm(x) diff --git a/opensfm/tracking.py b/opensfm/tracking.py index c1b79798c..eb897855d 100644 --- a/opensfm/tracking.py +++ b/opensfm/tracking.py @@ -98,6 +98,10 @@ def create_tracks_manager( instances[image][featureid] if image in instances else NO_VALUE, ) obs = pymap.Observation( + # pyre-fixme[6]: For 8th argument expected `int` but got + # `Union[ndarray[typing.Any, typing.Any], int]`. + # pyre-fixme[6]: For 9th argument expected `int` but got + # `Union[ndarray[typing.Any, typing.Any], int]`. x, y, s, int(r), int(g), int(b), featureid, segmentation, instance ) tracks_manager.add_observation(image, str(track_id), obs) diff --git a/opensfm/transformations.py b/opensfm/transformations.py index 071915b64..dfd2d142d 100644 --- a/opensfm/transformations.py +++ b/opensfm/transformations.py @@ -411,6 +411,7 @@ def scale_matrix( """ if direction is None: # uniform scaling + # pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[typing... M = numpy.diag([factor, factor, factor, 1.0]) if origin is not None: M[:3, 3] = origin[:3] @@ -466,6 +467,10 @@ def scale_from_matrix( raise ValueError("no eigenvector corresponding to eigenvalue 1") origin = numpy.real(V[:, i[-1]]).squeeze() origin /= origin[3] + # pyre-fixme[7]: Expected `Tuple[ndarray[typing.Any, typing.Any], + # ndarray[typing.Any, typing.Any], ndarray[typing.Any, typing.Any]]` but got + # `Tuple[typing.Any, ndarray[typing.Any, dtype[typing.Any]], + # Optional[ndarray[typing.Any, dtype[typing.Any]]]]`. return factor, origin, direction @@ -1663,10 +1668,14 @@ def vector_norm( data *= data out = numpy.atleast_1d(numpy.sum(data, axis=axis)) numpy.sqrt(out, out) + # pyre-fixme[7]: Expected `float` but got `ndarray[typing.Any, + # dtype[typing.Any]]`. return out else: data *= data numpy.sum(data, axis=axis, out=out) + # pyre-fixme[7]: Expected `float` but got `ndarray[typing.Any, + # dtype[typing.Any]]`. return numpy.sqrt(out, out) @@ -1832,6 +1841,7 @@ def is_same_transform(matrix0: numpy.ndarray, matrix1: numpy.ndarray) -> numpy.n matrix0 /= matrix0[3, 3] matrix1 = numpy.array(matrix1, dtype=numpy.float64, copy=True) matrix1 /= matrix1[3, 3] + # pyre-fixme[7]: Expected `ndarray[typing.Any, typing.Any]` but got `bool`. return numpy.allclose(matrix0, matrix1)