@@ -55,8 +55,8 @@ def test_plot_line_with_no_axis(self):
5555 doc = ezdxf .readfile (outfile )
5656 modelspace = doc .modelspace ()
5757 entities = list (modelspace )
58- assert len (entities ) == 1 # 1 line
59-
58+ assert len (entities ) == 1 # 1 line and the bounding box of the plot
59+
6060 def test_plot_line (self ):
6161 """Test a simple line-plot command."""
6262 plt .gca ().patch .set_visible (False )
@@ -163,6 +163,7 @@ def test_contourf(self):
163163 X , Y = np .meshgrid (x , y )
164164 Z = np .sin (np .sqrt (X ** 2 + Y ** 2 ))
165165 plt .contourf (X , Y , Z )
166+
166167 plt .savefig ("tests/files/test_contourf.png" )
167168
168169 try :
@@ -171,3 +172,27 @@ def test_contourf(self):
171172
172173 finally :
173174 plt .close ()
175+
176+ def test_plot_with_nans (self ):
177+ """Test a plot with NaNs."""
178+ plt .gca ().patch .set_visible (False )
179+ x = [1 , 2 , 3 , 4 , 5 , 6 ]
180+ y = [1 , 2 , 3 , np .nan , 5 , 6 ]
181+ plt .plot (x , y )
182+ plt .axis ("off" )
183+
184+ plt .savefig ("tests/files/test_plot_with_nans.png" )
185+
186+ try :
187+ outfile = "tests/files/test_plot_with_nans.dxf"
188+ plt .savefig (outfile )
189+ finally :
190+ plt .close ()
191+
192+ # Load the DXF file and inspect its content
193+ doc = ezdxf .readfile (outfile )
194+ modelspace = doc .modelspace ()
195+ entities = list (modelspace )
196+ assert (
197+ len (entities ) == 1
198+ ) # ideally we should have two lines (i.e. one broken line), but one interpolated line works as a hotfix
0 commit comments