From aca0ee3eea88b2493e62f9eb6c48776f76e54279 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 19 Sep 2024 13:19:57 +0800 Subject: [PATCH] locationd: replaced the loop and setattr with direct attribute assignment (#33466) replaced the loop and setattr with direct attribute assignment --- selfdrive/locationd/locationd.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/selfdrive/locationd/locationd.py b/selfdrive/locationd/locationd.py index 14a315da85..4cde1e5ad4 100755 --- a/selfdrive/locationd/locationd.py +++ b/selfdrive/locationd/locationd.py @@ -31,9 +31,8 @@ POSENET_STD_HIST_HALF = 20 def init_xyz_measurement(measurement: capnp._DynamicStructBuilder, values: np.ndarray, stds: np.ndarray, valid: bool): assert len(values) == len(stds) == 3 - for i, d in enumerate(("x", "y", "z")): - setattr(measurement, d, float(values[i])) - setattr(measurement, f"{d}Std", float(stds[i])) + measurement.x, measurement.y, measurement.z = map(float, values) + measurement.xStd, measurement.yStd, measurement.zStd = map(float, stds) measurement.valid = valid