Exemple #1
0
def test_grdvolume_no_outfile(grid):
    """
    Test that grdvolume fails when output_type set to 'file' but no outfile is
    specified.
    """
    with pytest.raises(GMTInvalidInput):
        grdvolume(grid=grid, output_type="file")
Exemple #2
0
def test_grdvolume_format(grid):
    """
    Test that correct formats are returned.
    """
    grdvolume_default = grdvolume(grid=grid)
    assert isinstance(grdvolume_default, pd.DataFrame)
    grdvolume_array = grdvolume(grid=grid, output_type="numpy")
    assert isinstance(grdvolume_array, np.ndarray)
    grdvolume_df = grdvolume(grid=grid, output_type="pandas")
    assert isinstance(grdvolume_df, pd.DataFrame)
Exemple #3
0
def test_grdvolume_no_outgrid(grid, data):
    """
    Test the expected output of grdvolume with no output file set.
    """
    test_output = grdvolume(grid=grid,
                            contour=[200, 400, 50],
                            output_type="numpy")
    npt.assert_allclose(test_output, data)
Exemple #4
0
def test_grdvolume_outgrid(grid):
    """
    Test the expected output of grdvolume with an output file set.
    """
    with GMTTempFile(suffix=".csv") as tmpfile:
        result = grdvolume(grid=grid,
                           contour=[200, 400, 50],
                           output_type="file",
                           outfile=tmpfile.name)
        assert result is None  # return value is None
        assert os.path.exists(path=tmpfile.name)  # check that outfile exists
Exemple #5
0
def test_grdvolume_invalid_format(grid):
    """
    Test that grdvolume fails with incorrect output_type argument.
    """
    with pytest.raises(GMTInvalidInput):
        grdvolume(grid=grid, output_type=1)