@@ -21,7 +21,7 @@ def test_info():
21
21
"""
22
22
Make sure info works on file name inputs.
23
23
"""
24
- output = info (table = POINTS_DATA )
24
+ output = info (data = POINTS_DATA )
25
25
expected_output = (
26
26
f"{ POINTS_DATA } : N = 20 "
27
27
"<11.5309/61.7074> "
@@ -31,6 +31,23 @@ def test_info():
31
31
assert output == expected_output
32
32
33
33
34
+ def test_info_deprecate_table_to_data ():
35
+ """
36
+ Make sure that the old parameter "table" is supported and it reports a
37
+ warning.
38
+ """
39
+ with pytest .warns (expected_warning = FutureWarning ) as record :
40
+ output = info (table = POINTS_DATA ) # pylint: disable=no-value-for-parameter
41
+ expected_output = (
42
+ f"{ POINTS_DATA } : N = 20 "
43
+ "<11.5309/61.7074> "
44
+ "<-2.9289/7.8648> "
45
+ "<0.1412/0.9338>\n "
46
+ )
47
+ assert output == expected_output
48
+ assert len (record ) == 1 # check that only one warning was raised
49
+
50
+
34
51
@pytest .mark .parametrize (
35
52
"table" ,
36
53
[
@@ -55,7 +72,7 @@ def test_info_path(table):
55
72
"""
56
73
Make sure info works on a pathlib.Path input.
57
74
"""
58
- output = info (table = table )
75
+ output = info (data = table )
59
76
expected_output = (
60
77
f"{ POINTS_DATA } : N = 20 "
61
78
"<11.5309/61.7074> "
@@ -69,7 +86,7 @@ def test_info_2d_list():
69
86
"""
70
87
Make sure info works on a 2d list.
71
88
"""
72
- output = info (table = [[0 , 8 ], [3 , 5 ], [6 , 2 ]])
89
+ output = info (data = [[0 , 8 ], [3 , 5 ], [6 , 2 ]])
73
90
expected_output = "<vector memory>: N = 3 <0/6> <2/8>\n "
74
91
assert output == expected_output
75
92
@@ -88,7 +105,7 @@ def test_info_dataframe():
88
105
Make sure info works on pandas.DataFrame inputs.
89
106
"""
90
107
table = pd .read_csv (POINTS_DATA , sep = " " , header = None )
91
- output = info (table = table )
108
+ output = info (data = table )
92
109
expected_output = (
93
110
"<vector memory>: N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n "
94
111
)
@@ -100,7 +117,7 @@ def test_info_numpy_array_time_column():
100
117
Make sure info works on a numpy.ndarray input with a datetime type.
101
118
"""
102
119
table = pd .date_range (start = "2020-01-01" , periods = 5 ).to_numpy ()
103
- output = info (table = table )
120
+ output = info (data = table )
104
121
expected_output = (
105
122
"<vector memory>: N = 5 <2020-01-01T00:00:00/2020-01-05T00:00:00>\n "
106
123
)
@@ -117,7 +134,7 @@ def test_info_pandas_dataframe_time_column():
117
134
"time" : pd .date_range (start = "2020-01-01" , periods = 5 ),
118
135
}
119
136
)
120
- output = info (table = table )
137
+ output = info (data = table )
121
138
expected_output = (
122
139
"<vector memory>: N = 5 <10/15> <2020-01-01T00:00:00/2020-01-05T00:00:00>\n "
123
140
)
@@ -135,7 +152,7 @@ def test_info_xarray_dataset_time_column():
135
152
"time" : ("index" , pd .date_range (start = "2020-01-01" , periods = 5 )),
136
153
},
137
154
)
138
- output = info (table = table )
155
+ output = info (data = table )
139
156
expected_output = (
140
157
"<vector memory>: N = 5 <10/15> <2020-01-01T00:00:00/2020-01-05T00:00:00>\n "
141
158
)
@@ -147,7 +164,7 @@ def test_info_2d_array():
147
164
Make sure info works on 2D numpy.ndarray inputs.
148
165
"""
149
166
table = np .loadtxt (POINTS_DATA )
150
- output = info (table = table )
167
+ output = info (data = table )
151
168
expected_output = (
152
169
"<matrix memory>: N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n "
153
170
)
@@ -158,7 +175,7 @@ def test_info_1d_array():
158
175
"""
159
176
Make sure info works on 1D numpy.ndarray inputs.
160
177
"""
161
- output = info (table = np .arange (20 ))
178
+ output = info (data = np .arange (20 ))
162
179
expected_output = "<vector memory>: N = 20 <0/19>\n "
163
180
assert output == expected_output
164
181
@@ -167,7 +184,7 @@ def test_info_per_column():
167
184
"""
168
185
Make sure the per_column option works.
169
186
"""
170
- output = info (table = POINTS_DATA , per_column = True )
187
+ output = info (data = POINTS_DATA , per_column = True )
171
188
npt .assert_allclose (
172
189
actual = output , desired = [11.5309 , 61.7074 , - 2.9289 , 7.8648 , 0.1412 , 0.9338 ]
173
190
)
@@ -178,7 +195,7 @@ def test_info_per_column_with_time_inputs():
178
195
Make sure the per_column option works with time inputs.
179
196
"""
180
197
table = pd .date_range (start = "2020-01-01" , periods = 5 ).to_numpy ()
181
- output = info (table = table , per_column = True )
198
+ output = info (data = table , per_column = True )
182
199
npt .assert_equal (
183
200
actual = output , desired = ["2020-01-01T00:00:00" , "2020-01-05T00:00:00" ]
184
201
)
@@ -188,15 +205,15 @@ def test_info_spacing():
188
205
"""
189
206
Make sure the spacing option works.
190
207
"""
191
- output = info (table = POINTS_DATA , spacing = 0.1 )
208
+ output = info (data = POINTS_DATA , spacing = 0.1 )
192
209
npt .assert_allclose (actual = output , desired = [11.5 , 61.8 , - 3 , 7.9 ])
193
210
194
211
195
212
def test_info_spacing_bounding_box ():
196
213
"""
197
214
Make sure the spacing option for writing a bounding box works.
198
215
"""
199
- output = info (table = POINTS_DATA , spacing = "b" )
216
+ output = info (data = POINTS_DATA , spacing = "b" )
200
217
npt .assert_allclose (
201
218
actual = output ,
202
219
desired = [
@@ -213,15 +230,15 @@ def test_info_per_column_spacing():
213
230
"""
214
231
Make sure the per_column and spacing options work together.
215
232
"""
216
- output = info (table = POINTS_DATA , per_column = True , spacing = 0.1 )
233
+ output = info (data = POINTS_DATA , per_column = True , spacing = 0.1 )
217
234
npt .assert_allclose (actual = output , desired = [11.5 , 61.8 , - 3 , 7.9 , 0.1412 , 0.9338 ])
218
235
219
236
220
237
def test_info_nearest_multiple ():
221
238
"""
222
239
Make sure the nearest_multiple option works.
223
240
"""
224
- output = info (table = POINTS_DATA , nearest_multiple = 0.1 )
241
+ output = info (data = POINTS_DATA , nearest_multiple = 0.1 )
225
242
npt .assert_allclose (actual = output , desired = [11.5 , 61.8 , 0.1 ])
226
243
227
244
@@ -231,4 +248,4 @@ def test_info_fails():
231
248
DataFrame, or numpy ndarray.
232
249
"""
233
250
with pytest .raises (GMTInvalidInput ):
234
- info (table = xr .DataArray (21 ))
251
+ info (data = xr .DataArray (21 ))
0 commit comments