Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

More python3 cleanup #10861

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

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions 17 lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
from six.moves import zip, zip_longest

import functools
import itertools
import logging
Expand Down Expand Up @@ -2764,7 +2758,7 @@ def get_next_color():
if autopct is not None:
xt = x + pctdistance * radius * math.cos(thetam)
yt = y + pctdistance * radius * math.sin(thetam)
if isinstance(autopct, six.string_types):
if isinstance(autopct, str):
s = autopct % (100. * frac)
elif callable(autopct):
s = autopct(100. * frac)
Expand Down Expand Up @@ -5606,8 +5600,7 @@ def pcolor(self, *args, **kwargs):
# makes artifacts that are often disturbing.
if 'antialiased' in kwargs:
kwargs['antialiaseds'] = kwargs.pop('antialiased')
if 'antialiaseds' not in kwargs and (
isinstance(ec, six.string_types) and ec.lower() == "none"):
if 'antialiaseds' not in kwargs and cbook._str_lower_equal(ec, "none"):
kwargs['antialiaseds'] = False

kwargs.setdefault('snap', False)
Expand Down Expand Up @@ -6526,12 +6519,12 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,

if label is None:
labels = [None]
elif isinstance(label, six.string_types):
elif isinstance(label, str):
labels = [label]
else:
labels = [six.text_type(lab) for lab in label]
labels = [str(lab) for lab in label]

for patch, lbl in zip_longest(patches, labels, fillvalue=None):
for patch, lbl in itertools.zip_longest(patches, labels):
if patch:
p = patch[0]
p.update(kwargs)
Expand Down
4 changes: 0 additions & 4 deletions 4 lib/matplotlib/backends/qt_compat.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
""" A Qt API selector that can be used to switch between PyQt and PySide.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import os
import logging
Expand Down
12 changes: 4 additions & 8 deletions 12 lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

The object-oriented API is recommended for more complex plots.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import inspect
from numbers import Number
Expand Down Expand Up @@ -504,7 +500,7 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
figLabel = ''
if num is None:
num = next_num
elif isinstance(num, six.string_types):
elif isinstance(num, str):
figLabel = num
allLabels = get_figlabels()
if figLabel not in allLabels:
Expand Down Expand Up @@ -655,13 +651,13 @@ def close(*args):
arg = args[0]
if arg == 'all':
_pylab_helpers.Gcf.destroy_all()
elif isinstance(arg, six.integer_types):
elif isinstance(arg, int):
_pylab_helpers.Gcf.destroy(arg)
elif hasattr(arg, 'int'):
# if we are dealing with a type UUID, we
# can use its integer representation
_pylab_helpers.Gcf.destroy(arg.int)
elif isinstance(arg, six.string_types):
elif isinstance(arg, str):
allLabels = get_figlabels()
if arg in allLabels:
num = get_fignums()[allLabels.index(arg)]
Expand Down Expand Up @@ -2449,7 +2445,7 @@ def plotfile(fname, cols=(0,), plotfuncs=None,

def getname_val(identifier):
'return the name and column data for identifier'
if isinstance(identifier, six.string_types):
if isinstance(identifier, str):
return identifier, r[identifier]
elif isinstance(identifier, Number):
name = r.dtype.names[int(identifier)]
Expand Down
17 changes: 1 addition & 16 deletions 17 lib/matplotlib/testing/jpl_units/Duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
# ==========================================================================
# Place all imports after here.
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
import operator
#
# Place all imports before here.
Expand Down Expand Up @@ -66,20 +62,9 @@ def seconds(self):
return self._seconds

# ----------------------------------------------------------------------
def __nonzero__(self):
"""Compare two Durations.

= INPUT VARIABLES
- rhs The Duration to compare against.

= RETURN VALUE
- Returns -1 if self < rhs, 0 if self == rhs, +1 if self > rhs.
"""
def __bool__(self):
return self._seconds != 0

if six.PY3:
__bool__ = __nonzero__

# ----------------------------------------------------------------------
def __eq__(self, rhs):
return self._cmp(rhs, operator.eq)
Expand Down
22 changes: 10 additions & 12 deletions 22 lib/matplotlib/testing/jpl_units/Epoch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
# ===========================================================================
# Place all imports after here.
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
import operator
import math
import datetime as DT
Expand Down Expand Up @@ -68,16 +64,18 @@ def __init__(self, frame, sec=None, jd=None, daynum=None, dt=None):
(daynum is not None and dt is not None) or
(dt is not None and (sec is not None or jd is not None)) or
((dt is not None) and not isinstance(dt, DT.datetime))):
msg = "Invalid inputs. Must enter sec and jd together, " \
"daynum by itself, or dt (must be a python datetime).\n" \
"Sec = %s\nJD = %s\ndnum= %s\ndt = %s" \
% (str(sec), str(jd), str(daynum), str(dt))
raise ValueError(msg)
raise ValueError(
"Invalid inputs. Must enter sec and jd together, "
"daynum by itself, or dt (must be a python datetime).\n"
"Sec = %s\n"
"JD = %s\n"
"dnum= %s\n"
"dt = %s" % (sec, jd, daynum, dt))

if frame not in self.allowed:
msg = "Input frame '%s' is not one of the supported frames of %s" \
% (frame, str(list(six.iterkeys(self.allowed))))
raise ValueError(msg)
raise ValueError(
"Input frame '%s' is not one of the supported frames of %s" %
(frame, list(self.allowed.keys())))

self._frame = frame

Expand Down
11 changes: 3 additions & 8 deletions 11 lib/matplotlib/testing/jpl_units/EpochConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
# ==========================================================================
# Place all imports after here.
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import matplotlib.units as units
import matplotlib.dates as date_ticker
from matplotlib.cbook import iterable
Expand Down Expand Up @@ -121,8 +116,8 @@ def convert(value, unit, axis):
isNotEpoch = True
isDuration = False

if iterable(value) and not isinstance(value, six.string_types):
if (len(value) == 0):
if iterable(value) and not isinstance(value, str):
if len(value) == 0:
return []
else:
return [EpochConverter.convert(x, unit, axis) for x in value]
Expand Down Expand Up @@ -156,7 +151,7 @@ def default_units(value, axis):
- Returns the default units to use for value.
"""
frame = None
if iterable(value) and not isinstance(value, six.string_types):
if iterable(value) and not isinstance(value, str):
return EpochConverter.default_units(value[0], axis)
else:
frame = value.frame()
Expand Down
5 changes: 1 addition & 4 deletions 5 lib/matplotlib/testing/jpl_units/StrConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
# ==========================================================================
# Place all imports after here.
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import matplotlib.units as units
from matplotlib.cbook import iterable

#
# Place all imports before here.
# ==========================================================================

Expand Down
26 changes: 6 additions & 20 deletions 26 lib/matplotlib/testing/jpl_units/UnitDbl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
# ==========================================================================
# Place all imports after here.
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
import operator
#
# Place all imports before here.
Expand Down Expand Up @@ -111,19 +107,9 @@ def __neg__(self):
return UnitDbl(-self._value, self._units)

# ----------------------------------------------------------------------
def __nonzero__(self):
"""Test a UnitDbl for a non-zero value.

= RETURN VALUE
- Returns true if the value is non-zero.
"""
if six.PY3:
return self._value.__bool__()
else:
return self._value.__nonzero__()

if six.PY3:
__bool__ = __nonzero__
def __bool__(self):
"""Return the truth value of a UnitDbl."""
return bool(self._value)

# ----------------------------------------------------------------------
def __eq__(self, rhs):
Expand Down Expand Up @@ -292,9 +278,9 @@ def checkUnits(self, units):
- units The string name of the units to check.
"""
if units not in self.allowed:
msg = "Input units '%s' are not one of the supported types of %s" \
% (units, str(list(six.iterkeys(self.allowed))))
raise ValueError(msg)
raise ValueError("Input units '%s' are not one of the supported "
"types of %s" % (
units, list(self.allowed.keys())))

# ----------------------------------------------------------------------
def checkSameUnits(self, rhs, func):
Expand Down
18 changes: 5 additions & 13 deletions 18 lib/matplotlib/testing/jpl_units/UnitDblConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
# ==========================================================================
# Place all imports after here.
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import numpy as np
import matplotlib.units as units
import matplotlib.projections.polar as polar
Expand Down Expand Up @@ -75,11 +70,8 @@ def axisinfo(unit, axis):
# Check to see if the value used for units is a string unit value
# or an actual instance of a UnitDbl so that we can use the unit
# value for the default axis label value.
if (unit):
if (isinstance(unit, six.string_types)):
label = unit
else:
label = unit.label()
if unit:
label = unit if isinstance(unit, str) else unit.label()
else:
label = None

Expand Down Expand Up @@ -109,8 +101,8 @@ def convert(value, unit, axis):

isNotUnitDbl = True

if (iterable(value) and not isinstance(value, six.string_types)):
if (len(value) == 0):
if iterable(value) and not isinstance(value, str):
if len(value) == 0:
return []
else:
return [UnitDblConverter.convert(x, unit, axis) for x in value]
Expand Down Expand Up @@ -153,7 +145,7 @@ def default_units(value, axis):

# Determine the default units based on the user preferences set for
# default units when printing a UnitDbl.
if (iterable(value) and not isinstance(value, six.string_types)):
if iterable(value) and not isinstance(value, str):
return UnitDblConverter.default_units(value[0], axis)
else:
return UnitDblConverter.defaults[value.type()]
3 changes: 0 additions & 3 deletions 3 lib/matplotlib/testing/jpl_units/UnitDblFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
# ==========================================================================
# Place all imports after here.
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import matplotlib.ticker as ticker
#
# Place all imports before here.
Expand Down
2 changes: 0 additions & 2 deletions 2 lib/matplotlib/testing/jpl_units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
"""

# ======================================================================
from __future__ import (absolute_import, division, print_function,
unicode_literals)

from .Duration import Duration
from .Epoch import Epoch
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.