def test_TimeArray_index_at():
    time1 = ts.TimeArray(list(range(10)), time_unit='ms')
    for i in range(5):
        # The return value is always an array, so we keep it for multiple tests
        i_arr = np.array(i)
        # Check 'closest' indexing mode first
        idx = time1.index_at(i)
        npt.assert_equal(idx, i_arr)

        # If we index with seconds/1000, results shouldn't vary
        idx_secs = time1.index_at(ts.TimeArray(1000. / i, time_unit='s'))
        npt.assert_equal(idx_secs, i_arr)

        # If we now change the tolerance
        # In this case, it should still return
        idx = time1.index_at(i + 0.1, tol=0.1)
        npt.assert_equal(idx, i_arr)
        # But with a smaller tolerance, we should get no indices
        idx = time1.index_at(i + 0.1, tol=0.05)
        npt.assert_equal(idx, np.array([]))

        # Now, check before/after modes
        idx = time1.index_at(i + 0.1, mode='before')
        npt.assert_equal(idx, i_arr)

        idx = time1.index_at(i + 0.1, mode='after')
        npt.assert_equal(idx, i_arr + 1)
dataset/ETHPy150Open nipy/nitime/nitime/tests/test_timeseries.py/test_TimeArray_index_at/swapped operands of `/`