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

Test incompatible with matplotlib 3.8.0 #22

Open
duncanmmacleod opened this issue Jan 16, 2024 · 0 comments
Open

Test incompatible with matplotlib 3.8.0 #22

duncanmmacleod opened this issue Jan 16, 2024 · 0 comments

Comments

@duncanmmacleod
Copy link
Contributor

Describe the bug

The test/test_drivers.py::test_plotting test is incompatible with matploitlib >= 3.8.0 resulting in an AttributeError:

================================== FAILURES ===================================
________________________________ test_plotting ________________________________

    def test_plotting():
        # Model definitions
        # =================
        # Define a simple straight line function, parameters theta=(m,c)
        def f(x, theta):
            m, c = theta
            return m * x + c

        numpy.random.seed(1)

        # Posterior samples
        nsamples = 1000
        ms = numpy.random.normal(loc=-5, scale=1, size=nsamples)
        cs = numpy.random.normal(loc=2, scale=1, size=nsamples)
        samples = numpy.array([(m, c) for m, c in zip(ms, cs)]).copy()

        # Prior samples
        ms = numpy.random.normal(loc=0, scale=5, size=nsamples)
        cs = numpy.random.normal(loc=0, scale=5, size=nsamples)
        prior_samples = numpy.array([(m, c) for m, c in zip(ms, cs)]).copy()

        # Examine the function over a range of x's
        xmin, xmax = -2, 2
        nx = 100
        x = numpy.linspace(xmin, xmax, nx)

        # Set the cache
        for cache in [None, 'cache/test']:
            if cache is not None:
                prior_cache = cache + '_prior'
            else:
                prior_cache = None

            # Plotting
            # ========
            fig, axes = plt.subplots(2, 2)

            # Sample plot
            # -----------
            ax_samples = axes[0, 0]
            ax_samples.set_ylabel(r'$c$')
            ax_samples.set_xlabel(r'$m$')
            ax_samples.plot(prior_samples.T[0], prior_samples.T[1], 'b.')
            ax_samples.plot(samples.T[0], samples.T[1], 'r.')

            # Line plot
            # ---------
            ax_lines = axes[0, 1]
            ax_lines.set_ylabel(r'$y = m x + c$')
            ax_lines.set_xlabel(r'$x$')
            plot_lines(f, x, prior_samples, ax_lines, color='b', cache=prior_cache)
            plot_lines(f, x, samples, ax_lines, color='r', cache=cache)

            # Predictive posterior plot
            # -------------------------
            ax_fgivenx = axes[1, 1]
            ax_fgivenx.set_ylabel(r'$P(y|x)$')
            ax_fgivenx.set_xlabel(r'$x$')
            plot_contours(f, x, prior_samples, ax_fgivenx,
                          colors=plt.cm.Blues_r, lines=False,
                          cache=prior_cache)
            plot_contours(f, x, samples, ax_fgivenx, cache=cache)

            # DKL plot
            # --------
            ax_dkl = axes[1, 0]
            ax_dkl.set_ylabel(r'$D_\mathrm{KL}$')
            ax_dkl.set_xlabel(r'$x$')
            ax_dkl.set_ylim(bottom=0)
            plot_dkl(f, x, samples, prior_samples, ax_dkl,
                     cache=cache, prior_cache=prior_cache)

>           ax_lines.get_shared_x_axes().join(ax_lines, ax_fgivenx, ax_samples)
E           AttributeError: 'GrouperView' object has no attribute 'join'

To Reproduce
Steps to reproduce the behavior:

conda create --name fgivenx python=3.11 fgivenx matplotlib-base=3.8.0 pytest
conda activate fgivenx
python3 -m pytest --pyargs fgivenx

Expected behavior

The test doesn't fail.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

duncanmmacleod added a commit to regro-cf-autotick-bot/fgivenx-feedstock that referenced this issue Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant