Skip to content

Commit fef7c00

Browse files
committed
Update pygmt.info
1 parent 7718f62 commit fef7c00

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

pygmt/src/info.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,28 @@
22
info - Get information about data tables.
33
"""
44
import numpy as np
5+
from pygmt.alias import Alias, convert_aliases
56
from pygmt.clib import Session
67
from pygmt.helpers import (
78
GMTTempFile,
89
build_arg_string,
910
fmt_docstring,
10-
kwargs_to_strings,
11-
use_alias,
1211
)
1312

1413

1514
@fmt_docstring
16-
@use_alias(
17-
C="per_column",
18-
I="spacing",
19-
T="nearest_multiple",
20-
V="verbose",
21-
a="aspatial",
22-
f="coltypes",
23-
i="incols",
24-
r="registration",
25-
)
26-
@kwargs_to_strings(I="sequence", i="sequence_comma")
27-
def info(data, **kwargs):
15+
def info(
16+
data,
17+
per_column=None,
18+
spacing=None,
19+
nearest_multiple=None,
20+
verbose=None,
21+
aspatial=None,
22+
coltypes=None,
23+
incols=None,
24+
registration=None,
25+
**kwargs,
26+
):
2827
r"""
2928
Get information about data tables.
3029
@@ -43,8 +42,6 @@ def info(data, **kwargs):
4342
4443
Full option list at :gmt-docs:`gmtinfo.html`
4544
46-
{aliases}
47-
4845
Parameters
4946
----------
5047
data : str, {table-like}
@@ -79,17 +76,30 @@ def info(data, **kwargs):
7976
- :class:`numpy.ndarray` if either of the above parameters are used.
8077
- str if none of the above parameters are used.
8178
"""
79+
_aliases = [
80+
Alias("per_column", "C", "", ""),
81+
Alias("spacing", "I", "", "/"),
82+
Alias("nearest_multiple", "T", "", ""),
83+
Alias("verbose", "V", "", ""),
84+
Alias("aspatial", "a", "", ""),
85+
Alias("coltypes", "f", "", ""),
86+
Alias("incols", "i", "", ","),
87+
Alias("registration", "r", "", ""),
88+
]
89+
90+
options = convert_aliases()
91+
8292
with Session() as lib:
8393
file_context = lib.virtualfile_from_data(check_kind="vector", data=data)
8494
with GMTTempFile() as tmpfile:
8595
with file_context as fname:
8696
lib.call_module(
8797
module="info",
88-
args=build_arg_string(kwargs, infile=fname, outfile=tmpfile.name),
98+
args=build_arg_string(options, infile=fname, outfile=tmpfile.name),
8999
)
90100
result = tmpfile.read()
91101

92-
if any(kwargs.get(arg) is not None for arg in ["C", "I", "T"]):
102+
if any(arg is not None for arg in (per_column, spacing, nearest_multiple)):
93103
# Converts certain output types into a numpy array
94104
# instead of a raw string that is less useful.
95105
if result.startswith(("-R", "-T")): # e.g. -R0/1/2/3 or -T0/9/1

0 commit comments

Comments
 (0)