Bug 1914285

Summary: python-mplcairo: FTBFS in Fedora rawhide: RuntimeWarning: divide by zero encountered in log10
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-mplcairoAssignee: Elliott Sales de Andrade <quantum.analyst>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: python-sig, quantum.analyst
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: https://koschei.fedoraproject.org/package/python-mplcairo
Whiteboard:
Fixed In Version: python-mplcairo-0.4-1.fc33 python-mplcairo-0.4-1.fc34 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-04-19 17:44:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1921574    
Bug Blocks: 1868278, 1890881    

Description Tomáš Hrnčiar 2021-01-08 14:27:28 UTC
Description of problem:
Package python-mplcairo fails to build from source in Fedora rawhide.

Version-Release number of selected component (if applicable):
0.3-4.fc33

Steps to Reproduce:
koji build --scratch f34 python-mplcairo-0.3-4.fc33.src.rpm

Additional info:
This package is tracked by Koschei. See:
https://koschei.fedoraproject.org/package/python-mplcairo

=================================== FAILURES ===================================
____________________________ test_specgram_fs_none _____________________________
[gw4] linux -- Python 3.9.1 /usr/bin/python3
    def test_specgram_fs_none():
        """Test axes.specgram when Fs is None, should not throw error."""
>       spec, freqs, t, im = plt.specgram(np.ones(300), Fs=None)
/usr/lib64/python3.9/site-packages/matplotlib/tests/test_axes.py:4155: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.9/site-packages/matplotlib/pyplot.py:2919: in specgram
    __ret = gca().specgram(
/usr/lib64/python3.9/site-packages/matplotlib/__init__.py:1427: in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <AxesSubplot:>
x = array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
       1., 1., 1., 1., 1., 1., 1., 1., 1., ...1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
       1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])
NFFT = 256, Fs = 2, Fc = 0, detrend = None, window = None, noverlap = 128
cmap = None, xextent = None, pad_to = None, sides = None, scale_by_freq = None
mode = None, scale = 'dB', vmin = None, vmax = None, kwargs = {}
spec = array([[8.50000000e+01],
       [4.29996400e+01],
       [2.96562495e-04],
       [4.15570832e-05],
       [1.18056850... [1.45740501e-13],
       [8.18349917e-14],
       [3.63254653e-14],
       [9.07452846e-15],
       [0.00000000e+00]])
freqs = array([0.       , 0.0078125, 0.015625 , 0.0234375, 0.03125  , 0.0390625,
       0.046875 , 0.0546875, 0.0625   , 0.070...6875,
       0.9375   , 0.9453125, 0.953125 , 0.9609375, 0.96875  , 0.9765625,
       0.984375 , 0.9921875, 1.       ])
t = array([64.])
    @_preprocess_data(replace_names=["x"])
    @docstring.dedent_interpd
    def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
                 window=None, noverlap=None,
                 cmap=None, xextent=None, pad_to=None, sides=None,
                 scale_by_freq=None, mode=None, scale=None,
                 vmin=None, vmax=None, **kwargs):
        """
        Plot a spectrogram.
    
        Compute and plot a spectrogram of data in *x*.  Data are split into
        *NFFT* length segments and the spectrum of each section is
        computed.  The windowing function *window* is applied to each
        segment, and the amount of overlap of each segment is
        specified with *noverlap*. The spectrogram is plotted as a colormap
        (using imshow).
    
        Parameters
        ----------
        x : 1-D array or sequence
            Array or sequence containing the data.
    
        %(Spectral)s
    
        %(PSD)s
    
        mode : {'default', 'psd', 'magnitude', 'angle', 'phase'}
            What sort of spectrum to use.  Default is 'psd', which takes the
            power spectral density.  'magnitude' returns the magnitude
            spectrum.  'angle' returns the phase spectrum without unwrapping.
            'phase' returns the phase spectrum with unwrapping.
    
        noverlap : int
            The number of points of overlap between blocks.  The
            default value is 128.
    
        scale : {'default', 'linear', 'dB'}
            The scaling of the values in the *spec*.  'linear' is no scaling.
            'dB' returns the values in dB scale.  When *mode* is 'psd',
            this is dB power (10 * log10).  Otherwise this is dB amplitude
            (20 * log10). 'default' is 'dB' if *mode* is 'psd' or
            'magnitude' and 'linear' otherwise.  This must be 'linear'
            if *mode* is 'angle' or 'phase'.
    
        Fc : int, default: 0
            The center frequency of *x*, which offsets the x extents of the
            plot to reflect the frequency range used when a signal is acquired
            and then filtered and downsampled to baseband.
    
        cmap : `.Colormap`, default: :rc:`image.cmap`
    
        xextent : *None* or (xmin, xmax)
            The image extent along the x-axis. The default sets *xmin* to the
            left border of the first bin (*spectrum* column) and *xmax* to the
            right border of the last bin. Note that for *noverlap>0* the width
            of the bins is smaller than those of the segments.
    
        **kwargs
            Additional keyword arguments are passed on to `~.axes.Axes.imshow`
            which makes the specgram image.
    
        Returns
        -------
        spectrum : 2-D array
            Columns are the periodograms of successive segments.
    
        freqs : 1-D array
            The frequencies corresponding to the rows in *spectrum*.
    
        t : 1-D array
            The times corresponding to midpoints of segments (i.e., the columns
            in *spectrum*).
    
        im : `.AxesImage`
            The image created by imshow containing the spectrogram.
    
        See Also
        --------
        psd
            Differs in the default overlap; in returning the mean of the
            segment periodograms; in not returning times; and in generating a
            line plot instead of colormap.
        magnitude_spectrum
            A single spectrum, similar to having a single segment when *mode*
            is 'magnitude'. Plots a line instead of a colormap.
        angle_spectrum
            A single spectrum, similar to having a single segment when *mode*
            is 'angle'. Plots a line instead of a colormap.
        phase_spectrum
            A single spectrum, similar to having a single segment when *mode*
            is 'phase'. Plots a line instead of a colormap.
    
        Notes
        -----
        The parameters *detrend* and *scale_by_freq* do only apply when *mode*
        is set to 'psd'.
        """
        if NFFT is None:
            NFFT = 256  # same default as in mlab.specgram()
        if Fc is None:
            Fc = 0  # same default as in mlab._spectral_helper()
        if noverlap is None:
            noverlap = 128  # same default as in mlab.specgram()
        if Fs is None:
            Fs = 2  # same default as in mlab._spectral_helper()
    
        if mode == 'complex':
            raise ValueError('Cannot plot a complex specgram')
    
        if scale is None or scale == 'default':
            if mode in ['angle', 'phase']:
                scale = 'linear'
            else:
                scale = 'dB'
        elif mode in ['angle', 'phase'] and scale == 'dB':
            raise ValueError('Cannot use dB scale with angle or phase mode')
    
        spec, freqs, t = mlab.specgram(x=x, NFFT=NFFT, Fs=Fs,
                                       detrend=detrend, window=window,
                                       noverlap=noverlap, pad_to=pad_to,
                                       sides=sides,
                                       scale_by_freq=scale_by_freq,
                                       mode=mode)
    
        if scale == 'linear':
            Z = spec
        elif scale == 'dB':
            if mode is None or mode == 'default' or mode == 'psd':
>               Z = 10. * np.log10(spec)
E               RuntimeWarning: divide by zero encountered in log10
/usr/lib64/python3.9/site-packages/matplotlib/axes/_axes.py:7553: RuntimeWarning

Comment 1 Fedora Release Engineering 2021-01-24 04:22:40 UTC
Dear Maintainer,

your package has an open Fails To Build From Source bug for Fedora 34.
Action is required from you.

If you can fix your package to build, perform a build in koji, and either create
an update in bodhi, or close this bug without creating an update, if updating is
not appropriate [1]. If you are working on a fix, set the status to ASSIGNED to
acknowledge this. If you have already fixed this issue, please close this Bugzilla report.

Following the policy for such packages [2], your package will be orphaned if
this bug remains in NEW state more than 8 weeks (not sooner than 2021-03-05).

A week before the mass branching of Fedora 35 according to the schedule [3],
any packages not successfully rebuilt at least on Fedora 33 will be
retired regardless of the status of this bug.

[1] https://docs.fedoraproject.org/en-US/fesco/Updates_Policy/
[2] https://docs.fedoraproject.org/en-US/fesco/Fails_to_build_from_source_Fails_to_install/
[3] https://fedorapeople.org/groups/schedule/f-35/f-35-key-tasks.html

Comment 2 Elliott Sales de Andrade 2021-02-06 01:49:45 UTC
This would have been fixed by latest Matplotlib, but appears to have broken due to Python 3.9.1 and/or pybind11 incompatibility.

+ /usr/bin/python3 -c 'import mplcairo.base'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/builddir/build/BUILDROOT/python-mplcairo-0.3-5.fc34.x86_64/usr/lib64/python3.9/site-packages/mplcairo/__init__.py", line 20, in <module>
    from . import _mplcairo
ImportError: Object of type 'EnumMeta' is not an instance of 'none'

Comment 3 Ben Cotton 2021-02-09 15:38:28 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 4 Fedora Update System 2021-04-11 08:23:44 UTC
FEDORA-2021-5af22b573f has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-5af22b573f

Comment 5 Fedora Update System 2021-04-11 13:58:45 UTC
FEDORA-2021-5af22b573f has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-5af22b573f`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-5af22b573f

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 6 Fedora Update System 2021-04-12 15:09:18 UTC
FEDORA-2021-7bbb4a5990 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-7bbb4a5990`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-7bbb4a5990

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 7 Fedora Update System 2021-04-19 17:44:02 UTC
FEDORA-2021-5af22b573f has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 8 Fedora Update System 2021-04-24 20:09:06 UTC
FEDORA-2021-7bbb4a5990 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.