Skip to content

Commit 8057e54

Browse files
committed
combine error messages in solve_wls
1 parent d5a9382 commit 8057e54

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

gnss_lib_py/algorithms/snapshot.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def solve_wls(measurements, weight_type = None, only_bias = False,
8484
rx_rows_to_find,
8585
max_allow=1)
8686
states = []
87+
runtime_error_idxs = {}
8788

8889
position = np.zeros((4,1))
8990
for timestamp, _, measurement_subset in measurements.loop_time("gps_millis", delta_t_decimals=delta_t_decimals):
@@ -120,9 +121,10 @@ def solve_wls(measurements, weight_type = None, only_bias = False,
120121
only_bias, tol, max_count)
121122
states.append([timestamp] + np.squeeze(position).tolist())
122123
except RuntimeError as error:
123-
warnings.warn("RuntimeError encountered at gps_millis: " \
124-
+ str(int(timestamp)) + " RuntimeError: " \
125-
+ str(error), RuntimeWarning)
124+
if str(error) not in runtime_error_idxs:
125+
runtime_error_idxs[str(error)] = [str(int(timestamp))]
126+
else:
127+
runtime_error_idxs[str(error)].append(str(int(timestamp)))
126128
states.append([timestamp, np.nan, np.nan, np.nan, np.nan])
127129

128130
states = np.array(states)
@@ -134,6 +136,11 @@ def solve_wls(measurements, weight_type = None, only_bias = False,
134136
state_estimate["z_rx_wls_m"] = states[:,3]
135137
state_estimate["b_rx_wls_m"] = states[:,4]
136138

139+
for error,timestamps in runtime_error_idxs.items():
140+
warnings.warn(error + " Encountered at " + str(len(timestamps))\
141+
+ " gps_millis of: " \
142+
+ ", ".join(timestamps), RuntimeWarning)
143+
137144
if np.isnan(states[:,1:]).all():
138145
warnings.warn("No valid state estimate computed in WLS, "\
139146
+ "returning NaNs.", RuntimeWarning)

gnss_lib_py/parsers/navdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def argwhere(self, key_idx, value, condition="eq"):
373373
elif np.isnan(value):
374374
str_check = [str(np.nan)]
375375
else:
376-
raise ValueError("Value must be string or array-like" \
376+
raise ValueError("Value must be string or array-like " \
377377
+ "for string condition checks")
378378
# Extract columns where condition holds true and return new NavData
379379
if condition == "eq":

tests/algorithms/test_snapshot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,8 @@ def test_solve_wls_fails(derived):
592592
593593
"""
594594

595-
navdata = derived.remove(cols=list(range(3,len(derived))))
595+
navdata = derived.remove(cols=list(range(3,50)) \
596+
+ list(range(53,len(derived))))
596597

597598
with pytest.warns(RuntimeWarning) as warns:
598599
solve_wls(navdata)

0 commit comments

Comments
 (0)