def test_ptrPyArrayObjectReturnArg1(pymod_test_mod, array_shape, input_type):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(
        array_shape, input_type)
    res = pymod_test_mod.ptrPyArrayObjectReturnArg(arg)
    assert numpy.all(res == arg)
    assert type(res) == type(arg)
    assert res.dtype == arg.dtype
Пример #2
0
def test_returnStridesAsTuple3D1(pymod_test_mod, array_shape, input_type):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(
        array_shape, input_type)
    expectedStrides = arg.strides

    resStrides = pymod_test_mod.returnStridesAsTuple3D(arg)
    assert resStrides == expectedStrides
Пример #3
0
def test_returnNdAttr_4d(pymod_test_mod, input_type, random_4d_array_shape):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(random_4d_array_shape, input_type)

    resNd = pymod_test_mod.returnNdAttr(arg)
    assert resNd == len(arg.shape)
    assert resNd == arg.ndim

    resNdim = pymod_test_mod.returnNdimAttr(arg)
    assert resNdim == len(arg.shape)
    assert resNdim == arg.ndim
Пример #4
0
def test_returnStridesAsTuple1D1(pymod_test_mod, array_shape, input_type):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(array_shape, input_type)
    expectedStrides = arg.strides

    resStrides = pymod_test_mod.returnStridesAsTuple1D(arg)
    # FIXME:  Currently, Pymod incorrectly unwraps single-element-tuple return-types.
    # Thus, `resStrides` should be a tuple-of-single-int, but instead it's an int.
    # We will fix this soon...
    resStrides = (resStrides,)
    assert resStrides == expectedStrides
Пример #5
0
def test_returnNdAttr_4d(pymod_test_mod, input_type, random_4d_array_shape):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(
        random_4d_array_shape, input_type)

    resNd = pymod_test_mod.returnNdAttr(arg)
    assert resNd == len(arg.shape)
    assert resNd == arg.ndim

    resNdim = pymod_test_mod.returnNdimAttr(arg)
    assert resNdim == len(arg.shape)
    assert resNdim == arg.ndim
Пример #6
0
def test_returnDimensionsAsTuple2D1(pymod_test_mod, array_shape, input_type):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(
        array_shape, input_type)
    expectedDimensions = arg.shape
    expectedShape = arg.shape

    resDimensions = pymod_test_mod.returnDimensionsAsTuple2D(arg)
    assert resDimensions == expectedDimensions

    resShape = pymod_test_mod.returnShapeAsTuple2D(arg)
    assert resShape == expectedShape
Пример #7
0
def test_returnStridesAsTuple1D1(pymod_test_mod, array_shape, input_type):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(
        array_shape, input_type)
    expectedStrides = arg.strides

    resStrides = pymod_test_mod.returnStridesAsTuple1D(arg)
    # FIXME:  Currently, Pymod incorrectly unwraps single-element-tuple return-types.
    # Thus, `resStrides` should be a tuple-of-single-int, but instead it's an int.
    # We will fix this soon...
    resStrides = (resStrides, )
    assert resStrides == expectedStrides
Пример #8
0
def test_ptrPyArrayObjectReturnArg1(pymod_test_mod, array_shape, input_type):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(array_shape, input_type)
    res = pymod_test_mod.ptrPyArrayObjectReturnArg(arg)
    assert numpy.all(res == arg)
    assert type(res) == type(arg)
    assert res.dtype == arg.dtype
Пример #9
0
def test_returnStridesAsTuple4D2(pymod_test_mod, input_type, random_4d_array_shape):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(random_4d_array_shape, input_type)
    expectedStrides = arg.strides

    resStrides = pymod_test_mod.returnStridesAsTuple4D(arg)
    assert resStrides == expectedStrides
Пример #10
0
def test_returnInt8DataPtrAsInt_2d(pymod_test_mod, random_2d_array_shape):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(random_2d_array_shape, numpy.int8)
    res = pymod_test_mod.returnInt8DataPtrAsInt(arg)
    data_addr = _get_array_data_address(arg)
    assert res == data_addr
Пример #11
0
def test_returnDataPointerAsInt1(pymod_test_mod, array_shape, input_type):
    arg = array_utils.get_random_Nd_array_of_shape_and_type(array_shape, input_type)
    res = pymod_test_mod.returnDataPointerAsInt(arg)
    data_addr = _get_array_data_address(arg)
    assert res == data_addr
Пример #12
0
def random_2d_array_of_integers(random_2d_array_shape):
    """Return a randomly-shaped 2-D array of random integers in the range [-100, 100]."""
    return get_random_Nd_array_of_shape_and_type(random_2d_array_shape)