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")
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)
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)
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
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)