8000 Improve reprs of transforms. by anntzer · Pull Request #9421 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Improve reprs of transforms. #9421

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 7 commits into from
Dec 1, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add fancy repr to Polar transforms.
  • Loading branch information
QuLogic authored and anntzer committed Nov 19, 2017
commit 862909c90ff103a35fdeeaccce4ba15103ecf7f4
60 changes: 57 addition 10000 s & 3 deletions lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ def __init__(self, axis=None, use_rmin=True,
self._use_rmin = use_rmin
self._apply_theta_transforms = _apply_theta_transforms

def __str__(self):
return ("{}(\n"
"{},\n"
" use_rmin={},\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a slightly preference for this string not to be indented, or remove the explicit spaces and call indent_str for use_rmin too (either way). The idea was to make the source layout "look like" the final result. Same comment throughout.

" _apply_theta_transforms={})"
.format(type(self).__name__,
mtransforms._indent_str(self._axis),
self._use_rmin,
self._apply_theta_transforms))

__repr__ = __str__

def transform_non_affine(self, tr):
xy = np.empty(tr.shape, float)

Expand Down Expand Up @@ -95,6 +107,16 @@ def __init__(self, scale_transform, limits):
self.set_children(scale_transform, limits)
self._mtx = None

def __str__(self):
return ("{}(\n"
"{},\n"
"{})"
.format(type(self).__name__,
mtransforms._indent_str(self._scale_transform),
mtransforms._indent_str(self._limits)))

__repr__ = __str__

def get_matrix(self):
if self._invalid:
limits_scaled = self._limits.transformed(self._scale_transform)
Expand Down Expand Up @@ -125,6 +147,18 @@ def __init__(self, axis=None, use_rmin=True,
self._use_rmin = use_rmin
self._apply_theta_transforms = _apply_theta_transforms

def __str__(self):
return ("{}(\n"
"{},\n"
" use_rmin={},\n"
" _apply_theta_transforms={})"
.format(type(self).__name__,
mtransforms._indent_str(self._axis),
self._use_rmin,
self._apply_theta_transforms))

__repr__ = __str__

def transform_non_affine(self, xy):
x = xy[:, 0:1]
y = xy[:, 1:]
Expand Down Expand Up @@ -459,6 +493,18 @@ def __init__(self, axes, pad, mode):
self.mode = mode
self.pad = pad

def __str__(self):
return ("{}(\n"
"{},\n"
"{},\n"
"{})"
.format(type(self).__name__,
mtransforms._indent_str(self.axes),
mtransforms._indent_str(self.pad),
mtransforms._indent_str(repr(self.mode))))

__repr__ = __str__

def get_matrix(self):
if self._invalid:
if self.mode == 'rlabel':
Expand Down Expand Up @@ -697,9 +743,17 @@ def __init__(self, center, viewLim, originLim, **kwargs):
self._originLim = originLim
self.set_children(viewLim, originLim)

def __repr__(self):
return "_WedgeBbox(%r, %r, %r)" % (self._center, self._viewLim,
self._originLim)
def __str__(self):
return ("{}(\n"
"{},\n"
"{},\n"
"{})"
.format(type(self).__name__,
mtransforms._indent_str(self._center),
mtransforms._indent_str(self._viewLim),
mtransforms._indent_str(self._originLim)))

__repr__ = __str__

def get_points(self):
if self._invalid:
Expand Down
0