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

Commit d9169cb

Browse filesBrowse files
committed
Add test for axis label when units set
Fix indentation
1 parent 91dd120 commit d9169cb
Copy full SHA for d9169cb

File tree

Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed

‎lib/matplotlib/testing/jpl_units/UnitDbl.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/jpl_units/UnitDbl.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def __bool__(self):
9191

9292
def _cmp(self, op, rhs):
9393
"""Check that *self* and *rhs* share units; compare them using *op*."""
94+
if rhs is None:
95+
return NotImplemented
9496
self.checkSameUnits(rhs, "compare")
9597
return op(self._value, rhs._value)
9698

‎lib/matplotlib/tests/test_units.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_units.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,23 @@ def test_plot_kernel():
283283
# just a smoketest that fail
284284
kernel = Kernel([1, 2, 3, 4, 5])
285285
plt.plot(kernel)
286+
287+
288+
@check_figures_equal(extensions=['png'])
289+
def test_unit_axis_label(fig_test, fig_ref):
290+
import matplotlib.testing.jpl_units as units
291+
units.register()
292+
293+
data = [0 * units.km, 1 * units.km, 2 * units.km]
294+
295+
ax_test = fig_test.subplots()
296+
ax_ref = fig_ref.subplots()
297+
axs = [ax_test, ax_ref]
298+
299+
for ax in axs:
300+
ax.yaxis.set_units('km')
301+
ax.set_xlim(10, 20)
302+
ax.set_ylim(10, 20)
303+
304+
ax_test.scatter([1, 2, 3], data, edgecolors='none')
305+
ax_ref.plot([1, 2, 3], data, marker='o', linewidth=0)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.