How to use the tigramite.independence_tests._construct_array function in tigramite

To help you get started, we’ve selected a few tigramite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jakobrunge / tigramite / tests / test_tigramite_independence_tests.py View on Github external
data_mask = numpy.array([[0, 1, 1, 0],
                                 [0, 0, 0, 0],
                                 [1, 0, 0, 0],
                                 [0, 0, 1, 1],
                                 [0, 0, 0, 0],
                                 [0, 0, 0, 0],
                                 [0, 0, 0, 0]], dtype='bool')

        X = [(1, -1)]
        Y = [(0, 0)]
        Z = [(0, -1), (1, -2), (2, 0)]

        tau_max = 2

        # No masking
        res = _construct_array(
            X=X, Y=Y, Z=Z,
            tau_max=tau_max,
            use_mask=False,
            data=data,
            mask=data_mask,
            missing_flag=None,
            mask_type=None, verbosity=verbosity)
        print(res[0])
        numpy.testing.assert_almost_equal(res[0],
                                          numpy.array([[13, 14, 15],
                                                     [ 4,  5,  6],
                                                     [ 3,  4,  5],
                                                     [12, 13, 14],
                                                     [24, 25, 26]]))
        numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2]))
github jakobrunge / tigramite / tests / test_tigramite_independence_tests.py View on Github external
data_mask = numpy.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]], dtype='bool')

        X = [(1, -2)]
        Y = [(0, 0)]
        Z = [(2, -1)]

        tau_max = 1

        # Missing values
        res = _construct_array(
            X=X, Y=Y, Z=Z,
            tau_max=tau_max,
            use_mask=False,
            data=data,
            mask=data_mask,
            missing_flag=999,
            mask_type=['y'], verbosity=verbosity)

        # print(res[0])
        numpy.testing.assert_almost_equal(res[0],
                                          numpy.array([[10, 14],
                                                     [ 2,  6],
                                                     [21, 25]]))
github jakobrunge / tigramite / tests / test_tigramite_independence_tests.py View on Github external
use_mask=False,
            data=data,
            mask=data_mask,
            missing_flag=None,
            mask_type=None, verbosity=verbosity)
        print(res[0])
        numpy.testing.assert_almost_equal(res[0],
                                          numpy.array([[13, 14, 15],
                                                     [ 4,  5,  6],
                                                     [ 3,  4,  5],
                                                     [12, 13, 14],
                                                     [24, 25, 26]]))
        numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2]))

        # masking y
        res = _construct_array(
            X=X, Y=Y, Z=Z,
            tau_max=tau_max,
            use_mask=True,
            data=data,
            mask=data_mask,
            mask_type=['y'], verbosity=verbosity)
        print(res[0])

        numpy.testing.assert_almost_equal(res[0],
                                          numpy.array([[13, 14, 15],
                                                     [ 4,  5,  6],
                                                     [ 3,  4,  5],
                                                     [12, 13, 14],
                                                     [24, 25, 26]]))

        numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2]))