Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 332d31d

Browse files
committed
Separate shared_axis tests
1 parent fb76ed7 commit 332d31d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lib/matplotlib/tests/test_units.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ def test_jpl_bar_units():
128128
units.register()
129129

130130
day = units.Duration("ET", 24.0 * 60.0 * 60.0)
131-
x = [0*units.km, 1*units.km, 2*units.km]
132-
w = [1*day, 2*day, 3*day]
131+
x = [0 * units.km, 1 * units.km, 2 * units.km]
132+
w = [1 * day, 2 * day, 3 * day]
133133
b = units.Epoch("ET", dt=datetime(2009, 4, 25))
134134
fig, ax = plt.subplots()
135135
ax.bar(x, w, bottom=b)
136-
ax.set_ylim([b-1*day, b+w[-1]+(1.001)*day])
136+
ax.set_ylim([b - 1 * day, b + w[-1] + (1.001) * day])
137137

138138

139139
@image_comparison(['jpl_barh_units.png'],
@@ -143,13 +143,13 @@ def test_jpl_barh_units():
143143
units.register()
144144

145145
day = units.Duration("ET", 24.0 * 60.0 * 60.0)
146-
x = [0*units.km, 1*units.km, 2*units.km]
147-
w = [1*day, 2*day, 3*day]
146+
x = [0 * units.km, 1 * units.km, 2 * units.km]
147+
w = [1 * day, 2 * day, 3 * day]
148148
b = units.Epoch("ET", dt=datetime(2009, 4, 25))
149149

150150
fig, ax = plt.subplots()
151151
ax.barh(x, w, left=b)
152-
ax.set_xlim([b-1*day, b+w[-1]+(1.001)*day])
152+
ax.set_xlim([b - 1 * day, b + w[-1] + (1.001) * day])
153153

154154

155155
def test_empty_arrays():
@@ -175,7 +175,7 @@ class subdate(datetime):
175175
fig_ref.subplots().plot(datetime(2000, 1, 1), 0, "o")
176176

177177

178-
def test_set_xyunits(quantity_converter):
178+
def test_shared_axis_quantity(quantity_converter):
179179
munits.registry[Quantity] = quantity_converter
180180
x = Quantity(np.linspace(0, 1, 10), "hours")
181181
y1 = Quantity(np.linspace(1, 2, 10), "feet")
@@ -189,13 +189,21 @@ def test_set_xyunits(quantity_converter):
189189
ax2.yaxis.set_units("inches")
190190
assert ax1.xaxis.get_units() == ax2.xaxis.get_units() == "seconds"
191191
assert ax1.yaxis.get_units() == ax2.yaxis.get_units() == "inches"
192+
193+
194+
def test_shared_axis_datetime():
195+
# datetime uses dates.DateConverter
192196
y1 = [datetime(2020, i, 1, tzinfo=timezone.utc) for i in range(1, 13)]
193197
y2 = [datetime(2021, i, 1, tzinfo=timezone.utc) for i in range(1, 13)]
194198
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
195199
ax1.plot(y1)
196200
ax2.plot(y2)
197201
ax1.yaxis.set_units(timezone(timedelta(hours=5)))
198202
assert ax2.yaxis.units == timezone(timedelta(hours=5))
203+
204+
205+
def test_shared_axis_categorical():
206+
# str uses category.StrCategoryConverter
199207
d1 = {"a": 1, "b": 2}
200208
d2 = {"a": 3, "b": 4}
201209
fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True)

0 commit comments

Comments
 (0)