2
2
info - Get information about data tables.
3
3
"""
4
4
import numpy as np
5
+ from pygmt .alias import Alias , convert_aliases
5
6
from pygmt .clib import Session
6
7
from pygmt .helpers import (
7
8
GMTTempFile ,
8
9
build_arg_string ,
9
10
fmt_docstring ,
10
- kwargs_to_strings ,
11
- use_alias ,
12
11
)
13
12
14
13
15
14
@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
+ ):
28
27
r"""
29
28
Get information about data tables.
30
29
@@ -43,8 +42,6 @@ def info(data, **kwargs):
43
42
44
43
Full option list at :gmt-docs:`gmtinfo.html`
45
44
46
- {aliases}
47
-
48
45
Parameters
49
46
----------
50
47
data : str, {table-like}
@@ -79,17 +76,30 @@ def info(data, **kwargs):
79
76
- :class:`numpy.ndarray` if either of the above parameters are used.
80
77
- str if none of the above parameters are used.
81
78
"""
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
+
82
92
with Session () as lib :
83
93
file_context = lib .virtualfile_from_data (check_kind = "vector" , data = data )
84
94
with GMTTempFile () as tmpfile :
85
95
with file_context as fname :
86
96
lib .call_module (
87
97
module = "info" ,
88
- args = build_arg_string (kwargs , infile = fname , outfile = tmpfile .name ),
98
+ args = build_arg_string (options , infile = fname , outfile = tmpfile .name ),
89
99
)
90
100
result = tmpfile .read ()
91
101
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 ) ):
93
103
# Converts certain output types into a numpy array
94
104
# instead of a raw string that is less useful.
95
105
if result .startswith (("-R" , "-T" )): # e.g. -R0/1/2/3 or -T0/9/1
0 commit comments