Skip to content
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

Fix broken matplotlib tests #383

Merged
merged 2 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion typhon/plots/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def profile_p(p, x, ax=None, **kwargs):

# Label and format for yaxis.
formatter.set_yaxis_formatter(formatter.HectoPascalFormatter(), ax=ax)
if ax.is_first_col():
if ax.get_subplotspec().is_first_col():
ax.set_ylabel('Pressure [hPa]')

# Actual plot.
Expand Down
14 changes: 8 additions & 6 deletions typhon/tests/plots/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,24 @@ def test_cmap2act(self):

def test_cmap_from_txt(self):
"""Import colormap from txt file."""
idx = np.linspace(0, 1, 256)

viridis = plt.get_cmap('viridis')
cmap = colors.cmap_from_txt(os.path.join(self.ref_dir, 'viridis.txt'))

plt.register_cmap(cmap=viridis) # Register original viridis.
cmap = colors.cmap_from_txt(os.path.join(
self.ref_dir, 'viridis.txt'), name="viridis_read")

idx = np.linspace(0, 1, 256)
assert np.allclose(viridis(idx), cmap(idx), atol=0.001)

def test_cmap_from_act(self):
"""Import colormap from act file."""
idx = np.linspace(0, 1, 256)

viridis = plt.get_cmap('viridis')
cmap = colors.cmap_from_act(os.path.join(self.ref_dir, 'viridis.act'))

plt.register_cmap(cmap=viridis) # Register original viridis.
cmap = colors.cmap_from_act(
os.path.join(self.ref_dir, 'viridis.act'), name="viridis_read")

idx = np.linspace(0, 1, 256)
assert np.allclose(viridis(idx), cmap(idx), atol=0.004)

def test_get_material_design(self):
Expand Down