Skip to content

Commit

Permalink
Merge pull request #383 from lkluft/fix-tests
Browse files Browse the repository at this point in the history
Fix broken matplotlib tests
  • Loading branch information
olemke authored May 19, 2021
2 parents 39b6f0a + acd3284 commit 59ca873
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
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

0 comments on commit 59ca873

Please sign in to comment.