fix(nanoplots): keep a stroke width of zero passed to nanoplot_options - #893
Merged
rich-iannone merged 4 commits intoOct 2, 2026
Merged
Conversation
data_line_stroke_width and vertical_guide_stroke_width take their
default through 'x or default', so a width of 0, which is how a caller
asks for no stroke at all, is read as 'not given' and replaced by 8 and
by 12.
nanoplot_options(data_line_stroke_width=0) -> 8
nanoplot_options(data_line_stroke_width=1) -> 1
With 0 the generated SVG is byte for byte the default one, so the option
is silently dropped rather than doing nothing visible.
The same function already makes this distinction where it matters: every
show_* flag uses 'True if x is None else x' so that False survives, and
the widths that pass through _normalize_listable_nanoplot_options keep a
0 because it becomes a truthy [0]. These two are the ones left behind.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #893 +/- ##
=======================================
Coverage 98.34% 98.34%
=======================================
Files 52 52
Lines 8318 8318
=======================================
Hits 8180 8180
Misses 138 138 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nanoplot_options()takes the default fordata_line_stroke_widthandvertical_guide_stroke_widthwithx or default(_helpers.py:1475,_helpers.py:1492), so a width of0, which is how a caller asks for no stroke at all, reads as "not given":Passing
0produces an SVG byte for byte identical to the default one, so the option is dropped rather than doing something visible that the caller could notice.The same function already draws this distinction where it matters. Every
show_*flag usesTrue if x is None else xprecisely so thatFalsesurvives, and the widths that go through_normalize_listable_nanoplot_optionskeep a0because it becomes a truthy[0]. These two are the ones left onor.Reading the default with
is Noneis the smallest change that makes them behave like their neighbours. Colors are left as they are: an empty string is not a value a caller means.Test run: full
pytest tests, 2722 passed, 1 skipped, 6 xfailed. The new test fails onmain.ruff checkandruff format --checkclean on both files.