Skip to content

test_integer_inputs fails on ppc64le #11025

Closed

Description

@astrofrog

I noticed the following test failure (which happens many times due to the parametrized test) on ppc64le:

_____________ test_integer_inputs[model-True-False-False-fastchi2] _____________

data = (array([10.97627008, 14.30378733, 12.05526752, 10.89766366,  8.47309599,
       12.91788226,  8.75174423, 17.83546002,...6, 0.70984375, 0.68619301, 1.44437239, 1.2395508 ,
       0.99045881, 0.72741463, 0.75435648, 0.55802916, 0.93441663]))
method = 'fastchi2', center_data = False, fit_mean = False, with_errors = True
normalization = 'model'

    @pytest.mark.parametrize('method', ALL_METHODS_NO_AUTO)
    @pytest.mark.parametrize('center_data', [True, False])
    @pytest.mark.parametrize('fit_mean', [True, False])
    @pytest.mark.parametrize('with_errors', [True, False])
    @pytest.mark.parametrize('normalization', NORMALIZATIONS)
    def test_integer_inputs(data, method, center_data, fit_mean, with_errors,
                            normalization):
        if method == 'scipy' and (fit_mean or with_errors):
            return
    
        t, y, dy = data
    
        t = np.floor(100 * t)
        t_int = t.astype(int)
    
        y = np.floor(100 * y)
        y_int = y.astype(int)
    
        dy = np.floor(100 * dy)
        dy_int = dy.astype('int32')
    
        frequency = 1E-2 * (0.8 + 0.01 * np.arange(40))
    
        if not with_errors:
            dy = None
            dy_int = None
    
        kwds = dict(center_data=center_data,
                    fit_mean=fit_mean,
                    normalization=normalization)
        P_float = LombScargle(t, y, dy, **kwds).power(frequency,method=method)
        P_int = LombScargle(t_int, y_int, dy_int,
>                           **kwds).power(frequency, method=method)

../../.tox/py37-test/lib/python3.7/site-packages/astropy/timeseries/periodograms/lombscargle/tests/test_lombscargle.py:144: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../.tox/py37-test/lib/python3.7/site-packages/astropy/timeseries/periodograms/lombscargle/core.py:364: in power
    assume_regular_frequency=assume_regular_frequency)
../../.tox/py37-test/lib/python3.7/site-packages/astropy/timeseries/periodograms/lombscargle/implementations/main.py:216: in lombscargle
    PLS = METHODS[method](*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

t = array([1097, 1430, 1205, 1089,  847, 1291,  875, 1783, 1927,  766, 1583,
       1057, 1136, 1851,  142,  174,   40, 16...8, 1384, 1133,  530, 1046,  187,
       1151, 1858,  637, 1334,  263, 1432,  578,  366, 1173,   40, 1657,
          9])
y = array([1399, 1006, 1208, 1056,  700, 1369,  906,  990, 1065,  801,  884,
        433, 1103,  711,  952,  814,  983,  5...9, 1063,  934, 1036,  737, 1046,
        640,  503, 1040, 1066,  596,  826,  941,  616,  774,  846,  679,
       1425])
dy = array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=int32)
f0 = 0.008, df = 0.00010000000000000113, Nf = 40, normalization = 'model'
fit_mean = False, center_data = False, nterms = 1, use_fft = True
trig_sum_kwds = None

    def lombscargle_fastchi2(t, y, dy, f0, df, Nf, normalization='standard',
                             fit_mean=True, center_data=True, nterms=1,
                             use_fft=True, trig_sum_kwds=None):
        """Lomb-Scargle Periodogram
    
        This implements a fast chi-squared periodogram using the algorithm
        outlined in [4]_. The result is identical to the standard Lomb-Scargle
        periodogram. The advantage of this algorithm is the
        ability to compute multiterm periodograms relatively quickly.
    
        Parameters
        ----------
        t, y, dy : array_like  (NOT astropy.Quantities)
            times, values, and errors of the data points. These should be
            broadcastable to the same shape.
        f0, df, Nf : (float, float, int)
            parameters describing the frequency grid, f = f0 + df * arange(Nf).
        normalization : str, optional
            Normalization to use for the periodogram.
            Options are 'standard', 'model', 'log', or 'psd'.
        fit_mean : bool, optional
            if True, include a constant offset as part of the model at each
            frequency. This can lead to more accurate results, especially in the
            case of incomplete phase coverage.
        center_data : bool, optional
            if True, pre-center the data by subtracting the weighted mean
            of the input data. This is especially important if ``fit_mean = False``
        nterms : int, optional
            Number of Fourier terms in the fit
    
        Returns
        -------
        power : array_like
            Lomb-Scargle power associated with each frequency.
            Units of the result depend on the normalization.
    
        References
        ----------
        .. [1] M. Zechmeister and M. Kurster, A&A 496, 577-584 (2009)
        .. [2] W. Press et al, Numerical Recipes in C (2002)
        .. [3] Scargle, J.D. ApJ 263:835-853 (1982)
        .. [4] Palmer, J. ApJ 695:496-502 (2009)
        """
        if nterms == 0 and not fit_mean:
            raise ValueError("Cannot have nterms = 0 without fitting bias")
    
        if dy is None:
            dy = 1
    
        # Validate and setup input data
        t, y, dy = np.broadcast_arrays(t, y, dy)
        if t.ndim != 1:
            raise ValueError("t, y, dy should be one dimensional")
    
        # Validate and setup frequency grid
        if f0 < 0:
            raise ValueError("Frequencies must be positive")
        if df <= 0:
            raise ValueError("Frequency steps must be positive")
        if Nf <= 0:
            raise ValueError("Number of frequencies must be positive")
    
>       w = dy ** -2.0
E       RuntimeWarning: divide by zero encountered in power

../../.tox/py37-test/lib/python3.7/site-packages/astropy/timeseries/periodograms/lombscargle/implementations/fastchi2_impl.py:69: 

I'm not sure if it's safe to ignore the warning or whether this indicates are more serious issue.

@olebole - I'm curious whether you've noticed this before when testing for Debian?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions