Esempio n. 1
0
def test_indexing_and_setting():

    shape = (10,11,12)
    data = np.random.random(shape+(4,))
    ma = ModelArray()
    ma.model_params = data
    assert_array_equal(ma[0].model_params, data[0])
    assert_array_equal(ma[:, 1].model_params, data[:, 1])
    assert_array_equal(ma[:, :, 2].model_params, data[:, :, 2])
    assert_array_equal(ma[3:5].model_params, data[3:5])
    assert_array_equal(ma[..., 4:].model_params, data[..., 4:, :])
Esempio n. 2
0
def test_model_shape():

    shape = (10,11,12)
    ma = ModelArray()
    ma.model_params = np.zeros(shape+(4,))
    assert_equal(ma[..., 0].shape, shape[:-1])
    assert_equal(ma[0].shape, shape[1:])
    ma.shape = (-1)
    assert(ma.ndim == 1)
    ma.shape = shape[::-1]
    assert(ma.ndim == len(shape))
Esempio n. 3
0
def test_indexing_and_setting():

    shape = (10, 11, 12)
    data = np.random.random(shape + (4, ))
    ma = ModelArray()
    ma.model_params = data
    assert_array_equal(ma[0].model_params, data[0])
    assert_array_equal(ma[:, 1].model_params, data[:, 1])
    assert_array_equal(ma[:, :, 2].model_params, data[:, :, 2])
    assert_array_equal(ma[3:5].model_params, data[3:5])
    assert_array_equal(ma[..., 4:].model_params, data[..., 4:, :])
Esempio n. 4
0
def test_model_shape():

    shape = (10, 11, 12)
    ma = ModelArray()
    ma.model_params = np.zeros(shape + (4, ))
    assert_equal(ma[..., 0].shape, shape[:-1])
    assert_equal(ma[0].shape, shape[1:])
    ma.shape = (-1)
    assert (ma.ndim == 1)
    ma.shape = shape[::-1]
    assert (ma.ndim == len(shape))
Esempio n. 5
0
def test_model_mask():

    shape = (10,11,12)
    data = np.zeros(shape+(4,))
    ma = ModelArray()
    ma.model_params = data
    assert(ma.mask.all())

    mask = np.random.random(shape+(4,)) > .3
    maskedarray = MaskedArray(data, mask)
    ma.model_params = maskedarray
    assert_array_equal(ma.mask, mask)
Esempio n. 6
0
def test_model_mask():

    shape = (10, 11, 12)
    data = np.zeros(shape + (4, ))
    ma = ModelArray()
    ma.model_params = data
    assert (ma.mask.all())

    mask = np.random.random(shape + (4, )) > .3
    maskedarray = MaskedArray(data, mask)
    ma.model_params = maskedarray
    assert_array_equal(ma.mask, mask)