boutproject / xBOUT

Collects BOUT++ data from parallelized simulations into xarray.
https://xbout.readthedocs.io/en/latest/
Apache License 2.0
21 stars 8 forks source link

Tests fail with Matplotlib 3.7 #279

Closed QuLogic closed 1 year ago

QuLogic commented 1 year ago

Surprisingly, there is only one failure:

__________________ TestAnimate.test_animate_list_1d_multiline __________________

self = <xbout.tests.test_animate.TestAnimate object at 0x7fa5e0523d50>
create_test_file = (PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_data24'), <xarray.Dataset>
Dimensions:  (t: 6, x: 6, y: 12, z: 7)
C...:
    metadata:  {'BOUT_VERSION': 4.3, 'use_metric_3d': 0, 'NXPE': 3, 'NYPE': 3...
    options:   None
    geometry:  )

    def test_animate_list_1d_multiline(self, create_test_file):

        save_dir, ds = create_test_file

        animation = ds.isel(y=2, z=3).bout.animate_list(
            [["n", "T"], ds["T"].isel(x=2), ds["n"].isel(y=1, z=2)]
        )

        assert len(animation.blocks) == 4
        assert isinstance(animation.blocks[0], Line)
        assert isinstance(animation.blocks[1], Line)
        assert isinstance(animation.blocks[2], Pcolormesh)
        assert isinstance(animation.blocks[3], Line)

        # check there were actually 3 subplots
>       assert (
            len(
                [
                    x
                    for x in plt.gcf().get_axes()
                    if isinstance(x, matplotlib.axes.Subplot)
                ]
            )
            == 3
        )
E       AssertionError: assert 8 == 3
E        +  where 8 = len([<Axes: title={'center': 'T'}, xlabel='x', ylabel='T'>, <Axes: title={'center': 'T'}, xlabel='y', ylabel='z'>, <Axes: title={'center': 'n'}, xlabel='x', ylabel='n'>, <Axes: >, <Axes: ylabel='T'>, <Axes: >, ...])

xbout/tests/test_animate.py:199: AssertionError
---------------------------- Captured stdout setup -----------------------------
Read in:
<xbout.BoutDataset>
Contains:
<xarray.Dataset>
Dimensions:  (t: 6, x: 6, y: 12, z: 7)
Coordinates:
    dx       (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    dy       (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    dz       float64 0.8976
  * t        (t) float64 0.0 10.0 20.0 30.0 40.0 50.0
  * x        (x) int64 0 1 2 3 4 5
  * y        (y) float64 1.0 3.0 5.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0 21.0 23.0
  * z        (z) float64 0.0 0.8976 1.795 2.693 3.59 4.488 5.386
Data variables: (12/21)
    n        (t, x, y, z) float64 dask.array<chunksize=(6, 2, 4, 7), meta=np.ndarray>
    T        (t, x, y, z) float64 dask.array<chunksize=(6, 2, 4, 7), meta=np.ndarray>
    S        (t, x, y) float64 dask.array<chunksize=(6, 2, 4), meta=np.ndarray>
    g11      (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    g22      (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    g33      (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    ...       ...
    G1       (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    G2       (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    G3       (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    J        (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    Bxy      (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
    zShift   (x, y) float64 dask.array<chunksize=(2, 4), meta=np.ndarray>
Attributes:
    metadata:  {'BOUT_VERSION': 4.3, 'use_metric_3d': 0, 'NXPE': 3, 'NYPE': 3...
    options:   None
    geometry:  
Metadata:
{   'BOUT_VERSION': 4.3,
    'MXG': 0,
    'MXSUB': 2,
    'MYG': 0,
    'MYSUB': 4,
    'MZ': 7,
    'MZG': 0,
    'MZSUB': 7,
    'NXPE': 3,
    'NYPE': 3,
    'NZPE': 1,
    'ZMAX': 1.0,
    'ZMIN': 0.0,
    'bout_tdim': 't',
    'bout_xdim': 'x',
    'bout_ydim': 'y',
    'bout_zdim': 'z',
    'fine_interpolation_factor': 8,
    'hist_hi': 5,
    'is_restart': 0,
    'iteration': 5,
    'ixseps1': 6,
    'ixseps2': 6,
    'jyseps1_1': -1,
    'jyseps1_2': 5,
    'jyseps2_1': 5,
    'jyseps2_2': 11,
    'keep_xboundaries': 1,
    'keep_yboundaries': 0,
    'nx': 6,
    'ny': 12,
    'ny_inner': 6,
    'nz': 7,
    'tt': 50.0,
    'use_metric_3d': 0,
    'zperiod': 1}

I believe this is related to the merging of SubplotBase into AxesBase so that now the parasite Axes from mpl_toolkits are now regular Axes.

johnomotani commented 1 year ago

Fixed in #278.