Skip to content

Commit

Permalink
change to use .get() for "is_valid"
Browse files Browse the repository at this point in the history
Signed-off-by: Shunsuke Miura <[email protected]>
  • Loading branch information
miursh committed Nov 21, 2023
1 parent c6ffc7a commit 1ffee4d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion perception_dataset/t4_dataset/data_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_first_sample_data_list():
return sample_data_list

for sample_data in get_first_sample_data_list():
if "is_valid" in sample_data and not sample_data["is_valid"]:
if not sample_data.get("is_valid", True):
continue
first_filename: str = sample_data["filename"]
first_timestamp: int = sample_data["timestamp"]
Expand Down
2 changes: 1 addition & 1 deletion perception_dataset/t4_dataset/format_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def validate_sample_data(nusc: NuScenes, root_path: Path):
no_next_token_count: int = 0
no_prev_token_count: int = 0
for sample_data in nusc.sample_data:
if "is_valid" in sample_data and not sample_data["is_valid"]:
if not sample_data.get("is_valid", True):
continue
assert find_in_table(
nusc, "sample", sample_data["sample_token"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _remove_sample_of_non_keyframe(

def _change_sample_token_to_next_closest_keyframe(self, sample_data_list: list):
for sample_data in sample_data_list[:]:
if sample_data["is_key_frame"] or not sample_data["is_valid"]:
if sample_data.get("is_key_frame", True) or not sample_data.get("is_valid", True):
continue
sample_data["sample_token"] = self._get_next_closest_keyframe(
sample_data, sample_data_list
Expand Down Expand Up @@ -166,7 +166,7 @@ def connect_sample_data_next_prev_tokens(self, sample_data_list: list):
sensor_sample_data_list = [
data
for data in sample_data_list
if data["calibrated_sensor_token"] == sensor and data["is_valid"]
if data["calibrated_sensor_token"] == sensor and data.get("is_valid", True)
]
self.connect_sample_next_prev_tokens(sensor_sample_data_list)
new_sample_data_list.extend(sensor_sample_data_list)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tlr_dataset_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_sample_data_json(t4_dataset_path):
assert sample_data["width"] >= 0, "width is empty"
assert sample_data["height"] >= 0, "height is empty"
assert (
sample_data["is_key_frame"] == sample_data["is_valid"]
sample_data["is_key_frame"] == sample_data.get("is_valid", True)
), f"is_key_frame is {sample_data['is_key_frame']}, is_valid is {sample_data['is_valid']}"
assert "next" in sample_data.keys(), "next is empty"
assert "prev" in sample_data.keys(), "prev is empty"
Expand Down

0 comments on commit 1ffee4d

Please sign in to comment.