Skip to content

Commit 1f419a1

Browse files
committed
Migrate Figure.meca tests to dvc
1 parent ebdb353 commit 1f419a1

15 files changed

+38
-36
lines changed
-4.79 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 7500fa67c18f4e307497e05fbc6857e3
3+
size: 4903
4+
path: test_meca_loc_array.png
-3.13 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 05610aeb221699698eac9d74012b5c0b
3+
size: 3212
4+
path: test_meca_spec_1d_array.png
-5.29 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: b3e49cd999ed234d679f359d7b4fac28
3+
size: 5424
4+
path: test_meca_spec_2d_array.png
-4.45 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 7b7024b143d6b0ec2a339e58db4d7c78
3+
size: 4575
4+
path: test_meca_spec_dataframe.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: a0abe33fb3dc4a67444cabe82cad92ba
3+
size: 3074
4+
path: test_meca_spec_dict_list.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 9077531329696ab21991b6e9595b281a
3+
size: 19564
4+
path: test_meca_spec_dictionary.png
-3.1 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: ad602355748d74a76edfa5cef4100b13
3+
size: 3179
4+
path: test_meca_spec_file.png

pygmt/tests/test_meca.py

+10-36
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
@pytest.mark.mpl_image_compare
1616
def test_meca_spec_dictionary():
1717
"""
18-
Test supplying a dictionary containing a single focal mechanism to the
19-
`spec` argument.
18+
Test supplying a dictionary containing a single focal mechanism to the spec
19+
argument.
2020
"""
21-
2221
fig = Figure()
23-
2422
# Right lateral strike slip focal mechanism
2523
fig.meca(
2624
dict(strike=0, dip=90, rake=0, magnitude=5),
@@ -32,24 +30,20 @@ def test_meca_spec_dictionary():
3230
projection="M14c",
3331
frame=2,
3432
)
35-
3633
return fig
3734

3835

3936
@pytest.mark.mpl_image_compare
4037
def test_meca_spec_dict_list():
4138
"""
42-
Test supplying a dictionary containing a list of focal mechanism to the
43-
`spec` argument.
39+
Test supplying a dictionary containing a list of focal mechanism to the spec
40+
argument.
4441
"""
45-
4642
fig = Figure()
47-
4843
# supply focal mechanisms as a dict of lists
4944
focal_mechanisms = dict(
5045
strike=[330, 350], dip=[30, 50], rake=[90, 90], magnitude=[3, 2]
5146
)
52-
5347
fig.meca(
5448
focal_mechanisms,
5549
longitude=[-124.3, -124.4],
@@ -59,15 +53,14 @@ def test_meca_spec_dict_list():
5953
scale="2c",
6054
projection="M14c",
6155
)
62-
6356
return fig
6457

6558

6659
@pytest.mark.mpl_image_compare
6760
def test_meca_spec_dataframe():
6861
"""
69-
Test supplying a pandas DataFrame containing focal mechanisms and locations
70-
to the `spec` argument.
62+
Test supplying a pandas.DataFrame containing focal mechanisms and locations
63+
to the spec argument.
7164
"""
7265

7366
fig = Figure()
@@ -83,21 +76,17 @@ def test_meca_spec_dataframe():
8376
depth=[12, 11.0],
8477
)
8578
spec_dataframe = pd.DataFrame(data=focal_mechanisms)
86-
8779
fig.meca(spec_dataframe, region=[-125, -122, 47, 49], scale="2c", projection="M14c")
88-
8980
return fig
9081

9182

9283
@pytest.mark.mpl_image_compare
9384
def test_meca_spec_1d_array():
9485
"""
9586
Test supplying a 1D numpy array containing focal mechanisms and locations
96-
to the `spec` argument.
87+
to the spec argument.
9788
"""
98-
9989
fig = Figure()
100-
10190
# supply focal mechanisms to meca as a 1D numpy array, here we are using
10291
# the Harvard CMT zero trace convention but the focal mechanism
10392
# parameters may be specified any of the available conventions. Since we
@@ -118,7 +107,6 @@ def test_meca_spec_1d_array():
118107
0, # plot_lat, 0 to plot at event location
119108
]
120109
focal_mech_array = np.asarray(focal_mechanism)
121-
122110
fig.meca(
123111
focal_mech_array,
124112
convention="mt",
@@ -127,19 +115,16 @@ def test_meca_spec_1d_array():
127115
scale="2c",
128116
projection="M14c",
129117
)
130-
131118
return fig
132119

133120

134121
@pytest.mark.mpl_image_compare
135122
def test_meca_spec_2d_array():
136123
"""
137124
Test supplying a 2D numpy array containing focal mechanisms and locations
138-
to the `spec` argument.
125+
to the spec argument.
139126
"""
140-
141127
fig = Figure()
142-
143128
# supply focal mechanisms to meca as a 2D numpy array, here we are using
144129
# the GCMT convention but the focal mechanism parameters may be
145130
# specified any of the available conventions. Since we are not using a
@@ -163,29 +148,25 @@ def test_meca_spec_2d_array():
163148
[-127.50, 40.88, 12.0, 168, 40, -115, 20, 54, -70, 4.0, 23, 0, 0],
164149
]
165150
focal_mechs_array = np.asarray(focal_mechanisms)
166-
167151
fig.meca(
168152
focal_mechs_array,
169153
convention="gcmt",
170154
region=[-128, -127, 40, 41],
171155
scale="2c",
172156
projection="M14c",
173157
)
174-
175158
return fig
176159

177160

178161
@pytest.mark.mpl_image_compare
179162
def test_meca_spec_file():
180163
"""
181-
Test supplying a file containing focal mechanisms and locations to the
182-
`spec` argument.
164+
Test supplying a file containing focal mechanisms and locations to the spec
165+
argument.
183166
"""
184167

185168
fig = Figure()
186-
187169
focal_mechanism = [-127.43, 40.81, 12, -3.19, 1.16, 3.93, -1.02, -3.93, -1.02, 23]
188-
189170
# writes temp file to pass to gmt
190171
with GMTTempFile() as temp:
191172
with open(temp.name, mode="w") as temp_file:
@@ -199,7 +180,6 @@ def test_meca_spec_file():
199180
scale="2c",
200181
projection="M14c",
201182
)
202-
203183
return fig
204184

205185

@@ -209,22 +189,17 @@ def test_meca_loc_array():
209189
Test supplying lists and np.ndarrays as the event location (longitude,
210190
latitude, and depth).
211191
"""
212-
213192
fig = Figure()
214-
215193
# specify focal mechanisms
216194
focal_mechanisms = dict(
217195
strike=[327, 350], dip=[41, 50], rake=[68, 90], magnitude=[3, 2]
218196
)
219-
220197
# longitude, latitude, and depth may be specified as an int, float,
221198
# list, or 1d numpy array
222199
longitude = np.array([-123.3, -124.4])
223200
latitude = np.array([48.4, 48.2])
224201
depth = [12.0, 11.0] # to test mixed data types as inputs
225-
226202
scale = "2c"
227-
228203
fig.meca(
229204
focal_mechanisms,
230205
scale,
@@ -234,5 +209,4 @@ def test_meca_loc_array():
234209
region=[-125, -122, 47, 49],
235210
projection="M14c",
236211
)
237-
238212
return fig

0 commit comments

Comments
 (0)