Skip to content

Commit

Permalink
STY: x.__class__ to type(x) #batch-6 (pandas-dev#29905)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaharNaveh authored and proost committed Dec 19, 2019
1 parent 7792723 commit 968beb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
9 changes: 4 additions & 5 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,8 @@ def apply_index(self, i):

if type(self) is not DateOffset:
raise NotImplementedError(
"DateOffset subclass {name} "
"does not have a vectorized "
"implementation".format(name=self.__class__.__name__)
f"DateOffset subclass {type(self).__name__} "
"does not have a vectorized implementation"
)
kwds = self.kwds
relativedelta_fast = {
Expand Down Expand Up @@ -402,7 +401,7 @@ def rollback(self, dt):
"""
dt = as_timestamp(dt)
if not self.onOffset(dt):
dt = dt - self.__class__(1, normalize=self.normalize, **self.kwds)
dt = dt - type(self)(1, normalize=self.normalize, **self.kwds)
return dt

def rollforward(self, dt):
Expand All @@ -416,7 +415,7 @@ def rollforward(self, dt):
"""
dt = as_timestamp(dt)
if not self.onOffset(dt):
dt = dt + self.__class__(1, normalize=self.normalize, **self.kwds)
dt = dt + type(self)(1, normalize=self.normalize, **self.kwds)
return dt

def onOffset(self, dt):
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/_depr_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, deprmod, deprmodto=None, removals=None, moved=None):
self.moved = moved

# For introspection purposes.
self.self_dir = frozenset(dir(self.__class__))
self.self_dir = frozenset(dir(type(self)))

def __dir__(self):
deprmodule = self._import_deprmod()
Expand Down
18 changes: 9 additions & 9 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def repr_class(x):
return x

try:
return x.__class__.__name__
return type(x).__name__
except AttributeError:
return repr(type(x))

Expand Down Expand Up @@ -780,17 +780,17 @@ def assert_is_valid_plot_return_object(objs):
if isinstance(objs, (pd.Series, np.ndarray)):
for el in objs.ravel():
msg = (
"one of 'objs' is not a matplotlib Axes instance, type "
"encountered {name!r}"
).format(name=el.__class__.__name__)
"one of 'objs' is not a matplotlib Axes instance, "
f"type encountered {repr(type(el).__name__)}"
)
assert isinstance(el, (plt.Axes, dict)), msg
else:
assert isinstance(objs, (plt.Artist, tuple, dict)), (
"objs is neither an ndarray of Artist instances nor a "
'single Artist instance, tuple, or dict, "objs" is a {name!r}'.format(
name=objs.__class__.__name__
)
msg = (
"objs is neither an ndarray of Artist instances nor a single "
"ArtistArtist instance, tuple, or dict, 'objs' is a "
f"{repr(type(objs).__name__)}"
)
assert isinstance(objs, (plt.Artist, tuple, dict)), msg


def isiterable(obj):
Expand Down

0 comments on commit 968beb1

Please sign in to comment.