Skip to content

Commit ce029b2

Browse files
committed
Rename return_table to return_dataset
1 parent c9e482a commit ce029b2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pygmt/clib/session.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -1738,14 +1738,16 @@ def read_virtualfile(
17381738
dtype = {"dataset": _GMT_DATASET, "grid": _GMT_GRID}[kind]
17391739
return ctp.cast(pointer, ctp.POINTER(dtype))
17401740

1741-
def return_table(
1741+
def return_dataset(
17421742
self,
17431743
output_type: Literal["pandas", "numpy", "file"],
17441744
vfile: str,
17451745
column_names: list[str] | None = None,
17461746
) -> pd.DataFrame | np.ndarray | None:
17471747
"""
1748-
Return an output table from a virtual file based on the output type.
1748+
Output a dataset stored in a virtual file in different formats.
1749+
1750+
The format of the dataset is determined by the ``output_type`` parameter.
17491751
17501752
Parameters
17511753
----------
@@ -1763,8 +1765,8 @@ def return_table(
17631765
17641766
Returns
17651767
-------
1766-
table
1767-
The output table. If ``output_type="file"`` returns ``None``.
1768+
result
1769+
The result dataset. If ``output_type="file"`` returns ``None``.
17681770
17691771
Examples
17701772
--------
@@ -1792,29 +1794,31 @@ def return_table(
17921794
... kind="dataset", fname=outtmp.name
17931795
... ) as vouttbl:
17941796
... lib.call_module("read", f"{tmpfile.name} {vouttbl} -Td")
1795-
... result = lib.return_table(output_type="file", vfile=vouttbl)
1797+
... result = lib.return_dataset(
1798+
... output_type="file", vfile=vouttbl
1799+
... )
17961800
... assert result is None
17971801
... assert Path(outtmp.name).stat().st_size > 0
17981802
...
17991803
... # numpy output
18001804
... with Session() as lib:
18011805
... with lib.virtualfile_out(kind="dataset") as vouttbl:
18021806
... lib.call_module("read", f"{tmpfile.name} {vouttbl} -Td")
1803-
... outnp = lib.return_table(output_type="numpy", vfile=vouttbl)
1807+
... outnp = lib.return_dataset(output_type="numpy", vfile=vouttbl)
18041808
... assert isinstance(outnp, np.ndarray)
18051809
...
18061810
... # pandas output
18071811
... with Session() as lib:
18081812
... with lib.virtualfile_out(kind="dataset") as vouttbl:
18091813
... lib.call_module("read", f"{tmpfile.name} {vouttbl} -Td")
1810-
... outpd = lib.return_table(output_type="pandas", vfile=vouttbl)
1814+
... outpd = lib.return_dataset(output_type="pandas", vfile=vouttbl)
18111815
... assert isinstance(outpd, pd.DataFrame)
18121816
...
18131817
... # pandas output with specified column names
18141818
... with Session() as lib:
18151819
... with lib.virtualfile_out(kind="dataset") as vouttbl:
18161820
... lib.call_module("read", f"{tmpfile.name} {vouttbl} -Td")
1817-
... outpd2 = lib.return_table(
1821+
... outpd2 = lib.return_dataset(
18181822
... output_type="pandas",
18191823
... vfile=vouttbl,
18201824
... column_names=["col1", "col2", "col3", "coltext"],

0 commit comments

Comments
 (0)