Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischang5 committed Feb 25, 2024
1 parent 1157a0d commit 71b8bd5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
6 changes: 2 additions & 4 deletions boat_simulator/common/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
GaussianGenerator,
)


class Sensor:
"""
Expand Down Expand Up @@ -106,7 +107,6 @@ def __init__(
self.wind_queue: deque = deque()
self.wind_noisemaker = MVGaussianGenerator(mean=np.array([0, 0]), cov=np.eye(2))


@property # type: ignore
def wind(self) -> ScalarOrArray:
# TODO: Ensure attribute value and noisemakers are using the same value shape.
Expand All @@ -129,6 +129,7 @@ def wind(self, wind: ScalarOrArray):
else:
self.wind_queue_next = True


class GPS(Sensor):
"""
Abstraction for GPS.
Expand Down Expand Up @@ -172,7 +173,6 @@ def __init__(
self.speed_noisemaker: GaussianGenerator = GaussianGenerator(mean=0, stdev=1)
self.heading_noisemaker: GaussianGenerator = GaussianGenerator(mean=0, stdev=1)


@property # type: ignore
def lat_lon(self) -> NDArray:
return (
Expand All @@ -192,7 +192,6 @@ def lat_lon(self, lat_lon: NDArray):
else:
self.lat_lon_queue_next = True


@property # type: ignore
def speed(self) -> Scalar:
return (
Expand Down Expand Up @@ -228,4 +227,3 @@ def heading(self, heading: Scalar):
self._heading = self.heading_queue.popleft()
else:
self.heading_queue_next = True

11 changes: 7 additions & 4 deletions boat_simulator/common/unit_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ class ConversionFactors(Enum):
km_to_nautical_mi = nautical_mi_to_km.inverse()

# Time

sec_to_ms = ConversionFactor(factor=1000)
ms_to_sec = sec_to_ms.inverse()

min_to_sec = ConversionFactor(factor=60)
sec_to_min = min_to_sec.inverse()

Expand Down Expand Up @@ -203,7 +202,9 @@ def __init__(self, **kwargs: EnumAttr):
belonging to `ConversionFactors`.
"""
for attr_name, attr_val in kwargs.items():
assert isinstance(attr_val, Enum) and isinstance(attr_val.value, ConversionFactor)
assert isinstance(attr_val, Enum) and isinstance(
attr_val.value, ConversionFactor
)
setattr(self, attr_name, attr_val)

def convert(self, **kwargs: ScalarOrArray) -> Dict[str, ScalarOrArray]:
Expand All @@ -227,7 +228,9 @@ def convert(self, **kwargs: ScalarOrArray) -> Dict[str, ScalarOrArray]:

for attr_name, attr_val in kwargs.items():
attr = getattr(self, attr_name, None)
assert attr is not None, f"Attribute name {attr} not found in UnitConverter."
assert (
attr is not None
), f"Attribute name {attr} not found in UnitConverter."

conversion_factor = attr.value
converted_values[attr_name] = conversion_factor.forward_convert(attr_val)
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/common/test_gps_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ def test_gps_sensor_update_delay(self):
# Initialized data is read without delay
gps = GPS(lat_lon=lat_lon, speed=speed0, heading=heading, enable_delay=True)
assert gps.read("speed") == speed0

NUM_UPDATES = 3
for i in range(NUM_UPDATES):
gps.update(speed=(i + 1))
assert gps.read("speed") == i

2 changes: 0 additions & 2 deletions tests/unit/common/test_wind_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def test_wind_sensor_read_mv_gaussian_noise(self):
sample_mean = np.mean(reading, axis=0)
sample_cov = np.cov(reading, rowvar=False)


assert np.allclose(sample_mean, mean, atol=0.2)
assert np.allclose(sample_cov, cov, atol=0.2)

Expand Down Expand Up @@ -68,4 +67,3 @@ def test_wind_sensor_update_with_delay(self):
ws.update(wind=np.array([i + 1, i + 1]))
wind = ws.read("wind")
assert np.all(wind == [i, i])

0 comments on commit 71b8bd5

Please sign in to comment.