Skip to content

Commit a991908

Browse files
committed
Improve the docstrings of 'output_type' and 'outfile'
1 parent 08a29bb commit a991908

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

pygmt/src/filter1d.py

+20-16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
filter1d - Time domain filtering of 1-D data tables
33
"""
44

5+
from typing import Literal
6+
57
import pandas as pd
68
from pygmt.clib import Session
79
from pygmt.exceptions import GMTInvalidInput
@@ -20,7 +22,12 @@
2022
F="filter_type",
2123
N="time_col",
2224
)
23-
def filter1d(data, output_type="pandas", outfile=None, **kwargs):
25+
def filter1d(
26+
data,
27+
output_type: Literal["pandas", "numpy", "file"] = "pandas",
28+
outfile: str | None = None,
29+
**kwargs,
30+
):
2431
r"""
2532
Time domain filtering of 1-D data tables.
2633
@@ -38,6 +45,15 @@ def filter1d(data, output_type="pandas", outfile=None, **kwargs):
3845
3946
Parameters
4047
----------
48+
output_type
49+
Desired output type of the result data.
50+
51+
- ``pandas`` will return a :class:`pandas.DataFrame` object.
52+
- ``numpy`` will return a :class:`numpy.ndarray` object.
53+
- ``file`` will save the result to the file given by the ``outfile`` parameter.
54+
outfile
55+
The file name for saving the result. If specified, ``output_type`` will be
56+
forced to be ``"file"``.
4157
filter_type : str
4258
**type**\ *width*\ [**+h**].
4359
Set the filter **type**. Choose among convolution and non-convolution
@@ -91,26 +107,14 @@ def filter1d(data, output_type="pandas", outfile=None, **kwargs):
91107
left-most column is 0, while the right-most is (*n_cols* - 1)
92108
[Default is ``0``].
93109
94-
output_type : str
95-
Determine the format the xyz data will be returned in [Default is
96-
``pandas``]:
97-
98-
- ``numpy`` - :class:`numpy.ndarray`
99-
- ``pandas``- :class:`pandas.DataFrame`
100-
- ``file`` - ASCII file (requires ``outfile``)
101-
outfile : str
102-
The file name for the output ASCII file.
103-
104110
Returns
105111
-------
106112
ret : pandas.DataFrame or numpy.ndarray or None
107113
Return type depends on ``outfile`` and ``output_type``:
108114
109-
- None if ``outfile`` is set (output will be stored in file set by
110-
``outfile``)
111-
- :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is
112-
not set (depends on ``output_type`` [Default is
113-
:class:`pandas.DataFrame`])
115+
- None if ``outfile`` is set (output will be stored in file set by ``outfile``)
116+
- :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is not set
117+
(depends on ``output_type``)
114118
"""
115119
if kwargs.get("F") is None:
116120
raise GMTInvalidInput("Pass a required argument to 'filter_type'.")

0 commit comments

Comments
 (0)