@@ -1738,14 +1738,16 @@ def read_virtualfile(
1738
1738
dtype = {"dataset" : _GMT_DATASET , "grid" : _GMT_GRID }[kind ]
1739
1739
return ctp .cast (pointer , ctp .POINTER (dtype ))
1740
1740
1741
- def return_table (
1741
+ def return_dataset (
1742
1742
self ,
1743
1743
output_type : Literal ["pandas" , "numpy" , "file" ],
1744
1744
vfile : str ,
1745
1745
column_names : list [str ] | None = None ,
1746
1746
) -> pd .DataFrame | np .ndarray | None :
1747
1747
"""
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.
1749
1751
1750
1752
Parameters
1751
1753
----------
@@ -1763,8 +1765,8 @@ def return_table(
1763
1765
1764
1766
Returns
1765
1767
-------
1766
- table
1767
- The output table . If ``output_type="file"`` returns ``None``.
1768
+ result
1769
+ The result dataset . If ``output_type="file"`` returns ``None``.
1768
1770
1769
1771
Examples
1770
1772
--------
@@ -1792,29 +1794,31 @@ def return_table(
1792
1794
... kind="dataset", fname=outtmp.name
1793
1795
... ) as vouttbl:
1794
1796
... 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
+ ... )
1796
1800
... assert result is None
1797
1801
... assert Path(outtmp.name).stat().st_size > 0
1798
1802
...
1799
1803
... # numpy output
1800
1804
... with Session() as lib:
1801
1805
... with lib.virtualfile_out(kind="dataset") as vouttbl:
1802
1806
... 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)
1804
1808
... assert isinstance(outnp, np.ndarray)
1805
1809
...
1806
1810
... # pandas output
1807
1811
... with Session() as lib:
1808
1812
... with lib.virtualfile_out(kind="dataset") as vouttbl:
1809
1813
... 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)
1811
1815
... assert isinstance(outpd, pd.DataFrame)
1812
1816
...
1813
1817
... # pandas output with specified column names
1814
1818
... with Session() as lib:
1815
1819
... with lib.virtualfile_out(kind="dataset") as vouttbl:
1816
1820
... lib.call_module("read", f"{tmpfile.name} {vouttbl} -Td")
1817
- ... outpd2 = lib.return_table (
1821
+ ... outpd2 = lib.return_dataset (
1818
1822
... output_type="pandas",
1819
1823
... vfile=vouttbl,
1820
1824
... column_names=["col1", "col2", "col3", "coltext"],
0 commit comments