Skip to content

Commit 6a53369

Browse files
author
Ingeborg Gjerde
committed
handle np.nans
1 parent 76c0267 commit 6a53369

12 files changed

+124
-24
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changes
22

3+
## Version 0.5.0
4+
5+
_2024-12-12_
6+
7+
Fix:
8+
9+
- Strip np.nans from line vertices to avoid silent crash when computing the bounding box
10+
311
## Version 0.4.0
412

513
_2024-11-22_

mpldxf/backend_dxf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ def _clip_mpl(self, gc, vertices, obj):
136136
vertices
137137
)
138138
elif obj == "line2d":
139+
# strip nans
140+
vertices = [v for v in vertices if not np.isnan(v).any()]
141+
139142
cliprect = Polygon(cliprect)
140143
line = LineString(vertices)
141144
try:
@@ -159,12 +162,6 @@ def _clip_mpl(self, gc, vertices, obj):
159162
return vertices
160163

161164
def _draw_mpl_lwpoly(self, gc, path, transform, obj):
162-
# TODO rework for BEZIER curves
163-
if obj == "patch":
164-
close = True
165-
elif obj == "line2d":
166-
close = False
167-
168165
dxfattribs = self._get_polyline_attribs(gc)
169166
vertices = path.transformed(transform).vertices
170167

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mpldxf"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
description = "A fork of mpldxf - a matplotlib backend to write DXF drawings. Modified by NGI to handle geotechnical plots"
55
authors = ["David Kent",
66
"Jon-Michael Josefsen <[email protected]>",

tests/files/test_boxplot.png

7.33 KB
Loading

tests/files/test_contour.png

103 KB
Loading

tests/files/test_contourf.png

14 KB
Loading

tests/files/test_plot_line.png

20.5 KB
Loading
12.7 KB
Loading
11.3 KB
Loading
8.28 KB
Loading

0 commit comments

Comments
 (0)