-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Warning treated as error while generating docs #8145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you @aashil for reporting this issue. With the vanilla line 55 in @tacaswell Is it expected for such an exception to be uncaught during the CI tests? |
We build the docs on py3 so it reasonable that we missed this. I think this is a unicode bug in the recently merged dash-pattern validator. |
@tacaswell It looks like you are right. With Python 2.7: In [1]: from matplotlib.rcsetup import _validate_linestyle
In [2]: _validate_linestyle(u'solid')
Out[2]: u'solid'
In [3]: _validate_linestyle('solid')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-9192256a512f> in <module>()
----> 1 _validate_linestyle('solid')
/home/adrien/matplotlib-git/lib/matplotlib/rcsetup.pyc in _validate_linestyle(ls)
928
929 raise ValueError("linestyle must be a string or " +
--> 930 "an even-length sequence of floats.")
931
932
ValueError: linestyle must be a string or an even-length sequence of floats. |
In ...
if isinstance(ls, six.text_type):
return _validate_named_linestyle(ls.decode())
... to make sure that we pass a unicode (string) argument? Or should this kind of conversion be handled differently? |
calling I do not fully understand what is going on here though.
|
@tacaswell If one trusts SO, it is the expected behavior with Python 2, which “handles translation between About the reported issue here, I think the problem may be due to the test if isinstance(ls, six.text_type): in the Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:08:32)
[...]
In [1]: from matplotlib.rcsetup import _validate_named_linestyle, _validate_linestyle
In [2]: import six
In [3]: _validate_named_linestyle('solid') # No problem with a valid ASCII string
Out[3]: u'solid'
In [4]: _validate_linestyle('solid') # Error with a valid ASCII string
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-9192256a512f> in <module>()
----> 1 _validate_linestyle('solid')
/home/adrien/matplotlib-git/matplotlib/lib/matplotlib/rcsetup.pyc in _validate_linestyle(ls)
928
929 raise ValueError("linestyle must be a string or " +
--> 930 "an even-length sequence of floats.")
931
932
ValueError: linestyle must be a string or an even-length sequence of floats.
In [5]: isinstance('solid', six.text_type) # => issue w/ the aforementioned test...
Out[5]: False
In [6]: isinstance(u'solid', six.text_type) # => expected behavior
Out[6]: True I used from __future__ import print_function
import six
from matplotlib.rcsetup import _validate_named_linestyle
def _validate_linestyle(ls):
"""
A validator for all possible line styles, the named ones *and*
the on-off ink sequences.
"""
# Named line style, like u'--' or u'solid'
if isinstance(ls, six.string_types): # <= Here is the change!
return _validate_named_linestyle(ls)
# On-off ink (in points) sequence *of even length*.
# Offset is set to None.
try:
if len(ls) % 2 != 0:
# Expecting a sequence of even length
raise ValueError
return (None, validate_nseq_float()(ls))
except (ValueError, TypeError):
# TypeError can be raised by wrong types passed to float()
# (called inside the instance of validate_nseq_float).
pass
raise ValueError("linestyle must be a string or " +
"an even-length sequence of floats.")
# Testing different types of strings for the same valid name of line style.
validated_strings = []
for ls in ['solid', u'solid', bytes('solid')]:
validated_strings.append(_validate_linestyle(ls))
print(validated_strings) # => [u'solid', u'solid', u'solid'] |
Or skip the type checking and just do try:
return _validate_named_linestyle(ls)
except KeyError:
pass |
Indeed ^^. I am going to open a PR to fix the issue as you suggest. |
With the PR #8165, I was able to locally build the documentation under Python 2.7. |
Bug report
Bug summary
I get the following
WARNING
while generating docs.The command from
contour_demo.py
which throws the warning is:I think it's expecting positive values for extent.
Code for reproduction
Matplotlib version
The text was updated successfully, but these errors were encountered: