Skip to content

Commit

Permalink
Trac #27126: py3: Fix plot module for python3
Browse files Browse the repository at this point in the history
The root cause for matplotlib's {{{AttributeError: Unknown property
which}}} was testing {{{hasattr(x, '__iter__')}}} to filter {{{str}}}.
{{{str}}} hasn't an {{{__iter__}}} method in py2 but has one in py3.

URL: https://trac.sagemath.org/27126
Reported by: vklein
Ticket author(s): Vincent Klein
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Jan 27, 2019
2 parents 437b1af + 2131766 commit 227cfa6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/sage/plot/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2383,10 +2383,10 @@ def _get_vmin_vmax(self, vmin, vmax, basev, axes_pad):
at least 10 units apart::
sage: p = Graphics()
sage: p._get_vmin_vmax(1, 2, 10, None)
(9/10, 10.0)
sage: p._get_vmin_vmax(1, 5, 10, None)
(9/10, 10.0)
sage: p._get_vmin_vmax(1, 2, 10, None) == (9/10, 10)
True
sage: p._get_vmin_vmax(1, 5, 10, None) == (9/10, 10)
True
sage: p._get_vmin_vmax(1, 10, 10, None)
(9/10, 11)
sage: p._get_vmin_vmax(1, 11, 10, None)
Expand Down Expand Up @@ -2903,7 +2903,7 @@ def matplotlib(self, filename=None,
if vgridlines=='minor':
vgridstyle['which']='both'

if hasattr(hgridlines, '__iter__'):
if not isinstance(hgridlines, str) and hasattr(hgridlines, '__iter__'):
hlines=iter(hgridlines)
hgridstyle.pop("minor",None)
for hline in hlines:
Expand All @@ -2919,7 +2919,7 @@ def matplotlib(self, filename=None,
if hgridlines not in (None, False):
subplot.yaxis.grid(True, **hgridstyle)

if hasattr(vgridlines, '__iter__'):
if not isinstance(vgridlines, str) and hasattr(vgridlines, '__iter__'):
vlines=iter(vgridlines)
vgridstyle.pop("minor",None)
for vline in vlines:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/plot/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def get_minmax_data(self):
DeprecationWarning: the 'normed' option is deprecated. Use 'density' instead.
See https://trac.sagemath.org/25260 for details.
sage: h.get_minmax_data()
doctest:warning ...:
VisibleDeprecationWarning: Passing `normed=True` on non-uniform bins has always been broken, and computes neither the probability density function nor the probability mass function. The result is only correct if the bins are uniform, when density=True will produce the same result anyway. The argument will be removed in a future version of numpy.
doctest:warning ...
...VisibleDeprecationWarning: Passing `normed=True` on non-uniform bins has always been broken, and computes neither the probability density function nor the probability mass function. The result is only correct if the bins are uniform, when density=True will produce the same result anyway. The argument will be removed in a future version of numpy.
{'xmax': 10.0, 'xmin': 3.0, 'ymax': 0.476190476190..., 'ymin': 0}
"""
import numpy
Expand Down

0 comments on commit 227cfa6

Please sign in to comment.