Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
rev: v0.9.1
hooks:
# Run the linter.
- id: ruff
Expand Down
22 changes: 6 additions & 16 deletions examples/devkit_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@
"plt.rcParams[\"figure.figsize\"] = [20, 10]\n",
"\n",
"# import the ZOD DevKit\n",
"from zod import ZodFrames\n",
"from zod import ZodSequences\n",
"\n",
"# import default constants\n",
"import zod.constants as constants\n",
"from zod.constants import Camera, Lidar, Anonymization, AnnotationProject\n",
"from zod import ZodFrames, ZodSequences\n",
"from zod.constants import AnnotationProject, Anonymization, Camera, Lidar\n",
"\n",
"# import useful data classes\n",
"from zod.data_classes import LidarData\n",
Expand Down Expand Up @@ -427,9 +425,7 @@
"# but for this we also need the calibrations of the sensor\n",
"calibrations = zod_frame.calibration\n",
"assert annotation_3d is not None\n",
"image = overlay_object_3d_box_on_image(\n",
" image, annotation_3d, calibrations, color=(255, 0, 0), line_thickness=10\n",
")\n",
"image = overlay_object_3d_box_on_image(image, annotation_3d, calibrations, color=(255, 0, 0), line_thickness=10)\n",
"\n",
"plt.figure()\n",
"plt.axis(\"off\")\n",
Expand Down Expand Up @@ -570,12 +566,8 @@
" np.hstack((pcd.points, pcd.intensity[:, None])),\n",
" (\n",
" np.array([obj.name for obj in object_annotations if obj.box3d]),\n",
" np.concatenate(\n",
" [obj.box3d.center[None, :] for obj in object_annotations if obj.box3d], axis=0\n",
" ),\n",
" np.concatenate(\n",
" [obj.box3d.size[None, :] for obj in object_annotations if obj.box3d], axis=0\n",
" ),\n",
" np.concatenate([obj.box3d.center[None, :] for obj in object_annotations if obj.box3d], axis=0),\n",
" np.concatenate([obj.box3d.size[None, :] for obj in object_annotations if obj.box3d], axis=0),\n",
" np.array([obj.box3d.orientation for obj in object_annotations if obj.box3d]),\n",
" ),\n",
")"
Expand Down Expand Up @@ -612,9 +604,7 @@
"plt.show()\n",
"\n",
"# Plot aggregated Lidar point cloud\n",
"aggregated_lidar = zod_frame.get_aggregated_lidar(\n",
" num_before=10, num_after=0, timestamp=image_timestamp\n",
")\n",
"aggregated_lidar = zod_frame.get_aggregated_lidar(num_before=10, num_after=0, timestamp=image_timestamp)\n",
"lid_image = visualize_lidar_on_image(\n",
" aggregated_lidar,\n",
" zod_frame.calibration,\n",
Expand Down
2 changes: 1 addition & 1 deletion zod/cli/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _download(download_path: str, dbx: ResumableDropbox, info: DownloadExtractIn
)
if pbar.n > info.size:
tqdm.write(
f"Error! File {download_path} already exists and is larger than expected. " "Please delete and try again."
f"Error! File {download_path} already exists and is larger than expected. Please delete and try again."
)
if pbar.n > 0:
# this means we are retrying or resuming a previously interrupted download
Expand Down
6 changes: 3 additions & 3 deletions zod/cli/extract_tsr_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def extract_tsr_patches(
print("Will save dataset to", output_dir)
output_dir.mkdir(parents=True, exist_ok=True)

assert not (
padding_factor is not None and (padding_px_x is not None or padding_px_y is not None)
), "Cannot specify both padding and padding_factor"
assert not (padding_factor is not None and (padding_px_x is not None or padding_px_y is not None)), (
"Cannot specify both padding and padding_factor"
)

padding = (padding_px_x, padding_px_y) if (padding_px_x is not None and padding_px_y is not None) else None

Expand Down
4 changes: 1 addition & 3 deletions zod/cli/generate_coco_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ def convert_to_coco(
if cls not in OBJECT_CLASSES:
typer.echo(f"ERROR: Invalid class: {cls}.")
raise typer.Exit(1)
typer.echo(
"Converting ZOD to COCO format. " f"Version: {version}, anonymization: {anonymization}, classes: {classes}"
)
typer.echo(f"Converting ZOD to COCO format. Version: {version}, anonymization: {anonymization}, classes: {classes}")

zod_frames = ZodFrames(str(dataset_root), version.value)

Expand Down
6 changes: 3 additions & 3 deletions zod/data_classes/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ def crop_from_image(
tuple: padding in all four directions | (left, top, right, bottom)
"""

assert not (
padding is not None and padding_factor is not None
), "Cannot specify both padding and padding_factor"
assert not (padding is not None and padding_factor is not None), (
"Cannot specify both padding and padding_factor"
)

if padding is not None:
padding_x, padding_y = padding
Expand Down
6 changes: 3 additions & 3 deletions zod/data_classes/ego_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def get_poses(self, target_ts: Union[np.ndarray, float]) -> np.ndarray:
[N, 4, 4] array of interpolated poses for each timestamp.
"""
selfmin, selfmax = np.min(self.timestamps), np.max(self.timestamps)
assert (selfmin <= np.min(target_ts)) and (
selfmax >= np.max(target_ts)
), f"targets not between pose timestamps, must be [{selfmin}, {selfmax}]"
assert (selfmin <= np.min(target_ts)) and (selfmax >= np.max(target_ts)), (
f"targets not between pose timestamps, must be [{selfmin}, {selfmax}]"
)

if np.isin(target_ts, self.timestamps).all():
return self.poses[self.timestamps.searchsorted(target_ts)]
Expand Down
6 changes: 3 additions & 3 deletions zod/data_classes/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def get_camera_lidar_map(
A tuple of the camera frame and the closest lidar frame.
"""
camera_name = f"{camera.value}_{anonymization.value}"
assert (
camera_name in self.camera_frames
), f"Camera {camera_name} not found. Available cameras: {self.camera_frames.keys()}"
assert camera_name in self.camera_frames, (
f"Camera {camera_name} not found. Available cameras: {self.camera_frames.keys()}"
)
assert lidar in self.lidar_frames, f"Lidar {lidar} not found. Available lidars: {self.lidar_frames.keys()}"

for camera_frame in self.camera_frames[camera_name]:
Expand Down
12 changes: 6 additions & 6 deletions zod/eval/detection/_experimental/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ def match_one_frame(
A list of tuples. Each tuple contains the ground truth object and the prediction.
"""
# check that all objects are in the evaluation frame
assert all(
gt.box3d.frame == EVALUATION_FRAME for gt in ground_truth if gt.box3d is not None
), "All ground truth objects must be in the evaluation frame."
assert all(
pred.box3d.frame == EVALUATION_FRAME for pred in predictions
), "All predictions must be in the evaluation frame."
assert all(gt.box3d.frame == EVALUATION_FRAME for gt in ground_truth if gt.box3d is not None), (
"All ground truth objects must be in the evaluation frame."
)
assert all(pred.box3d.frame == EVALUATION_FRAME for pred in predictions), (
"All predictions must be in the evaluation frame."
)

if method == "greedy":
return greedy_match(
Expand Down