Skip to content

Commit 7ae5f6a

Browse files
committed
Prevent delaunay triples from setting header for non-file output
1 parent 4a42b1a commit 7ae5f6a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pygmt/src/triangulate.py

+3
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ def delaunay_triples( # pylint: disable=too-many-arguments,too-many-locals
355355
warnings.warn(message=msg, category=RuntimeWarning, stacklevel=2)
356356
output_type = "file"
357357

358+
if header is not None and output_type != "file":
359+
raise GMTInvalidInput("'header' is only allowed with output_type='file'.")
360+
358361
# Return a pandas.DataFrame if ``outfile`` is not set
359362
with GMTTempFile(suffix=".txt") as tmpfile:
360363
if output_type != "file":

pygmt/tests/test_triangulate.py

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ def test_delaunay_triples_invalid_format(dataframe):
127127
"""
128128
with pytest.raises(GMTInvalidInput):
129129
triangulate.delaunay_triples(data=dataframe, output_type=1)
130+
with pytest.raises(GMTInvalidInput):
131+
triangulate.delaunay_triples(data=dataframe, output_type="pandas", header="o+c")
130132

131133

132134
def test_regular_grid_with_outgrid_true(dataframe, expected_grid):

0 commit comments

Comments
 (0)