Skip to content

stats.lombscargle failures with Numpy-dev #4954

Closed

Description

@astrofrog

Some of the tests for the stats.lombscargle sub-package are failing with the latest developer version of Numpy, e.g.:

____________________________________________________________________________ test_all_methods[psd-True-False-True-True-chi2] _____________________________________________________________________________

data = (array([ 10.97627008,  14.30378733,  12.05526752,  10.89766366,
         8.47309599,  12.91788226,   8.75174423,  17.8...84375,  0.68619301,  1.44437239,  1.2395508 ,
        0.99045881,  0.72741463,  0.75435648,  0.55802916,  0.93441663]))
method = 'chi2', center_data = True, fit_mean = True, with_errors = False, with_units = True, normalization = 'psd'

    @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('with_units', [True, False])
    @pytest.mark.parametrize('normalization', NORMALIZATIONS)
    def test_all_methods(data, method, center_data, fit_mean,
                         with_errors, with_units, normalization):
        if method == 'scipy' and (fit_mean or with_errors):
            return

        t, y, dy = data
        frequency = 0.8 + 0.01 * np.arange(40)
        if with_units:
            t = t * units.day
            y = y * units.mag
            dy = dy * units.mag
            frequency = frequency / t.unit
        if not with_errors:
            dy = None

        kwds = dict(normalization=normalization)
        ls = LombScargle(t, y, dy, center_data=center_data, fit_mean=fit_mean)
        P_expected = ls.power(frequency, **kwds)

        # don't use the fft approximation here; we'll test this elsewhere
        if method in FAST_METHODS:
            kwds['method_kwds'] = dict(use_fft=False)
        P_method = ls.power(frequency, method=method, **kwds)

        if with_units:
            if normalization == 'psd' and not with_errors:
                assert P_method.unit == y.unit ** 2
            else:
                assert P_method.unit == units.dimensionless_unscaled
        else:
            assert not hasattr(P_method, 'unit')

>       assert_quantity_allclose(P_expected, P_method)

astropy/stats/lombscargle/tests/test_lombscargle.py:67: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
astropy/tests/helper.py:480: in assert_quantity_allclose
    **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x_id = array([False, False, False, False, False, False, False, False, False,
       False, False, False, False, False, False,...,
       False, False, False, False, False, False, False, False, False,
       False, False, False, False], dtype=bool)
y_id = array([ True,  True,  True,  True,  True,  True,  True,  True,  True,
        True,  True,  True,  True,  True,  True,...,
        True,  True,  True,  True,  True,  True,  True,  True,  True,
        True,  True,  True,  True], dtype=bool)
hasval = '+inf'

    def chk_same_position(x_id, y_id, hasval='nan'):
        """Handling nan/inf: check that x and y have the nan/inf at the same
            locations."""
        try:
            assert_array_equal(x_id, y_id)
        except AssertionError:
            msg = build_err_msg([x, y],
                                err_msg + '\nx and y %s location mismatch:'
                                % (hasval), verbose=verbose, header=header,
                                names=('x', 'y'), precision=precision)
>           raise AssertionError(msg)
E           AssertionError: 
E           Not equal to tolerance rtol=1e-07, atol=0
E           
E           x and y +inf location mismatch:
E            x: array([  5.379997e-01,   9.984607e-01,   2.911666e+00,   3.905607e+00,
E                    2.454666e+00,   2.022995e-01,   1.302772e+00,   6.637232e+00,
E                    1.201750e+01,   1.447837e+01,   1.600839e+01,   1.972033e+01,...
E            y: array([ inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,
E                   inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,
E                   inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,  inf,
E                   inf,  inf,  inf,  inf,  inf,  inf,  inf])

/Users/tom/miniconda3/envs/dev35/lib/python3.5/site-packages/numpy-1.12.0.dev0+cd96464-py3.5-macosx-10.5-x86_64.egg/numpy/testing/utils.py:677: AssertionError

@jakevdp - do you have time to investigate this?

Activity

  1. added
    Affects-devPRs and issues that do not impact an existing Astropy release
    on May 19, 2016
  2. bsipocz commented on May 19, 2016

    @bsipocz
    Member
  3. mhvk commented on May 20, 2016

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Affects-devPRs and issues that do not impact an existing Astropy releaseBugUpstream Action RequiredWas: Upstream Fix Requiredstats

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions