Skip to content

Checking plot labels works locally but not during CI #31580

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

Closed
MarcoGorelli opened this issue Feb 2, 2020 · 1 comment · Fixed by #31659
Closed

Checking plot labels works locally but not during CI #31580

MarcoGorelli opened this issue Feb 2, 2020 · 1 comment · Fixed by #31659
Labels
Testing pandas testing functions or related to the test suite Visualization plotting
Milestone

Comments

@MarcoGorelli
Copy link
Member

Code Sample, a copy-pastable example if possible

xref #31207

If I modified the test as follows (with import re at the top of the file)

        with tm.assert_produces_warning(None):
            fig, ax = self.plt.subplots()
            ts.plot(ax=ax)
            fig.canvas.draw()
            labels = [i.get_text() for i in ax.get_xticklabels()]
            # Extract H:M component, check first point is in correct timezone.
            # NOTE: this test could be updated once GH 31548 is fixed,
            # so that the last point is checked as well.
            assert re.findall(r"[^:]?(\d{2}:\d{2})", labels[0])[0] == "00:00"
            _check_plot_works(ts.plot)

then the test worked locally, but not during CI. Looking at the job details for linux py36_local, I could see that labels was

['01 00:01', ...1 00:51', ...]

I don't understand where that extra minute is coming from (nor can I understand why it only appears during CI).

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit : 6e2d3ae
python : 3.7.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-74-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 0.26.0.dev0+2036.g6e2d3aeb6
numpy : 1.17.3
pytz : 2019.3
dateutil : 2.8.1
pip : 19.3.1
setuptools : 45.0.0.post20200113
Cython : 0.29.14
pytest : 5.3.3
hypothesis : 5.1.5
sphinx : 2.3.1
blosc : None
feather : None
xlsxwriter : 1.2.7
lxml.etree : 4.4.2
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.11.1
pandas_datareader: None
bs4 : 4.8.2
bottleneck : 1.3.1
fastparquet : 0.3.2
gcsfs : None
lxml.etree : 4.4.2
matplotlib : 3.1.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.1
pandas_gbq : None
pyarrow : 0.15.1
pytables : None
pytest : 5.3.3
pyxlsb : None
s3fs : 0.4.0
scipy : 1.4.1
sqlalchemy : 1.3.12
tables : 3.6.1
tabulate : 0.8.6
xarray : 0.14.1
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.7
numba : 0.47.0

@jorisvandenbossche
Copy link
Member

@MarcoGorelli I would approach it a bit differently, and instead of testing the labels on the plot (which is very much dependent on matplotlib, they could eg change it a bit accross versions), I would maybe rather test the data values as they are plotted on the axis. Eg you can get those data with list(ax.get_lines())[0].get_xdata() (with ax the return value of df.plot()). Then could eg check that those values are the same whether you plot timezone aware or timezone naive version

@jreback jreback added this to the 1.1 milestone Feb 5, 2020
@jreback jreback added Testing pandas testing functions or related to the test suite Visualization plotting labels Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants