[Debian-astro-maintainers] Bug#1074625: astroml: fails tests with matplotlib 3.8
Drew Parsons
dparsons at debian.org
Tue Jul 2 10:56:39 BST 2024
Source: astroml
Version: 1.0.2-4
Severity: normal
astroml is failing debci tests with matplotlib 3.8 from experimental
95s =================================== FAILURES ===================================
95s ____________________________ test_devectorize_axes _____________________________
95s
95s def test_devectorize_axes():
95s np.random.seed(0)
95s
95s x, y = np.random.random((2, 1000))
95s
95s # save vectorized version
95s fig = plt.figure()
95s ax = fig.add_subplot(111)
95s ax.scatter(x, y)
95s output = BytesIO()
95s fig.savefig(output)
95s output.seek(0)
95s im1 = image.imread(output)
95s plt.close()
95s
95s # save devectorized version
95s fig = plt.figure()
95s ax = fig.add_subplot(111)
95s ax.scatter(x, y)
95s > devectorize_axes(ax, dpi=200)
95s
95s /usr/lib/python3/dist-packages/astroML/plotting/tests/test_devectorize.py:35:
95s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
95s
95s ax = <Axes: >, dpi = 200, transparent = True
95s
95s def devectorize_axes(ax=None, dpi=None, transparent=True):
95s """Convert axes contents to a png.
95s
95s This is useful when plotting many points, as the size of the saved file
95s can become very large otherwise.
95s
95s Parameters
95s ----------
95s ax : Axes instance (optional)
95s Axes to de-vectorize. If None, this uses the current active axes
95s (plt.gca())
95s dpi: int (optional)
95s resolution of the png image. If not specified, the default from
95s 'savefig.dpi' in rcParams will be used
95s transparent : bool (optional)
95s if True (default) then the PNG will be made transparent
95s
95s Returns
95s -------
95s ax : Axes instance
95s the in-place modified Axes instance
95s
95s Examples
95s --------
95s The code can be used in the following way::
95s
95s >>> import matplotlib.pyplot as plt
95s >>> import numpy as np
95s >>> from astroML.plotting.tools import devectorize_axes
95s >>> fig, ax = plt.subplots()
95s >>> x, y = np.random.random((2, 10000))
95s >>> ax.scatter(x, y) # doctest: +IGNORE_OUTPUT
95s >>> devectorize_axes(ax) # doctest: +IGNORE_OUTPUT
95s
95s The resulting figure will be much smaller than the vectorized version.
95s """
95s if ax is None:
95s ax = plt.gca()
95s
95s fig = ax.figure
95s axlim = ax.axis()
95s
95s # setup: make all visible spines (axes & ticks) & text invisible
95s # we need to set these back later, so we save their current state
95s _sp = {}
95s _txt_vis = [t.get_visible() for t in ax.texts]
95s for k in ax.spines:
95s _sp[k] = ax.spines[k].get_visible()
95s ax.spines[k].set_visible(False)
95s for t in ax.texts:
95s t.set_visible(False)
95s
95s _xax = ax.xaxis.get_visible()
95s _yax = ax.yaxis.get_visible()
95s _patch = ax.patch.get_visible()
95s ax.patch.set_visible(False)
95s ax.xaxis.set_visible(False)
95s ax.yaxis.set_visible(False)
95s
95s # convert canvas to PNG
95s extents = ax.bbox.extents / fig.dpi
95s output = BytesIO()
95s plt.savefig(output, format='png', dpi=dpi,
95s transparent=transparent,
95s bbox_inches=Bbox([extents[:2], extents[2:]]))
95s output.seek(0)
95s im = image.imread(output)
95s
95s # clear everything on axis (but not text)
95s > ax.lines.clear()
95s E AttributeError: 'ArtistList' object has no attribute 'clear'
95s
95s /usr/lib/python3/dist-packages/astroML/plotting/tools.py:81: AttributeError
More information about the Debian-astro-maintainers
mailing list