Skip to content

Commit 36034bb

Browse files
generatedunixname89002005307016meta-codesync[bot]
authored andcommitted
Remove unused type error suppressions - mapillary
Summary: This diff was automatically generated by the Pyre per-target upgrade tool. It removes `# pyre-fixme` or `pyrefly: ignore` comments that are no longer needed because the underlying type errors have been resolved. Note that it will also aim to ensure type checking runs cleanly, and will add suppressions to existing type errors. #pyreupgrade Differential Revision: D116358864 fbshipit-source-id: aeb900f1c8546a7df8110f329c8a938dfcade2b8
1 parent 238744c commit 36034bb

23 files changed

Lines changed: 10 additions & 91 deletions

‎annotation_gui_gcp/run_ba.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,13 @@ def bundle_with_fixed_images(
287287
for shot in reconstruction.shots.values():
288288
r = shot.pose.rotation
289289
t = shot.pose.translation
290-
# pyrefly: ignore [missing-attribute]
291290
ba.add_shot(shot.id, shot.camera.id, r, t, shot.id in fixed_images)
292291

293292
for point in reconstruction.points.values():
294293
ba.add_point(point.id, point.coordinates, False)
295294
ba.add_point_prior(
296-
# pyre-ignore[6]: Pyre doesn't recognize numpy.ndarray as numpy.typing.ArrayLike
297295
point.id,
298296
point.coordinates,
299-
# pyre-ignore[6]: Pyre doesn't recognize numpy.ndarray as numpy.typing.ArrayLike
300297
np.array([100.0, 100.0, 100.0]),
301298
False,
302299
)
@@ -340,7 +337,6 @@ def bundle_with_fixed_images(
340337
orec._get_camera_from_bundle(ba, camera)
341338

342339
for shot in reconstruction.shots.values():
343-
# pyrefly: ignore [missing-attribute]
344340
s = ba.get_shot(shot.id)
345341
shot.pose.rotation = [s.r[0], s.r[1], s.r[2]]
346342
shot.pose.translation = [s.t[0], s.t[1], s.t[2]]
@@ -544,7 +540,6 @@ def align_3d_annotations_to_reconstruction(
544540
except ValueError:
545541
logger.warning(f"Could not align reconstruction with {model_id}")
546542

547-
# pyrefly: ignore [unbound-name]
548543
return gcp_reprojections, {"s": s.tolist(), "A": A.tolist(), "b": b.tolist()}
549544

550545

‎bin/import_colmap.py‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,35 +62,27 @@ def compute_and_save_undistorted_reconstruction(
6262
reconstruction, tracks_manager, data, udata
6363
):
6464
image_format = data.config["undistorted_image_format"]
65-
# pyrefly: ignore [missing-attribute]
6665
urec = types.Reconstruction()
67-
# pyrefly: ignore [missing-attribute]
6866
utracks_manager = pymap.TracksManager()
6967
undistorted_shots = []
7068
for shot in reconstruction.shots.values():
7169
if shot.camera.projection_type == "perspective":
72-
# pyrefly: ignore [missing-attribute]
7370
ucamera = osfm_u.perspective_camera_from_perspective(shot.camera)
7471
elif shot.camera.projection_type == "brown":
75-
# pyrefly: ignore [missing-attribute]
7672
ucamera = osfm_u.perspective_camera_from_brown(shot.camera)
7773
elif shot.camera.projection_type == "fisheye":
78-
# pyrefly: ignore [missing-attribute]
7974
ucamera = osfm_u.perspective_camera_from_fisheye(shot.camera)
8075
else:
8176
raise ValueError
8277
urec.add_camera(ucamera)
83-
# pyrefly: ignore [missing-attribute]
8478
ushot = osfm_u.get_shot_with_different_camera(urec, shot, image_format)
8579
if tracks_manager:
86-
# pyrefly: ignore [missing-attribute]
8780
osfm_u.add_subshot_tracks(tracks_manager, utracks_manager, shot, ushot)
8881
undistorted_shots.append(ushot)
8982

9083
image = data.load_image(shot.id, unchanged=True, anydepth=True)
9184
if image is not None:
9285
max_size = data.config["undistorted_image_max_size"]
93-
# pyrefly: ignore [missing-attribute]
9486
undistorted = osfm_u.undistort_image(
9587
shot, undistorted_shots, image, cv2.INTER_AREA, max_size
9688
)
@@ -130,7 +122,6 @@ def import_cameras_images(db, data):
130122
cameras = {}
131123
for row in cursor:
132124
camera_id, camera_model_id, width, height, prior_focal, params = row
133-
# pyrefly: ignore [no-matching-overload]
134125
params = np.fromstring(params, dtype=np.double)
135126
cam = cam_from_colmap_params(
136127
camera_model_id, width, height, params, prior_focal
@@ -197,15 +188,13 @@ def import_features(db, data, image_map, camera_map):
197188
filename, camera_id = image_map[image_id]
198189
cam = camera_map[camera_id]
199190

200-
# pyrefly: ignore [no-matching-overload]
201191
arr = np.fromstring(arr, dtype=np.float32).reshape((n_rows, n_cols))
202192

203193
rgb = data.load_image(filename).astype(np.float32)
204194
xc = np.clip(arr[:, 1].astype(int), 0, rgb.shape[0] - 1)
205195
yc = np.clip(arr[:, 0].astype(int), 0, rgb.shape[1] - 1)
206196
colors[image_id] = rgb[xc, yc, :]
207197

208-
# pyrefly: ignore [missing-attribute]
209198
arr[:, :2] = features.normalized_image_coordinates(
210199
arr[:, :2], cam.width, cam.height
211200
)
@@ -227,10 +216,8 @@ def import_features(db, data, image_map, camera_map):
227216
for row in cursor:
228217
image_id, n_rows, n_cols, arr = row
229218
filename, _ = image_map[image_id]
230-
# pyrefly: ignore [no-matching-overload]
231219
descriptors = np.fromstring(arr, dtype=np.uint8).reshape((n_rows, n_cols))
232220
kp = keypoints[image_id]
233-
# pyrefly: ignore [missing-attribute]
234221
features_data = features.FeaturesData(kp, descriptors, colors[image_id], None)
235222
data.save_features(filename, features_data)
236223

@@ -249,7 +236,6 @@ def import_matches(db, data, image_map):
249236

250237
for row in cursor:
251238
pair_id = row[0]
252-
# pyrefly: ignore [no-matching-overload]
253239
inlier_matches = np.fromstring(row[1], dtype=np.uint32).reshape(-1, 2)
254240
image_id1, image_id2 = pair_id_to_image_ids(pair_id)
255241
image_name1 = image_map[image_id1][0]
@@ -294,13 +280,10 @@ def cam_from_colmap_params(camera_model_id, width, height, params, prior_focal=1
294280
normalizer = max(width, height)
295281
focal = params[0] / normalizer if prior_focal else 0.85
296282
if projection_type == "perspective":
297-
# pyrefly: ignore [missing-attribute]
298283
cam = pygeometry.Camera.create_perspective(focal, params[3], params[4])
299284
elif projection_type == "pinhole":
300-
# pyrefly: ignore [missing-attribute]
301285
cam = pygeometry.Camera.create_perspective(focal, 0, 0)
302286
else: # projection_type == 'fisheye'
303-
# pyrefly: ignore [missing-attribute]
304287
cam = pygeometry.Camera.create_fisheye(focal, params[3], 0)
305288
cam.width = width
306289
cam.height = height
@@ -388,7 +371,6 @@ def import_images_reconstruction(path_images, keypoints, rec):
388371
Read images.bin, building shots and tracks graph
389372
"""
390373
logger.info("Importing images from {}".format(path_images))
391-
# pyrefly: ignore [missing-attribute]
392374
tracks_manager = pymap.TracksManager()
393375
image_ix_to_shot_id = {}
394376
with open(path_images, "rb") as f:
@@ -413,7 +395,6 @@ def import_images_reconstruction(path_images, keypoints, rec):
413395
q /= np.linalg.norm(q)
414396
t = np.array([t0, t1, t2])
415397

416-
# pyrefly: ignore [missing-attribute]
417398
pose = pygeometry.Pose(rotation=quaternion_to_angle_axis(q), translation=t)
418399
shot = rec.create_shot(filename, str(camera_id), pose)
419400
image_ix_to_shot_id[image_ix] = shot.id
@@ -426,7 +407,6 @@ def import_images_reconstruction(path_images, keypoints, rec):
426407
if point3d_id != np.iinfo(np.uint64).max:
427408
kp = keypoints[image_id][point2d_ix]
428409
r, g, b = rec.points[str(point3d_id)].color
429-
# pyrefly: ignore [missing-attribute]
430410
obs = pymap.Observation(
431411
x,
432412
y,
@@ -492,7 +472,6 @@ def project_pointcloud_save_depth(udata, urec, points, shot_id, max_sz):
492472

493473
points_2d = shot.project_many(points)
494474

495-
# pyrefly: ignore [missing-attribute]
496475
pixel_coords = features.denormalized_image_coordinates(points_2d, w, h).astype(int)
497476
# Filter out points that fall out of the image
498477
# <<< aren't we supposed to have points that are visible from this image only??!?!
@@ -570,7 +549,6 @@ def main():
570549
):
571550
os.symlink(p_db.parent.parent / "config.yaml", export_folder / "config.yaml")
572551

573-
# pyrefly: ignore [missing-attribute]
574552
data = dataset.DataSet(export_folder)
575553
db = sqlite3.connect(p_db.as_posix())
576554
camera_map, image_map = import_cameras_images(db, data)
@@ -588,7 +566,6 @@ def main():
588566
rec_points = p_db.parent / "points3D.bin"
589567
rec_images = p_db.parent / "images.bin"
590568
if rec_cameras.exists() and rec_images.exists() and rec_points.exists():
591-
# pyrefly: ignore [missing-attribute]
592569
reconstruction = types.Reconstruction()
593570
import_cameras_reconstruction(rec_cameras, reconstruction)
594571
import_points_reconstruction(rec_points, reconstruction)
@@ -600,7 +577,6 @@ def main():
600577
data.save_tracks_manager(tracks_manager)
601578

602579
# Save undistorted reconstruction as well
603-
# pyrefly: ignore [missing-attribute]
604580
udata = dataset.UndistortedDataSet(data, io_handler=data.io_handler)
605581
urec = compute_and_save_undistorted_reconstruction(
606582
reconstruction, tracks_manager, data, udata
@@ -612,7 +588,6 @@ def main():
612588
rec_cameras = p_db.parent / "dense/sparse/cameras.bin"
613589
rec_images = p_db.parent / "dense/sparse/images.bin"
614590
rec_points = p_db.parent / "points3D.bin"
615-
# pyrefly: ignore [missing-attribute]
616591
reconstruction = types.Reconstruction()
617592
import_cameras_reconstruction(rec_cameras, reconstruction)
618593
import_points_reconstruction(rec_points, reconstruction)

‎bin/plot_matches.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def plot_graph(data) -> None:
5555
o2 = np.array(
5656
reference.to_topocentric(gps2["latitude"], gps2["longitude"], 0)[:2]
5757
)
58-
# pyrefly: ignore [no-matching-overload]
5958
c = max(0, min(1.0, 1 - (edge - lowest) / (highest - lowest)))
6059
pl.plot([o1[0], o2[0]], [o1[1], o2[1]], linestyle="-", color=cmap(c))
6160

‎opensfm/actions/export_colmap.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,12 @@ def export_matches(
467467
pair_matches = matches_per_pair.setdefault(pair_key, {})
468468
for match in image_matches:
469469
if image1 < image2:
470-
# pyrefly: ignore [missing-attribute]
471470
pair_matches.update({(match[0], match[1]): True})
472471
else:
473-
# pyrefly: ignore [missing-attribute]
474472
pair_matches.update({(match[1], match[0]): True})
475473

476474
data.config["robust_matching_threshold"] = 8
477475
for pair, matches in matches_per_pair.items():
478-
# pyrefly: ignore [not-iterable]
479476
matches_numpy = np.array([np.array([m[0], m[1]]) for m in matches])
480477
if len(matches_numpy) < 10:
481478
continue

‎opensfm/actions/export_geocoords.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ def _transform_dense_point_cloud(
150150
fout.write(line)
151151
else:
152152
x, y, z, nx, ny, nz, red, green, blue = line.split()
153-
# pyre-fixme[6]: For 2nd argument expected `Union[Sequence[Sequen...
154153
x, y, z = np.dot(A, map(float, [x, y, z])) + b
155-
# pyre-fixme[6]: For 2nd argument expected `Union[Sequence[Sequen...
156154
nx, ny, nz = np.dot(A, map(float, [nx, ny, nz]))
157155
fout.write(
158156
"{} {} {} {} {} {} {} {} {}\n".format(

‎opensfm/actions/extend_reconstruction.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run_dataset(data: DataSetBase, input: Optional[str], output: Optional[str])
2828
gcp,
2929
)
3030
rec_report["num_remaining_images"] = len(remaining_images)
31-
# pyrefly: ignore [no-matching-overload, unsupported-operation]
31+
# pyrefly: ignore [unsupported-operation]
3232
report["not_reconstructed_images"] = list(remaining_images)
3333
data.save_reconstruction([rec], output)
3434
data.save_report(io.json_dumps(report), "reconstruction.json")

‎opensfm/dataset.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ def load_matches(self, image: str) -> Dict[str, NDArray]:
355355
class MatchingUnpickler(pickle.Unpickler):
356356
# Handle both numpy <2.0 (np.core) and numpy >=2.0 (np._core)
357357
_multiarray: ModuleType = (
358-
# pyrefly: ignore [missing-attribute]
359358
np.core.multiarray if hasattr(np, "core") else np._core.multiarray
360359
)
361360
modules_map: dict[str, ModuleType] = {

‎opensfm/feature_loading.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ def _add_segmentation_in_descriptor(
136136
if segmentation is None:
137137
return features
138138

139-
# pyrefly: ignore [no-matching-overload]
140139
desc_augmented = np.concatenate(
141-
# pyre-fixme[6]: For 1st argument expected `Union[_SupportsArray[dtype[ty...
142140
(
143141
features.descriptors,
144142
(np.array([segmentation]).T).astype(np.float32),

‎opensfm/features_processing.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ def bake_segmentation(
249249
new_width=new_width,
250250
new_height=new_height,
251251
).astype(int)
252-
# pyre-fixme[6]: For 2nd argument expected `None` but got
253252
# `ndarray[typing.Any, typing.Any]`.
254253
panoptic_data[i] = p_data[ps[:, 1], ps[:, 0]]
255254
# pyrefly: ignore [bad-return]

‎opensfm/io.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ def camera_from_vector(
713713
elif projection_type == "brown":
714714
fx, fy, cx, cy, k1, k2, p1, p2, k3 = parameters
715715
camera = pygeometry.Camera.create_brown(
716-
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
717716
fx,
718717
fy / fx,
719718
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
@@ -727,7 +726,6 @@ def camera_from_vector(
727726
elif projection_type == "fisheye_opencv":
728727
fx, fy, cx, cy, k1, k2, k3, k4 = parameters
729728
camera = pygeometry.Camera.create_fisheye_opencv(
730-
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
731729
fx,
732730
fy / fx,
733731
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
@@ -738,7 +736,6 @@ def camera_from_vector(
738736
elif projection_type == "fisheye62":
739737
fx, fy, cx, cy, k1, k2, k3, k4, k5, k6, p1, p2 = parameters
740738
camera = pygeometry.Camera.create_fisheye62(
741-
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
742739
fx,
743740
fy / fx,
744741
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
@@ -759,7 +756,6 @@ def camera_from_vector(
759756
elif projection_type == "radial":
760757
fx, fy, cx, cy, k1, k2 = parameters
761758
camera = pygeometry.Camera.create_radial(
762-
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
763759
fx,
764760
fy / fx,
765761
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
@@ -770,7 +766,6 @@ def camera_from_vector(
770766
elif projection_type == "simple_radial":
771767
fx, fy, cx, cy, k1 = parameters
772768
camera = pygeometry.Camera.create_simple_radial(
773-
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.
774769
fx,
775770
fy / fx,
776771
# pyre-fixme[6]: opensfm pybind / numpy stubs gap — runtime ok.

0 commit comments

Comments
 (0)