Beispiel #1
0
def test_addIntConstant():
    """
    1. Addition with constant integer
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 10, 'add')
    assert result.shape == cube.shape
Beispiel #2
0
def test_unsupportedMethod():
    """
    9. Test with unsupported method 'dummy'
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 5., 'dummy')
    assert result.shape == cube.shape
Beispiel #3
0
def test_divIntConstant():
    """
    7. Division with constant integer
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 10, 'divide')
    assert result.shape == cube.shape
Beispiel #4
0
def test_mulIntConstant():
    """
    5. Multiplication with integer
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 10, 'multiply')
    assert result.shape == cube.shape
Beispiel #5
0
def test_mulIntConstant():
    """
    5. Multiplication with integer
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 10, 'multiply')
    assert result.shape == cube.shape
Beispiel #6
0
def test_mulFloatConstant():
    """
    6. Multiplication with constant float
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 5., 'multiply')
    assert result.shape == cube.shape
Beispiel #7
0
def test_subIntConstant():
    """
    3. Subtraction with constant integer
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 10, 'subtract')
    assert result.shape == cube.shape
Beispiel #8
0
def test_subFloatConstant():
    """
    4. Subtraction with constant float
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 5., 'subtract')
    assert result.shape == cube.shape
Beispiel #9
0
def test_addFloatConstant():
    """
    2. Addition with constant float
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 5., 'add')
    assert result.shape == cube.shape
Beispiel #10
0
def test_divFloatConstant():
    """
    8. Division with constant float
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 5., 'divide')
    assert result.shape == cube.shape
Beispiel #11
0
def test_scalarInput():
    """
    13. Test with input scalar list 
    """

    in_list = np.arange(10)

    result = math(in_list, 10, 'add')
    assert isinstance(result, np.ndarray)
Beispiel #12
0
def test_unsupportedMethod():
    """
    9. Test with unsupported method 'dummy'
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 5., 'dummy')
    assert result.shape == cube.shape
Beispiel #13
0
def test_divFloatConstant():
    """
    8. Division with constant float
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 5., 'divide')
    assert result.shape == cube.shape
Beispiel #14
0
def test_subFloatConstant():
    """
    4. Subtraction with constant float
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 5., 'subtract')
    assert result.shape == cube.shape
Beispiel #15
0
def test_subIntConstant():
    """
    3. Subtraction with constant integer
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 10, 'subtract')
    assert result.shape == cube.shape
Beispiel #16
0
def test_addIntConstant():
    """
    1. Addition with constant integer
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 10, 'add')
    assert result.shape == cube.shape
Beispiel #17
0
def test_mulFloatConstant():
    """
    6. Multiplication with constant float
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 5., 'multiply')
    assert result.shape == cube.shape
Beispiel #18
0
def test_addFloatConstant():
    """
    2. Addition with constant float
    """   
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 5., 'add')
    assert result.shape == cube.shape
Beispiel #19
0
def test_scalarInput():
    """
    13. Test with input scalar list 
    """
    
    in_list = np.arange(10)
    
    result = math(in_list, 10, 'add')
    assert isinstance(result, np.ndarray)
Beispiel #20
0
def test_divIntConstant():
    """
    7. Division with constant integer
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 10, 'divide')
    assert result.shape == cube.shape
Beispiel #21
0
def test_diffDims():
    """
    12. Test with different dimensions
    """
    
    cube = np.arange(30*3*10).reshape(30, 3, 10)
    image = cube[15, :, :].reshape(5, 6)
    
    result = math(cube, image, 'divide')
    assert isinstance(result, np.ndarray)
Beispiel #22
0
def test_diffDims():
    """
    12. Test with different dimensions
    """

    cube = np.arange(30 * 3 * 10).reshape(30, 3, 10)
    image = cube[15, :, :].reshape(5, 6)

    result = math(cube, image, 'divide')
    assert isinstance(result, np.ndarray)
Beispiel #23
0
def test_unsupportedOperator():
    """
    10. Test with unsupported operator 'r'
    Operator must be a 1D/2D/3D array of int/float!
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, 'r', 'add')
    assert isinstance(result, np.ndarray), 'Operator cannot be a string!'
Beispiel #24
0
def test_unsupportedOperator():
    """
    10. Test with unsupported operator 'r'
    Operator must be a 1D/2D/3D array of int/float!
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, 'r', 'add')
    assert isinstance(result, np.ndarray), 'Operator cannot be a string!'
Beispiel #25
0
def test_cubeMinImage():
    """
    11. 3D/2D math operation
    Subtracting an image from a cube.
    """

    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)
    image = cube[15, :, :]

    result = math(cube, image, 'subtract')
    assert isinstance(result, np.ndarray)
Beispiel #26
0
def test_cubeMinImage():
    """
    11. 3D/2D math operation
    Subtracting an image from a cube.
    """
    
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    image = cube[15, :, :]
    
    result = math(cube, image, 'subtract')
    assert isinstance(result, np.ndarray)
Beispiel #27
0
def test_cubeAndSpectrum():
    """
    14. 3D/1D test with an spectrum as the operator
    
    Create a 2D spectrum image the same size as the 
    frame in the cube.
    """
    
    spectrum = np.random.randint(0, 10, size=(30))
    cube = np.arange(30*5*5).reshape(30, 5, 5)
    
    result = math(cube, spectrum, method='subtract')    
    assert isinstance(result, np.ndarray)

# ======================================================
#                       Test suite
# ======================================================
Beispiel #28
0
def test_cubeAndSpectrum():
    """
    14. 3D/1D test with an spectrum as the operator
    
    Create a 2D spectrum image the same size as the 
    frame in the cube.
    """

    spectrum = np.random.randint(0, 10, size=(30))
    cube = np.arange(30 * 5 * 5).reshape(30, 5, 5)

    result = math(cube, spectrum, method='subtract')
    assert isinstance(result, np.ndarray)


# ======================================================
#                       Test suite
# ======================================================