Skip to content

Commit b6ffb2b

Browse files
committed
fix: based new logic on whether there is a slope or not
1 parent 3eab3b0 commit b6ffb2b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/load_distribution/load_distribution.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,22 @@ def singularities_to_polygon(los: list[Singularity], xy: bool = False) -> Polygo
180180
x_acc = []
181181
prev_x = None
182182
n = None
183+
print(sorted_sings)
183184
for idx, sing in enumerate(sorted_sings):
184185
n = sing.precision
185186
eps = 10 ** (-2 * n)
186187
if prev_x != sing.x0 and prev_x is not None:
187188
x_acc.append(prev_x + eps)
188-
x_acc.append(sing.x0)
189-
x_acc.append(sing.x0 + eps)
190-
if idx == len(sorted_sings) - 1:
189+
if sing.m == 0: # If the slope is 0.0, we have a step function which needs to be treated differently
190+
x_acc.append(sing.x0)
191+
x_acc.append(sing.x0 + eps)
191192
x_acc.append(sing.x1 - eps)
192-
x_acc.append(sing.x1)
193-
prev_x = sing.x1
194-
if idx == len(sorted_sings) - 1: # Last iteration of actual iterations
195193
x_acc.append(sing.x1)
194+
else:
195+
x_acc.append(sing.x0)
196+
x_acc.append(sing.x1-eps)
197+
x_acc.append(sing.x1)
198+
prev_x = sing.x1
196199

197200
x_acc = sorted(list(set(x_acc)))
198201
y_acc = [sum([sing(x) for sing in sorted_sings]) for x in x_acc[:-1]]

0 commit comments

Comments
 (0)