Skip to content

Test failures with NumPy 1.12 #272

Closed

Description

@ViviCoder

When running tests with the newest version of NumPy, which no longer accept floats as array indices, one obtains the following errors:

________________________ test_mixed_rise_and_dont_rise _________________________

recwarn = <_pytest.recwarn.WarningsRecorder object at 0x7ff6e01d8a90>

    def test_mixed_rise_and_dont_rise(recwarn):
        vega = SkyCoord(279.23473479*u.deg, 38.78368896*u.deg)
        polaris = SkyCoord(37.95456067*u.deg, 89.26410897*u.deg)
        sirius = SkyCoord(101.28715533*u.deg, -16.71611586*u.deg)
        targets = [vega, polaris, sirius]
    
        location = EarthLocation(10*u.deg, 45*u.deg, 0*u.m)
        time = Time('1995-06-21 00:00:00')
    
        obs = Observer(location=location)
>       rise_times = obs.target_rise_time(time, targets, which='next')

astroplan/tests/test_observer.py:1029: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python2.7/dist-packages/astropy/utils/decorators.py:636: in target_rise_time
    func = make_function_with_signature(func, name=name, **wrapped_args)
/usr/lib/python2.7/dist-packages/astropy/units/decorators.py:130: in wrapper
    return wrapped_function(*func_args, **func_kwargs)
astroplan/observer.py:908: in target_rise_time
    horizon=horizon))
astroplan/observer.py:830: in _determine_which_event
    next_event = function(*args('next'))
astroplan/observer.py:721: in _calc_riseset
    horizon)
/usr/lib/python2.7/dist-packages/astropy/utils/decorators.py:636: in _horiz_cross
    func = make_function_with_signature(func, name=name, **wrapped_args)
/usr/lib/python2.7/dist-packages/astropy/units/decorators.py:130: in wrapper
    return wrapped_function(*func_args, **func_kwargs)
astroplan/observer.py:599: in _horiz_cross
    times = [t[i:i+2] if not np.isnan(i) else np.nan for i in time_inds]
/usr/lib/python2.7/dist-packages/astropy/time/core.py:879: in __getitem__
    return self._replicate('__getitem__', item)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Time object: scale='utc' format='iso' value=['1995-06-21 00:00:00.000' '1995-...1995-06-21 23:40:40.268'
 '1995-06-21 23:50:20.134' '1995-06-22 00:00:00.000']>
method = '__getitem__', args = (slice(89.0, 91.0, None),), kwargs = {}
new_format = 'iso'
jd1 = array([ 2449890.,  2449890.,  2449890.,  2449890.,  2449890.,  2449890.,
     ...890.,
        2449890.,  2449890.,  2449890.,  2449890.,  2449890.,  2449891.])
jd2 = array([-0.5       , -0.49328859, -0.48657718, -0.47986577, -0.47315436,
      ...44295,
        0.47315436,  0.47986577,  0.48657718,  0.49328859, -0.5       ])

    def _replicate(self, method=None, *args, **kwargs):
        """Replicate a time object, possibly applying a method to the arrays.
    
            Parameters
            ----------
            method : str, optional
                If given, the method is applied to the internal ``jd1`` and ``jd2``
                arrays, as well as to possible ``location``, ``_delta_ut1_utc``,
                and ``_delta_tdb_tt`` arrays, broadcasting the latter as required.
                Example methods: ``copy``, ``__getitem__``, ``reshape``.
            args : tuple
                Any positional arguments for ``method``.
            kwargs : dict
                Any keyword arguments for ``method``.  If the ``format`` keyword
                argument is present, this will be used as the Time format of the
                replica.
            """
        new_format = kwargs.pop('format', None)
        if new_format is None:
            new_format = self.format
    
        jd1, jd2 = self._time.jd1, self._time.jd2
        if method is not None:
>           jd1 = getattr(jd1, method)(*args, **kwargs)
E           TypeError: slice indices must be integers or None or have an __index__ method

/usr/lib/python2.7/dist-packages/astropy/time/core.py:790: TypeError
__________________________ test_sequential_scheduler ___________________________

    def test_sequential_scheduler():
        constraints = [AirmassConstraint(2.5, boolean_constraint=False)]
        blocks = [ObservingBlock(t, 55 * u.minute, i) for i, t in enumerate(targets)]
        start_time = Time('2016-02-06 03:00:00')
        end_time = start_time + 18 * u.hour
        scheduler = SequentialScheduler(constraints=constraints, observer=apo,
                                        transitioner=default_transitioner,
                                        gap_time=15*u.minute)
        schedule = Schedule(start_time, end_time)
        scheduler(blocks, schedule)
        assert len(schedule.observing_blocks) > 0
        assert all(np.abs(block.end_time - block.start_time - block.duration) <
                   1*u.second for block in schedule.scheduled_blocks)
        assert all([schedule.observing_blocks[0].target == rigel,
                    schedule.observing_blocks[1].target == polaris,
                    schedule.observing_blocks[2].target == vega])
        # vega rises late, so its start should be later
        assert schedule.observing_blocks[2].start_time > start_time + 8*u.hour
        # test that the scheduler does not error when called with a partially
        # filled schedule
>       scheduler(blocks, schedule)

astroplan/tests/test_scheduling.py:180: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
astroplan/scheduling.py:463: in __call__
    schedule = self._make_schedule(copied_blocks)
astroplan/scheduling.py:529: in _make_schedule
    pre_filled = filled_times.reshape((len(filled_times)/2, 2))
/usr/lib/python2.7/dist-packages/astropy/time/core.py:889: in reshape
    return self._replicate('reshape', *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Time object: scale='utc' format='iso' value=['2016-02-06 03:00:00.000' '2016-...2016-02-06 11:07:12.819'
 '2016-02-06 11:07:12.819' '2016-02-06 12:02:12.819']>
method = 'reshape', args = ((5.0, 2),), kwargs = {}, new_format = 'iso'
jd1 = array([ 2457424.5,  2457425. ,  2457425. ,  2457425. ,  2457425. ,
        2457425. ,  2457425. ,  2457425. ,  2457425. ,  2457425. ])
jd2 = array([ 0.125     , -0.33680556, -0.33680556, -0.33586521, -0.33586521,
       -0.29767076, -0.0372541 , -0.03665719, -0.03665719,  0.00153726])

    def _replicate(self, method=None, *args, **kwargs):
        """Replicate a time object, possibly applying a method to the arrays.
    
            Parameters
            ----------
            method : str, optional
                If given, the method is applied to the internal ``jd1`` and ``jd2``
                arrays, as well as to possible ``location``, ``_delta_ut1_utc``,
                and ``_delta_tdb_tt`` arrays, broadcasting the latter as required.
                Example methods: ``copy``, ``__getitem__``, ``reshape``.
            args : tuple
                Any positional arguments for ``method``.
            kwargs : dict
                Any keyword arguments for ``method``.  If the ``format`` keyword
                argument is present, this will be used as the Time format of the
                replica.
            """
        new_format = kwargs.pop('format', None)
        if new_format is None:
            new_format = self.format
    
        jd1, jd2 = self._time.jd1, self._time.jd2
        if method is not None:
>           jd1 = getattr(jd1, method)(*args, **kwargs)
E           TypeError: 'float' object cannot be interpreted as an index

/usr/lib/python2.7/dist-packages/astropy/time/core.py:790: TypeError

Activity

  1. bsipocz commented on Dec 21, 2016

    @bsipocz
    Member

    Thanks @ViviCoder for the report. Based on the traceback these may be problems in astropy itself. Which version did you use for the test? (That said, we know that astroplan has a few issues with astropy dev, but those are related to coordinates rather than the time module.)

  2. ViviCoder commented on Dec 21, 2016

    @ViviCoder
    Author

    @bsipocz At first glance, I also thought it was due to astropy, but in fact the errors come from the arguments that are passed to the astropy routine.
    I used astropy 1.2.1.

  3. bmorris3 commented on Dec 5, 2018

    @bmorris3
    Contributor

    Hey @ViviCoder, is this still an issue?

  4. ViviCoder commented on Dec 5, 2018

    @ViviCoder
    Author

    @bmorris3 I do not think so.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions