| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 11d00b5 commit b95ce02
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1404,6 +1404,11 @@ def test_bar_tick_label_single(): | |||
| 1404 | 1404 | ax.bar("a", "b", align='edge', tick_label='0', data=data) | |
| 1405 | 1405 | ||
| 1406 | 1406 | ||
| 1407 | + def test_nan_bar_values(): | ||
| 1408 | + fig, ax = plt.subplots() | ||
| 1409 | + ax.bar([0, 1], [np.nan, 4]) | ||
| 1410 | + | ||
| 1411 | + | ||
| 1407 | 1412 | def test_bar_ticklabel_fail(): | |
| 1408 | 1413 | fig, ax = plt.subplots() | |
| 1409 | 1414 | ax.bar([], []) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -459,8 +459,19 @@ def test_cleanup_closepoly(): | |||
| 459 | 459 | # component contains a NaN, then Path.cleaned should ignore not just the | |
| 460 | 460 | # control points but also the CLOSEPOLY, since it has nowhere valid to | |
| 461 | 461 | # point. | |
| 462 | - p = Path([[np.nan, np.nan], [np.nan, np.nan]], | ||
| 463 | - [Path.MOVETO, Path.CLOSEPOLY]) | ||
| 464 | - cleaned = p.cleaned(remove_nans=True) | ||
| 465 | - assert len(cleaned) == 1 | ||
| 466 | - assert cleaned.codes[0] == Path.STOP | ||
| 462 | + paths = [ | ||
| 463 | + Path([[np.nan, np.nan], [np.nan, np.nan]], | ||
| 464 | + [Path.MOVETO, Path.CLOSEPOLY]), | ||
| 465 | + # we trigger a different path in the C++ code if we don't pass any | ||
| 466 | + # codes explicitly, so we must also make sure that this works | ||
| 467 | + Path([[np.nan, np.nan], [np.nan, np.nan]]), | ||
| 468 | + # we should also make sure that this cleanup works if there's some | ||
| 469 | + # multi-vertex curves | ||
| 470 | + Path([[np.nan, np.nan], [np.nan, np.nan], [np.nan, np.nan], | ||
| 471 | + [np.nan, np.nan]], | ||
| 472 | + [Path.MOVETO, Path.CURVE3, Path.CURVE3, Path.CLOSEPOLY]) | ||
| 473 | + ] | ||
| 474 | + for p in paths: | ||
| 475 | + cleaned = p.cleaned(remove_nans=True) | ||
| 476 | + assert len(cleaned) == 1 | ||
| 477 | + assert cleaned.codes[0] == Path.STOP | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,11 +205,13 @@ class PathNanRemover : protected EmbeddedQueue<4> | |||
| 205 | 205 | are found along the way, the queue is emptied, and | |
| 206 | 206 | the next curve segment is handled. */ | |
| 207 | 207 | code = m_source->vertex(x, y); | |
| 208 | - if (code == agg::path_cmd_stop) { | ||
| 209 | - return code; | ||
| 210 | - } | ||
| 211 | - if (code == (agg::path_cmd_end_poly | agg::path_flags_close) | ||
| 212 | - && valid_segment_exists) { | ||
| 208 | + /* The vertices attached to STOP and CLOSEPOLY left are never | ||
| 209 | + used, so we leave them as-is even if NaN. However, CLOSEPOLY | ||
| 210 | + only makes sense if a valid MOVETO command has already been | ||
| 211 | + emitted. */ | ||
| 212 | + if (code == agg::path_cmd_stop || | ||
| 213 | + (code == (agg::path_cmd_end_poly | agg::path_flags_close) && | ||
| 214 | + valid_segment_exists)) { | ||
| 213 | 215 | return code; | |
| 214 | 216 | } | |
| 215 | 217 | ||
@@ -258,21 +260,23 @@ class PathNanRemover : protected EmbeddedQueue<4> | |||
| 258 | 260 | code = m_source->vertex(x, y); | |
| 259 | 261 | ||
| 260 | 262 | if (code == agg::path_cmd_stop || | |
| 261 | - code == (agg::path_cmd_end_poly | agg::path_flags_close)) { | ||
| 263 | + code == (agg::path_cmd_end_poly | agg::path_flags_close) && | ||
| 264 | + valid_segment_exists) { | ||
| 262 | 265 | return code; | |
| 263 | 266 | } | |
| 264 | 267 | ||
| 265 | 268 | if (!(std::isfinite(*x) && std::isfinite(*y))) { | |
| 266 | 269 | do { | |
| 267 | 270 | code = m_source->vertex(x, y); | |
| 268 | 271 | if (code == agg::path_cmd_stop || | |
| 269 | - code == (agg::path_cmd_end_poly | agg::path_flags_close)) { | ||
| 272 | + (code == (agg::path_cmd_end_poly | agg::path_flags_close) && | ||
| 273 | + valid_segment_exists)) { | ||
| 270 | 274 | return code; | |
| 271 | 275 | } | |
| 272 | 276 | } while (!(std::isfinite(*x) && std::isfinite(*y))); | |
| 273 | 277 | return agg::path_cmd_move_to; | |
| 274 | 278 | } | |
| 275 | - | ||
| 279 | + valid_segment_exists = true; | ||
| 276 | 280 | return code; | |
| 277 | 281 | } | |
| 278 | 282 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments