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

RFC: avoid pyplot interface in tests (1/2) #365

Merged
Merged
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
15 changes: 9 additions & 6 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os

import matplotlib.pyplot as plt
import numpy.testing as npt
import pytest
from matplotlib.colors import SymLogNorm
from matplotlib.figure import Figure

from nonos.api import GasDataSet, compute, find_nearest, from_data
from nonos.main import main
Expand Down Expand Up @@ -104,11 +104,12 @@ def test_plot_planet_corotation(test_data_dir):
assert find_nearest(azimfieldPlanet, azimfieldPlanet.max()) == 0


def test_unit_conversion(test_data_dir, temp_figure_and_axis):
def test_unit_conversion(test_data_dir):
os.chdir(test_data_dir / "idefix_planet3d")

ds = GasDataSet(43, geometry="polar")
fig, ax = temp_figure_and_axis
fig = Figure()
ax = fig.add_subplot()

plotfield10 = (
ds["RHO"]
Expand All @@ -121,9 +122,10 @@ def test_unit_conversion(test_data_dir, temp_figure_and_axis):
npt.assert_allclose(plotfield10.get_array(), 10 * plotfield.get_array())


def test_vmin_vmax_api(test_data_dir, temp_figure_and_axis):
def test_vmin_vmax_api(test_data_dir):
ds = GasDataSet(1, directory=test_data_dir / "idefix_rwi", geometry="polar")
fig, ax = temp_figure_and_axis
fig = Figure()
ax = fig.add_subplot()
p = ds["VX1"].vertical_at_midplane().map("R", "phi")

# check that no warning is emitted from matplotlib
Expand Down Expand Up @@ -194,5 +196,6 @@ def test_corotation_api_float(test_data_dir):
)
def test_reg(test_data_dir, map_args):
ds = GasDataSet(23, directory=test_data_dir / "idefix_newvtk_planet2d")
fig, ax = plt.subplots()
fig = Figure()
ax = fig.add_subplot()
ds["RHO"].map(*map_args).plot(fig, ax)