Skip to content

Commit 0396543

Browse files
committed
fix: add more points to the general case (excess will now get filtered); added new test case.
1 parent 57938fe commit 0396543

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/load_distribution/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
loads on beams or other linear elements.
44
"""
55

6-
__version__ = "0.1.3"
6+
__version__ = "0.1.4"
77

88
from load_distribution.load_distribution import *

src/load_distribution/load_distribution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ def singularities_to_polygon(los: list[Singularity], xy: bool = False) -> Polygo
202202
if prev_x is not None and not math.isclose(prev_x, sing.x0):
203203
x_acc.append(sing.x0)
204204
x_acc.append(sing.x0 + eps)
205-
x_acc.append(sing.x1 - 10 * eps)
205+
x_acc.append(sing.x1 - eps)
206+
x_acc.append(sing.x1)
207+
x_acc.append(sing.x1 + eps)
206208
prev_x = sing.x1
207209

208210
# There are two scenarios: sing functions that describe trapezoids/triangles

tests/test_load_distribution.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ def test_singularities_to_polygon():
175175

176176
assert (
177177
ld.singularities_to_polygon(square_45_sings[0] + square_45_sings[1]).wkt
178-
== "POLYGON ((0 0, 0 0, 5 10, 5 10, 10 0, 0 0))"
179-
# == "POLYGON ((0 0, 5 10, 5 10, 10 0, 10 0, 0 0))"
178+
== "POLYGON ((0 0, 0 0, 5 10, 5 10, 10 0, 10 0, 0 0))"
180179
)
181180
assert (
182181
ld.singularities_to_polygon(
@@ -202,7 +201,13 @@ def test_singularities_to_polygon():
202201
).wkt
203202
== "POLYGON ((1 0, 1 10, 3 10, 3 0, 1 0))"
204203
)
205-
204+
assert (
205+
ld.singularities_to_polygon([
206+
ld.Singularity(x0=0, x1=4, m=0.0, y0=5, precision=6, eps=1e-12),
207+
ld.Singularity(x0=0, x1=2.5, m=0.0, y0=40, precision=6, eps=1e-12)
208+
]).wkt
209+
== "POLYGON ((0 0, 0 45, 2.5 45, 2.5 5, 4 5, 4 0, 0 0))"
210+
)
206211

207212
def test_overlap_region_to_singularity():
208213
assert ld.overlap_region_to_singularity(

0 commit comments

Comments
 (0)