Ejemplo n.º 1
0
def test_ctps():
    """Test basic ctps functionality."""
    for ii, (n_trials, j_extent, pk_max) in iter_test_ctps:
        data = get_data(n_trials, j_extent)
        ks_dyn, pk_dyn, phase_trial = ctps(data)
        data2 = _compute_normalized_phase(data)
        ks_dyn2, pk_dyn2, phase_trial2 = ctps(data2, is_raw=False)
        for a, b in zip([ks_dyn, pk_dyn, phase_trial],
                        [ks_dyn2, pk_dyn2, data2]):
            assert_array_equal(a, b)
            assert (a.min() >= 0)
            assert (a.max() <= 1)
            assert (b.min() >= 0)
            assert (b.max() <= 1)

        # test for normalization
        assert ((pk_dyn.min() > 0.0) or (pk_dyn.max() < 1.0))
        # test shapes
        assert (phase_trial.shape == data.shape)
        assert (pk_dyn.shape == data.shape[1:])
        # tets ground_truth + random + jittered case
        assert (pk_dyn[0].max() == 1.0)
        assert (len(np.unique(pk_dyn[0])) == 1.0)
        assert (pk_dyn[1].max() < pk_max)
        assert (pk_dyn[2].max() > 0.3)
        if ii < 1:
            pytest.raises(ValueError, ctps, data[:, :, :, None])

    assert (_prob_kuiper(1.0, 400) == 1.0)
    # test vecrosization
    assert_array_equal(_prob_kuiper(np.array([1.0, 1.0]), 400),
                       _prob_kuiper(np.array([1.0, 1.0]), 400))
    assert (_prob_kuiper(0.1, 400) < 0.1)
Ejemplo n.º 2
0
def test_ctps():
    """ Test basic ctps functionality
    """
    for ii, (n_trials, j_extent, pk_max) in iter_test_ctps:
        data = get_data(n_trials, j_extent)
        ks_dyn, pk_dyn, phase_trial = ctps(data)
        data2 = _compute_normalized_phase(data)
        ks_dyn2, pk_dyn2, phase_trial2 = ctps(data2, is_raw=False)
        for a, b in zip([ks_dyn, pk_dyn, phase_trial],
                        [ks_dyn2, pk_dyn2, data2]):
            assert_array_equal(a, b)
            assert_true(a.min() >= 0)
            assert_true(a.max() <= 1)
            assert_true(b.min() >= 0)
            assert_true(b.max() <= 1)

        # test for normalization
        assert_true((pk_dyn.min() > 0.0) or (pk_dyn.max() < 1.0))
        # test shapes
        assert_true(phase_trial.shape == data.shape)
        assert_true(pk_dyn.shape == data.shape[1:])
        # tets ground_truth + random + jittered case
        assert_true(pk_dyn[0].max() == 1.0)
        assert_true(len(np.unique(pk_dyn[0])) == 1.0)
        assert_true(pk_dyn[1].max() < pk_max)
        assert_true(pk_dyn[2].max() > 0.3)
        if ii < 1:
            assert_raises(ValueError, ctps,
                          data[:, :, :, None])

    assert_true(_prob_kuiper(1.0, 400) == 1.0)
    # test vecrosization
    assert_array_equal(_prob_kuiper(np.array([1.0, 1.0]), 400),
                       _prob_kuiper(np.array([1.0, 1.0]), 400))
    assert_true(_prob_kuiper(0.1, 400) < 0.1)