Skip to content

Commit 28f503b

Browse files
committed
changed imports, removed None checks for array of LidarDetection
1 parent 0f21e10 commit 28f503b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

modules/lidar_oscillation.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Representing a LiDAR Oscillation
33
"""
44

5-
from lidar_detection import LidarDetection
5+
from . import lidar_detection
66

77

88
class LidarOscillation:
@@ -13,28 +13,29 @@ class LidarOscillation:
1313
__create_key = object()
1414

1515
@classmethod
16-
def create(cls, readings: list[LidarDetection]) -> "tuple[bool, LidarOscillation | None]":
16+
def create(
17+
cls, readings: list[lidar_detection.LidarDetection]
18+
) -> "tuple[bool, LidarOscillation | None]":
1719
"""
1820
Create a new LidarOscillation object from a list of LidarReading objects.
1921
"""
20-
# Ensuring the list does not contain None values
21-
if any(reading is None for reading in readings):
22-
return False, None
2322

2423
return True, LidarOscillation(cls.__create_key, readings)
2524

26-
def __init__(self, class_private_create_key: object, readings: list[LidarDetection]) -> None:
25+
def __init__(
26+
self, class_private_create_key: object, readings: list[lidar_detection.LidarDetection]
27+
) -> None:
2728
"""
2829
Private constructor, use create() method to instantiate.
2930
"""
3031
assert class_private_create_key is LidarOscillation.__create_key, "Use the create() method"
3132

3233
self.readings = readings
33-
valid_angles = [reading.angle for reading in readings if reading is not None]
34+
angles = [reading.angle for reading in readings]
3435

35-
if valid_angles:
36-
self.min_angle = min(valid_angles)
37-
self.max_angle = max(valid_angles)
36+
if angles:
37+
self.min_angle = min(angles)
38+
self.max_angle = max(angles)
3839
else:
3940
self.min_angle = None
4041
self.max_angle = None

0 commit comments

Comments
 (0)