-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
str_angles and scale_units logic for quiver #8670
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -626,19 +626,19 @@ def _angles_lengths(self, U, V, eps=1): | |
|
||
def _make_verts(self, U, V, angles): | ||
uv = (U + V * 1j) | ||
str_angles = isinstance(angles, six.string_types) | ||
if str_angles and (angles == 'xy' and self.scale_units == 'xy'): | ||
str_angles = angles if isinstance(angles, six.string_types) else '' | ||
if str_angles == 'xy' and self.scale_units == 'xy': | ||
# Here eps is 1 so that if we get U, V by diffing | ||
# the X, Y arrays, the vectors will connect the | ||
# points, regardless of the axis scaling (including log). | ||
angles, lengths = self._angles_lengths(U, V, eps=1) | ||
elif str_angles and (angles == 'xy' or self.scale_units == 'xy'): | ||
elif str_angles == 'xy' or self.scale_units == 'xy': | ||
# Calculate eps based on the extents of the plot | ||
# so that we don't end up with roundoff error from | ||
# adding a small number to a large. | ||
eps = np.abs(self.ax.dataLim.extents).max() * 0.001 | ||
angles, lengths = self._angles_lengths(U, V, eps=eps) | ||
if self.scale_units == 'xy': | ||
if str_angles and self.scale_units == 'xy': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this extra bit need to go in - if str_angles is a string does this even make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should avoid throwing issue 2 is str_angles == '', doesn't it ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the real question is whether this should apply to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, all the scalings except 'xy' are based on U and V, so I guess I it sufficient to leave it like that. throwing an exception on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Appears that |
||
a = lengths | ||
else: | ||
a = np.abs(uv) | ||
|
@@ -665,9 +665,9 @@ def _make_verts(self, U, V, angles): | |
self.scale = scale * widthu_per_lenu | ||
length = a * (widthu_per_lenu / (self.scale * self.width)) | ||
X, Y = self._h_arrows(length) | ||
if str_angles and (angles == 'xy'): | ||
if str_angles == 'xy': | ||
theta = angles | ||
elif str_angles and (angles == 'uv'): | ||
elif str_angles == 'uv': | ||
theta = np.angle(uv) | ||
else: | ||
theta = ma.masked_invalid(np.deg2rad(angles)).filled(0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing why this change is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build mpl on latest commit 1144e8c on branch master
before.pdf
after.pdf
this block l. 668 is now wrong:
since variable angles is overridden by
angles, lengths = self._angles_lengths(U, V, eps=1)
the cited commit d705dbd screws up the whole quiver logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay. In that case,
if str_angles and str_angles == 'some string':
is redundant now; it can just beif str_angles == 'some string':
.Please add a test as well; something similar to your example will probably work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not, str_angles is here to avoid the
FutureWarning: elementwise comparison failed
cited above and was introduced in #6971I tried to stick with the existant ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this line has changed it so that
str_angles
is always a string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but the empty string evaluates to False (as in
print('foo' if '' else 'bar')
), thus short-circuiting the angles == 'xy' test, which can eventually throw a warning.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you've replaced all the
angles ==
withstr_angles ==
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha yes I see it now, stupid me it's getting late here ...