Skip to content

Commit f6293c9

Browse files
committed
Merge branch 'fixes/incorrect_filtering_practices' into tests/test_incorrect_filtering
2 parents 12654fb + 0bfa269 commit f6293c9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/load_distribution/load_distribution.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,18 @@ def singularities_to_polygon(los: list[Singularity], xy: bool = False) -> Polygo
215215
# required shape, even if that means the exact x value is omitted (because we are
216216
# keeping the value immediately to the left and immediately to the right instead).
217217
x_acc = sorted(list(set(x_acc)))
218+
218219
x_ord_count = Counter([round(x, 6) for x in x_acc])
219220
to_filter = []
220221
for key, count in x_ord_count.items():
221222
if count == 3:
222223
to_filter.append(key)
223-
for filter_val in to_filter:
224-
index = x_acc.index(filter_val)
225-
x_acc.pop(index)
224+
225+
if to_filter:
226+
rounded_x_acc = [round(x, 6) for x in x_acc]
227+
for filter_val in to_filter:
228+
index = rounded_x_acc.index(filter_val)
229+
x_acc.pop(index)
226230

227231
# Now, for every x value, compute the corresponding y value
228232
y_acc = [sum([sing(x) for sing in sorted_sings]) for x in x_acc[:-1]]

0 commit comments

Comments
 (0)