earthsciencekit 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- earthsciencekit/__init__.py +6 -0
- earthsciencekit/_validation.py +62 -0
- earthsciencekit/atmosphere/__init__.py +57 -0
- earthsciencekit/atmosphere/core/__init__.py +5 -0
- earthsciencekit/atmosphere/core/base.py +10 -0
- earthsciencekit/atmosphere/systems/__init__.py +1 -0
- earthsciencekit/atmosphere/systems/dynamics.py +208 -0
- earthsciencekit/atmosphere/systems/hydrostatics.py +214 -0
- earthsciencekit/atmosphere/systems/moisture.py +162 -0
- earthsciencekit/atmosphere/systems/thermodynamics.py +222 -0
- earthsciencekit/atmosphere/tests/__init__.py +0 -0
- earthsciencekit/atmosphere/tests/test_models.py +741 -0
- earthsciencekit/atmosphere/tests/test_physics.py +81 -0
- earthsciencekit/atmosphere/visualizers/__init__.py +9 -0
- earthsciencekit/climate/__init__.py +63 -0
- earthsciencekit/climate/core/__init__.py +5 -0
- earthsciencekit/climate/core/base.py +10 -0
- earthsciencekit/climate/systems/__init__.py +1 -0
- earthsciencekit/climate/systems/carbon.py +76 -0
- earthsciencekit/climate/systems/forcing.py +124 -0
- earthsciencekit/climate/systems/radiation.py +214 -0
- earthsciencekit/climate/systems/response.py +402 -0
- earthsciencekit/climate/systems/sea_level.py +77 -0
- earthsciencekit/climate/tests/__init__.py +0 -0
- earthsciencekit/climate/tests/test_models.py +1015 -0
- earthsciencekit/climate/tests/test_physics.py +16 -0
- earthsciencekit/climate/visualizers/__init__.py +9 -0
- earthsciencekit/constants/__init__.py +23 -0
- earthsciencekit/geophysics/__init__.py +77 -0
- earthsciencekit/geophysics/core/__init__.py +5 -0
- earthsciencekit/geophysics/core/base.py +10 -0
- earthsciencekit/geophysics/systems/__init__.py +1 -0
- earthsciencekit/geophysics/systems/deformation.py +161 -0
- earthsciencekit/geophysics/systems/dynamo.py +159 -0
- earthsciencekit/geophysics/systems/figure.py +292 -0
- earthsciencekit/geophysics/systems/gravity.py +235 -0
- earthsciencekit/geophysics/systems/magnetism.py +354 -0
- earthsciencekit/geophysics/tests/__init__.py +0 -0
- earthsciencekit/geophysics/tests/test_models.py +898 -0
- earthsciencekit/geophysics/tests/test_physics.py +171 -0
- earthsciencekit/geophysics/visualizers/__init__.py +9 -0
- earthsciencekit/integrators/__init__.py +62 -0
- earthsciencekit/oceanography/__init__.py +61 -0
- earthsciencekit/oceanography/core/__init__.py +5 -0
- earthsciencekit/oceanography/core/base.py +10 -0
- earthsciencekit/oceanography/systems/__init__.py +1 -0
- earthsciencekit/oceanography/systems/circulation.py +388 -0
- earthsciencekit/oceanography/systems/hydrography.py +212 -0
- earthsciencekit/oceanography/systems/inertial.py +86 -0
- earthsciencekit/oceanography/systems/waves.py +281 -0
- earthsciencekit/oceanography/tests/__init__.py +0 -0
- earthsciencekit/oceanography/tests/test_models.py +916 -0
- earthsciencekit/oceanography/tests/test_physics.py +102 -0
- earthsciencekit/oceanography/visualizers/__init__.py +9 -0
- earthsciencekit/plate_tectonics/__init__.py +59 -0
- earthsciencekit/plate_tectonics/core/__init__.py +5 -0
- earthsciencekit/plate_tectonics/core/base.py +10 -0
- earthsciencekit/plate_tectonics/systems/__init__.py +1 -0
- earthsciencekit/plate_tectonics/systems/boundaries.py +201 -0
- earthsciencekit/plate_tectonics/systems/cooling.py +238 -0
- earthsciencekit/plate_tectonics/systems/isostasy.py +157 -0
- earthsciencekit/plate_tectonics/systems/kinematics.py +290 -0
- earthsciencekit/plate_tectonics/tests/__init__.py +0 -0
- earthsciencekit/plate_tectonics/tests/test_models.py +920 -0
- earthsciencekit/plate_tectonics/tests/test_physics.py +94 -0
- earthsciencekit/plate_tectonics/visualizers/__init__.py +9 -0
- earthsciencekit/py.typed +0 -0
- earthsciencekit/results.py +73 -0
- earthsciencekit/seismology/__init__.py +59 -0
- earthsciencekit/seismology/core/__init__.py +5 -0
- earthsciencekit/seismology/core/base.py +10 -0
- earthsciencekit/seismology/systems/__init__.py +1 -0
- earthsciencekit/seismology/systems/interfaces.py +102 -0
- earthsciencekit/seismology/systems/rays.py +221 -0
- earthsciencekit/seismology/systems/sources.py +249 -0
- earthsciencekit/seismology/systems/waves.py +268 -0
- earthsciencekit/seismology/tests/__init__.py +0 -0
- earthsciencekit/seismology/tests/test_models.py +852 -0
- earthsciencekit/seismology/tests/test_physics.py +100 -0
- earthsciencekit/seismology/visualizers/__init__.py +9 -0
- earthsciencekit/tests/__init__.py +0 -0
- earthsciencekit/tests/test_core.py +181 -0
- earthsciencekit/tests/test_relations.py +36 -0
- earthsciencekit/units/__init__.py +66 -0
- earthsciencekit/visualizers/__init__.py +45 -0
- earthsciencekit/volcanology/__init__.py +61 -0
- earthsciencekit/volcanology/core/__init__.py +5 -0
- earthsciencekit/volcanology/core/base.py +10 -0
- earthsciencekit/volcanology/systems/__init__.py +1 -0
- earthsciencekit/volcanology/systems/eruptions.py +161 -0
- earthsciencekit/volcanology/systems/geochemistry.py +226 -0
- earthsciencekit/volcanology/systems/geochronology.py +304 -0
- earthsciencekit/volcanology/systems/magma.py +190 -0
- earthsciencekit/volcanology/tests/__init__.py +0 -0
- earthsciencekit/volcanology/tests/test_models.py +485 -0
- earthsciencekit/volcanology/tests/test_physics.py +176 -0
- earthsciencekit/volcanology/visualizers/__init__.py +9 -0
- earthsciencekit-0.2.0.dist-info/METADATA +127 -0
- earthsciencekit-0.2.0.dist-info/RECORD +102 -0
- earthsciencekit-0.2.0.dist-info/WHEEL +5 -0
- earthsciencekit-0.2.0.dist-info/licenses/LICENSE +15 -0
- earthsciencekit-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,920 @@
|
|
|
1
|
+
"""Golden checks and invalid-input contracts for every public model."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from earthsciencekit import plate_tectonics as domain
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_angular_speed_reference():
|
|
10
|
+
result = domain.angular_speed(*[0.1, 10])
|
|
11
|
+
np.testing.assert_allclose(result, 0.01, rtol=1e-11, atol=1e-12)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
15
|
+
def test_angular_speed_rejects_invalid(bad):
|
|
16
|
+
args = [0.1, 10]
|
|
17
|
+
args[0] = bad
|
|
18
|
+
with pytest.raises(ValueError):
|
|
19
|
+
domain.angular_speed(*args)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_plate_speed_reference():
|
|
23
|
+
result = domain.plate_speed(*[1e-09, 6000000.0, 1.5707963267948966])
|
|
24
|
+
np.testing.assert_allclose(result, 0.006, rtol=1e-11, atol=1e-12)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
28
|
+
def test_plate_speed_rejects_invalid(bad):
|
|
29
|
+
args = [1e-09, 6000000.0, 1.5707963267948966]
|
|
30
|
+
args[0] = bad
|
|
31
|
+
with pytest.raises(ValueError):
|
|
32
|
+
domain.plate_speed(*args)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_euler_velocity_x_reference():
|
|
36
|
+
result = domain.euler_velocity_x(*[1, 2, 3, 4])
|
|
37
|
+
np.testing.assert_allclose(result, -2, rtol=1e-11, atol=1e-12)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
41
|
+
def test_euler_velocity_x_rejects_invalid(bad):
|
|
42
|
+
args = [1, 2, 3, 4]
|
|
43
|
+
args[0] = bad
|
|
44
|
+
with pytest.raises(ValueError):
|
|
45
|
+
domain.euler_velocity_x(*args)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_euler_velocity_y_reference():
|
|
49
|
+
result = domain.euler_velocity_y(*[2, 1, 4, 3])
|
|
50
|
+
np.testing.assert_allclose(result, 2, rtol=1e-11, atol=1e-12)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
54
|
+
def test_euler_velocity_y_rejects_invalid(bad):
|
|
55
|
+
args = [2, 1, 4, 3]
|
|
56
|
+
args[0] = bad
|
|
57
|
+
with pytest.raises(ValueError):
|
|
58
|
+
domain.euler_velocity_y(*args)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_euler_velocity_z_reference():
|
|
62
|
+
result = domain.euler_velocity_z(*[1, 2, 3, 4])
|
|
63
|
+
np.testing.assert_allclose(result, -2, rtol=1e-11, atol=1e-12)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
67
|
+
def test_euler_velocity_z_rejects_invalid(bad):
|
|
68
|
+
args = [1, 2, 3, 4]
|
|
69
|
+
args[0] = bad
|
|
70
|
+
with pytest.raises(ValueError):
|
|
71
|
+
domain.euler_velocity_z(*args)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_plate_displacement_reference():
|
|
75
|
+
result = domain.plate_displacement(*[0.01, 100])
|
|
76
|
+
np.testing.assert_allclose(result, 1, rtol=1e-11, atol=1e-12)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
80
|
+
def test_plate_displacement_rejects_invalid(bad):
|
|
81
|
+
args = [0.01, 100]
|
|
82
|
+
args[0] = bad
|
|
83
|
+
with pytest.raises(ValueError):
|
|
84
|
+
domain.plate_displacement(*args)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_spreading_age_reference():
|
|
88
|
+
result = domain.spreading_age(*[100, 2])
|
|
89
|
+
np.testing.assert_allclose(result, 50, rtol=1e-11, atol=1e-12)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
93
|
+
def test_spreading_age_rejects_invalid(bad):
|
|
94
|
+
args = [100, 2]
|
|
95
|
+
args[0] = bad
|
|
96
|
+
with pytest.raises(ValueError):
|
|
97
|
+
domain.spreading_age(*args)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_full_spreading_rate_reference():
|
|
101
|
+
result = domain.full_spreading_rate(*[0.001])
|
|
102
|
+
np.testing.assert_allclose(result, 0.002, rtol=1e-11, atol=1e-12)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
106
|
+
def test_full_spreading_rate_rejects_invalid(bad):
|
|
107
|
+
args = [0.001]
|
|
108
|
+
args[0] = bad
|
|
109
|
+
with pytest.raises(ValueError):
|
|
110
|
+
domain.full_spreading_rate(*args)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_convergence_rate_reference():
|
|
114
|
+
result = domain.convergence_rate(*[2, 1.0471975511965976])
|
|
115
|
+
np.testing.assert_allclose(result, 1, rtol=1e-11, atol=1e-12)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
119
|
+
def test_convergence_rate_rejects_invalid(bad):
|
|
120
|
+
args = [2, 1.0471975511965976]
|
|
121
|
+
args[0] = bad
|
|
122
|
+
with pytest.raises(ValueError):
|
|
123
|
+
domain.convergence_rate(*args)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def test_fault_slip_rate_reference():
|
|
127
|
+
result = domain.fault_slip_rate(*[2, 0.5235987755982988])
|
|
128
|
+
np.testing.assert_allclose(result, 1, rtol=1e-11, atol=1e-12)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
132
|
+
def test_fault_slip_rate_rejects_invalid(bad):
|
|
133
|
+
args = [2, 0.5235987755982988]
|
|
134
|
+
args[0] = bad
|
|
135
|
+
with pytest.raises(ValueError):
|
|
136
|
+
domain.fault_slip_rate(*args)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_subduction_travel_time_reference():
|
|
140
|
+
result = domain.subduction_travel_time(*[100, 2, 0.5235987755982988])
|
|
141
|
+
np.testing.assert_allclose(result, 100, rtol=1e-11, atol=1e-12)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
145
|
+
def test_subduction_travel_time_rejects_invalid(bad):
|
|
146
|
+
args = [100, 2, 0.5235987755982988]
|
|
147
|
+
args[0] = bad
|
|
148
|
+
with pytest.raises(ValueError):
|
|
149
|
+
domain.subduction_travel_time(*args)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_slab_pull_force_reference():
|
|
153
|
+
result = domain.slab_pull_force(*[100, 1000000000.0, 10])
|
|
154
|
+
np.testing.assert_allclose(result, 1e12, rtol=1e-11, atol=1e-12)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
158
|
+
def test_slab_pull_force_rejects_invalid(bad):
|
|
159
|
+
args = [100, 1000000000.0, 10]
|
|
160
|
+
args[0] = bad
|
|
161
|
+
with pytest.raises(ValueError):
|
|
162
|
+
domain.slab_pull_force(*args)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_airy_root_reference():
|
|
166
|
+
result = domain.airy_root(*[1000, 2700, 3300])
|
|
167
|
+
np.testing.assert_allclose(result, 4500, rtol=1e-11, atol=1e-12)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
171
|
+
def test_airy_root_rejects_invalid(bad):
|
|
172
|
+
args = [1000, 2700, 3300]
|
|
173
|
+
args[0] = bad
|
|
174
|
+
with pytest.raises(ValueError):
|
|
175
|
+
domain.airy_root(*args)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def test_flexural_rigidity_reference():
|
|
179
|
+
result = domain.flexural_rigidity(*[12, 1, 0])
|
|
180
|
+
np.testing.assert_allclose(result, 1, rtol=1e-11, atol=1e-12)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
184
|
+
def test_flexural_rigidity_rejects_invalid(bad):
|
|
185
|
+
args = [12, 1, 0]
|
|
186
|
+
args[0] = bad
|
|
187
|
+
with pytest.raises(ValueError):
|
|
188
|
+
domain.flexural_rigidity(*args)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def test_flexural_parameter_reference():
|
|
192
|
+
result = domain.flexural_parameter(*[4, 1, 1])
|
|
193
|
+
np.testing.assert_allclose(result, 2, rtol=1e-11, atol=1e-12)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
197
|
+
def test_flexural_parameter_rejects_invalid(bad):
|
|
198
|
+
args = [4, 1, 1]
|
|
199
|
+
args[0] = bad
|
|
200
|
+
with pytest.raises(ValueError):
|
|
201
|
+
domain.flexural_parameter(*args)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def test_halfspace_temperature_reference():
|
|
205
|
+
result = domain.halfspace_temperature(*[0, 1, 1, 300, 1300])
|
|
206
|
+
np.testing.assert_allclose(result, 300, rtol=1e-11, atol=1e-12)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
210
|
+
def test_halfspace_temperature_rejects_invalid(bad):
|
|
211
|
+
args = [0, 1, 1, 300, 1300]
|
|
212
|
+
args[0] = bad
|
|
213
|
+
with pytest.raises(ValueError):
|
|
214
|
+
domain.halfspace_temperature(*args)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_halfspace_heat_flux_reference():
|
|
218
|
+
result = domain.halfspace_heat_flux(*[1, 1, 1, 300, 1300])
|
|
219
|
+
np.testing.assert_allclose(result, 1000 / np.sqrt(np.pi), rtol=1e-11, atol=1e-12)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
223
|
+
def test_halfspace_heat_flux_rejects_invalid(bad):
|
|
224
|
+
args = [1, 1, 1, 300, 1300]
|
|
225
|
+
args[0] = bad
|
|
226
|
+
with pytest.raises(ValueError):
|
|
227
|
+
domain.halfspace_heat_flux(*args)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def test_angular_speed_broadcasting():
|
|
231
|
+
args = [0.1, 10]
|
|
232
|
+
reference = domain.angular_speed(*args)
|
|
233
|
+
args[0] = np.full((2, 1), args[0])
|
|
234
|
+
result = domain.angular_speed(*args)
|
|
235
|
+
assert result.shape == (2, 1)
|
|
236
|
+
np.testing.assert_allclose(result, reference)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def test_angular_speed_time_physical_bound():
|
|
240
|
+
args = [0.1, 10]
|
|
241
|
+
args[1] = 0
|
|
242
|
+
with pytest.raises(ValueError):
|
|
243
|
+
domain.angular_speed(*args)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def test_plate_speed_broadcasting():
|
|
247
|
+
args = [1e-09, 6000000.0, 1.5707963267948966]
|
|
248
|
+
reference = domain.plate_speed(*args)
|
|
249
|
+
args[0] = np.full((2, 1), args[0])
|
|
250
|
+
result = domain.plate_speed(*args)
|
|
251
|
+
assert result.shape == (2, 1)
|
|
252
|
+
np.testing.assert_allclose(result, reference)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def test_plate_speed_angular_speed_physical_bound():
|
|
256
|
+
args = [1e-09, 6000000.0, 1.5707963267948966]
|
|
257
|
+
args[0] = -1
|
|
258
|
+
with pytest.raises(ValueError):
|
|
259
|
+
domain.plate_speed(*args)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def test_plate_speed_radius_physical_bound():
|
|
263
|
+
args = [1e-09, 6000000.0, 1.5707963267948966]
|
|
264
|
+
args[1] = 0
|
|
265
|
+
with pytest.raises(ValueError):
|
|
266
|
+
domain.plate_speed(*args)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def test_plate_speed_angular_distance_physical_bound():
|
|
270
|
+
args = [1e-09, 6000000.0, 1.5707963267948966]
|
|
271
|
+
args[2] = 7
|
|
272
|
+
with pytest.raises(ValueError):
|
|
273
|
+
domain.plate_speed(*args)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def test_euler_velocity_x_broadcasting():
|
|
277
|
+
args = [1, 2, 3, 4]
|
|
278
|
+
reference = domain.euler_velocity_x(*args)
|
|
279
|
+
args[0] = np.full((2, 1), args[0])
|
|
280
|
+
result = domain.euler_velocity_x(*args)
|
|
281
|
+
assert result.shape == (2, 1)
|
|
282
|
+
np.testing.assert_allclose(result, reference)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def test_euler_velocity_y_broadcasting():
|
|
286
|
+
args = [2, 1, 4, 3]
|
|
287
|
+
reference = domain.euler_velocity_y(*args)
|
|
288
|
+
args[0] = np.full((2, 1), args[0])
|
|
289
|
+
result = domain.euler_velocity_y(*args)
|
|
290
|
+
assert result.shape == (2, 1)
|
|
291
|
+
np.testing.assert_allclose(result, reference)
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def test_euler_velocity_z_broadcasting():
|
|
295
|
+
args = [1, 2, 3, 4]
|
|
296
|
+
reference = domain.euler_velocity_z(*args)
|
|
297
|
+
args[0] = np.full((2, 1), args[0])
|
|
298
|
+
result = domain.euler_velocity_z(*args)
|
|
299
|
+
assert result.shape == (2, 1)
|
|
300
|
+
np.testing.assert_allclose(result, reference)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def test_plate_displacement_broadcasting():
|
|
304
|
+
args = [0.01, 100]
|
|
305
|
+
reference = domain.plate_displacement(*args)
|
|
306
|
+
args[0] = np.full((2, 1), args[0])
|
|
307
|
+
result = domain.plate_displacement(*args)
|
|
308
|
+
assert result.shape == (2, 1)
|
|
309
|
+
np.testing.assert_allclose(result, reference)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def test_plate_displacement_time_physical_bound():
|
|
313
|
+
args = [0.01, 100]
|
|
314
|
+
args[1] = -1
|
|
315
|
+
with pytest.raises(ValueError):
|
|
316
|
+
domain.plate_displacement(*args)
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def test_spreading_age_broadcasting():
|
|
320
|
+
args = [100, 2]
|
|
321
|
+
reference = domain.spreading_age(*args)
|
|
322
|
+
args[0] = np.full((2, 1), args[0])
|
|
323
|
+
result = domain.spreading_age(*args)
|
|
324
|
+
assert result.shape == (2, 1)
|
|
325
|
+
np.testing.assert_allclose(result, reference)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def test_spreading_age_distance_physical_bound():
|
|
329
|
+
args = [100, 2]
|
|
330
|
+
args[0] = -1
|
|
331
|
+
with pytest.raises(ValueError):
|
|
332
|
+
domain.spreading_age(*args)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def test_spreading_age_half_spreading_rate_physical_bound():
|
|
336
|
+
args = [100, 2]
|
|
337
|
+
args[1] = 0
|
|
338
|
+
with pytest.raises(ValueError):
|
|
339
|
+
domain.spreading_age(*args)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def test_full_spreading_rate_broadcasting():
|
|
343
|
+
args = [0.001]
|
|
344
|
+
reference = domain.full_spreading_rate(*args)
|
|
345
|
+
args[0] = np.full((2, 1), args[0])
|
|
346
|
+
result = domain.full_spreading_rate(*args)
|
|
347
|
+
assert result.shape == (2, 1)
|
|
348
|
+
np.testing.assert_allclose(result, reference)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def test_full_spreading_rate_half_spreading_rate_physical_bound():
|
|
352
|
+
args = [0.001]
|
|
353
|
+
args[0] = -1
|
|
354
|
+
with pytest.raises(ValueError):
|
|
355
|
+
domain.full_spreading_rate(*args)
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def test_convergence_rate_broadcasting():
|
|
359
|
+
args = [2, 1.0471975511965976]
|
|
360
|
+
reference = domain.convergence_rate(*args)
|
|
361
|
+
args[0] = np.full((2, 1), args[0])
|
|
362
|
+
result = domain.convergence_rate(*args)
|
|
363
|
+
assert result.shape == (2, 1)
|
|
364
|
+
np.testing.assert_allclose(result, reference)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def test_convergence_rate_relative_speed_physical_bound():
|
|
368
|
+
args = [2, 1.0471975511965976]
|
|
369
|
+
args[0] = -1
|
|
370
|
+
with pytest.raises(ValueError):
|
|
371
|
+
domain.convergence_rate(*args)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def test_convergence_rate_obliquity_physical_bound():
|
|
375
|
+
args = [2, 1.0471975511965976]
|
|
376
|
+
args[1] = 7
|
|
377
|
+
with pytest.raises(ValueError):
|
|
378
|
+
domain.convergence_rate(*args)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def test_fault_slip_rate_broadcasting():
|
|
382
|
+
args = [2, 0.5235987755982988]
|
|
383
|
+
reference = domain.fault_slip_rate(*args)
|
|
384
|
+
args[0] = np.full((2, 1), args[0])
|
|
385
|
+
result = domain.fault_slip_rate(*args)
|
|
386
|
+
assert result.shape == (2, 1)
|
|
387
|
+
np.testing.assert_allclose(result, reference)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def test_fault_slip_rate_relative_speed_physical_bound():
|
|
391
|
+
args = [2, 0.5235987755982988]
|
|
392
|
+
args[0] = -1
|
|
393
|
+
with pytest.raises(ValueError):
|
|
394
|
+
domain.fault_slip_rate(*args)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
def test_fault_slip_rate_obliquity_physical_bound():
|
|
398
|
+
args = [2, 0.5235987755982988]
|
|
399
|
+
args[1] = 7
|
|
400
|
+
with pytest.raises(ValueError):
|
|
401
|
+
domain.fault_slip_rate(*args)
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
def test_subduction_travel_time_broadcasting():
|
|
405
|
+
args = [100, 2, 0.5235987755982988]
|
|
406
|
+
reference = domain.subduction_travel_time(*args)
|
|
407
|
+
args[0] = np.full((2, 1), args[0])
|
|
408
|
+
result = domain.subduction_travel_time(*args)
|
|
409
|
+
assert result.shape == (2, 1)
|
|
410
|
+
np.testing.assert_allclose(result, reference)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
def test_subduction_travel_time_vertical_depth_physical_bound():
|
|
414
|
+
args = [100, 2, 0.5235987755982988]
|
|
415
|
+
args[0] = -1
|
|
416
|
+
with pytest.raises(ValueError):
|
|
417
|
+
domain.subduction_travel_time(*args)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def test_subduction_travel_time_slab_speed_physical_bound():
|
|
421
|
+
args = [100, 2, 0.5235987755982988]
|
|
422
|
+
args[1] = 0
|
|
423
|
+
with pytest.raises(ValueError):
|
|
424
|
+
domain.subduction_travel_time(*args)
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
def test_subduction_travel_time_dip_physical_bound():
|
|
428
|
+
args = [100, 2, 0.5235987755982988]
|
|
429
|
+
args[2] = 2
|
|
430
|
+
with pytest.raises(ValueError):
|
|
431
|
+
domain.subduction_travel_time(*args)
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def test_slab_pull_force_broadcasting():
|
|
435
|
+
args = [100, 1000000000.0, 10]
|
|
436
|
+
reference = domain.slab_pull_force(*args)
|
|
437
|
+
args[0] = np.full((2, 1), args[0])
|
|
438
|
+
result = domain.slab_pull_force(*args)
|
|
439
|
+
assert result.shape == (2, 1)
|
|
440
|
+
np.testing.assert_allclose(result, reference)
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def test_slab_pull_force_density_excess_physical_bound():
|
|
444
|
+
args = [100, 1000000000.0, 10]
|
|
445
|
+
args[0] = -1
|
|
446
|
+
with pytest.raises(ValueError):
|
|
447
|
+
domain.slab_pull_force(*args)
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
def test_slab_pull_force_slab_volume_physical_bound():
|
|
451
|
+
args = [100, 1000000000.0, 10]
|
|
452
|
+
args[1] = -1
|
|
453
|
+
with pytest.raises(ValueError):
|
|
454
|
+
domain.slab_pull_force(*args)
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
def test_slab_pull_force_gravity_physical_bound():
|
|
458
|
+
args = [100, 1000000000.0, 10]
|
|
459
|
+
args[2] = 0
|
|
460
|
+
with pytest.raises(ValueError):
|
|
461
|
+
domain.slab_pull_force(*args)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
def test_airy_root_broadcasting():
|
|
465
|
+
args = [1000, 2700, 3300]
|
|
466
|
+
reference = domain.airy_root(*args)
|
|
467
|
+
args[0] = np.full((2, 1), args[0])
|
|
468
|
+
result = domain.airy_root(*args)
|
|
469
|
+
assert result.shape == (2, 1)
|
|
470
|
+
np.testing.assert_allclose(result, reference)
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
def test_airy_root_elevation_physical_bound():
|
|
474
|
+
args = [1000, 2700, 3300]
|
|
475
|
+
args[0] = -1
|
|
476
|
+
with pytest.raises(ValueError):
|
|
477
|
+
domain.airy_root(*args)
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def test_airy_root_crust_density_physical_bound():
|
|
481
|
+
args = [1000, 2700, 3300]
|
|
482
|
+
args[1] = 0
|
|
483
|
+
with pytest.raises(ValueError):
|
|
484
|
+
domain.airy_root(*args)
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def test_airy_root_mantle_density_physical_bound():
|
|
488
|
+
args = [1000, 2700, 3300]
|
|
489
|
+
args[2] = 0
|
|
490
|
+
with pytest.raises(ValueError):
|
|
491
|
+
domain.airy_root(*args)
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
def test_flexural_rigidity_broadcasting():
|
|
495
|
+
args = [12, 1, 0]
|
|
496
|
+
reference = domain.flexural_rigidity(*args)
|
|
497
|
+
args[0] = np.full((2, 1), args[0])
|
|
498
|
+
result = domain.flexural_rigidity(*args)
|
|
499
|
+
assert result.shape == (2, 1)
|
|
500
|
+
np.testing.assert_allclose(result, reference)
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def test_flexural_rigidity_young_modulus_physical_bound():
|
|
504
|
+
args = [12, 1, 0]
|
|
505
|
+
args[0] = 0
|
|
506
|
+
with pytest.raises(ValueError):
|
|
507
|
+
domain.flexural_rigidity(*args)
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
def test_flexural_rigidity_elastic_thickness_physical_bound():
|
|
511
|
+
args = [12, 1, 0]
|
|
512
|
+
args[1] = 0
|
|
513
|
+
with pytest.raises(ValueError):
|
|
514
|
+
domain.flexural_rigidity(*args)
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
def test_flexural_rigidity_poisson_ratio_physical_bound():
|
|
518
|
+
args = [12, 1, 0]
|
|
519
|
+
args[2] = 0.5
|
|
520
|
+
with pytest.raises(ValueError):
|
|
521
|
+
domain.flexural_rigidity(*args)
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
def test_flexural_parameter_broadcasting():
|
|
525
|
+
args = [4, 1, 1]
|
|
526
|
+
reference = domain.flexural_parameter(*args)
|
|
527
|
+
args[0] = np.full((2, 1), args[0])
|
|
528
|
+
result = domain.flexural_parameter(*args)
|
|
529
|
+
assert result.shape == (2, 1)
|
|
530
|
+
np.testing.assert_allclose(result, reference)
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
def test_flexural_parameter_rigidity_physical_bound():
|
|
534
|
+
args = [4, 1, 1]
|
|
535
|
+
args[0] = 0
|
|
536
|
+
with pytest.raises(ValueError):
|
|
537
|
+
domain.flexural_parameter(*args)
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def test_flexural_parameter_density_contrast_physical_bound():
|
|
541
|
+
args = [4, 1, 1]
|
|
542
|
+
args[1] = 0
|
|
543
|
+
with pytest.raises(ValueError):
|
|
544
|
+
domain.flexural_parameter(*args)
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def test_flexural_parameter_gravity_physical_bound():
|
|
548
|
+
args = [4, 1, 1]
|
|
549
|
+
args[2] = 0
|
|
550
|
+
with pytest.raises(ValueError):
|
|
551
|
+
domain.flexural_parameter(*args)
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
def test_halfspace_temperature_broadcasting():
|
|
555
|
+
args = [0, 1, 1, 300, 1300]
|
|
556
|
+
reference = domain.halfspace_temperature(*args)
|
|
557
|
+
args[0] = np.full((2, 1), args[0])
|
|
558
|
+
result = domain.halfspace_temperature(*args)
|
|
559
|
+
assert result.shape == (2, 1)
|
|
560
|
+
np.testing.assert_allclose(result, reference)
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
def test_halfspace_temperature_depth_physical_bound():
|
|
564
|
+
args = [0, 1, 1, 300, 1300]
|
|
565
|
+
args[0] = -1
|
|
566
|
+
with pytest.raises(ValueError):
|
|
567
|
+
domain.halfspace_temperature(*args)
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
def test_halfspace_temperature_age_physical_bound():
|
|
571
|
+
args = [0, 1, 1, 300, 1300]
|
|
572
|
+
args[1] = 0
|
|
573
|
+
with pytest.raises(ValueError):
|
|
574
|
+
domain.halfspace_temperature(*args)
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
def test_halfspace_temperature_diffusivity_physical_bound():
|
|
578
|
+
args = [0, 1, 1, 300, 1300]
|
|
579
|
+
args[2] = 0
|
|
580
|
+
with pytest.raises(ValueError):
|
|
581
|
+
domain.halfspace_temperature(*args)
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
def test_halfspace_temperature_surface_temperature_physical_bound():
|
|
585
|
+
args = [0, 1, 1, 300, 1300]
|
|
586
|
+
args[3] = 0
|
|
587
|
+
with pytest.raises(ValueError):
|
|
588
|
+
domain.halfspace_temperature(*args)
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
def test_halfspace_temperature_mantle_temperature_physical_bound():
|
|
592
|
+
args = [0, 1, 1, 300, 1300]
|
|
593
|
+
args[4] = 0
|
|
594
|
+
with pytest.raises(ValueError):
|
|
595
|
+
domain.halfspace_temperature(*args)
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def test_halfspace_heat_flux_broadcasting():
|
|
599
|
+
args = [1, 1, 1, 300, 1300]
|
|
600
|
+
reference = domain.halfspace_heat_flux(*args)
|
|
601
|
+
args[0] = np.full((2, 1), args[0])
|
|
602
|
+
result = domain.halfspace_heat_flux(*args)
|
|
603
|
+
assert result.shape == (2, 1)
|
|
604
|
+
np.testing.assert_allclose(result, reference)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def test_halfspace_heat_flux_age_physical_bound():
|
|
608
|
+
args = [1, 1, 1, 300, 1300]
|
|
609
|
+
args[0] = 0
|
|
610
|
+
with pytest.raises(ValueError):
|
|
611
|
+
domain.halfspace_heat_flux(*args)
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
def test_halfspace_heat_flux_diffusivity_physical_bound():
|
|
615
|
+
args = [1, 1, 1, 300, 1300]
|
|
616
|
+
args[1] = 0
|
|
617
|
+
with pytest.raises(ValueError):
|
|
618
|
+
domain.halfspace_heat_flux(*args)
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
def test_halfspace_heat_flux_conductivity_physical_bound():
|
|
622
|
+
args = [1, 1, 1, 300, 1300]
|
|
623
|
+
args[2] = 0
|
|
624
|
+
with pytest.raises(ValueError):
|
|
625
|
+
domain.halfspace_heat_flux(*args)
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
def test_halfspace_heat_flux_surface_temperature_physical_bound():
|
|
629
|
+
args = [1, 1, 1, 300, 1300]
|
|
630
|
+
args[3] = 0
|
|
631
|
+
with pytest.raises(ValueError):
|
|
632
|
+
domain.halfspace_heat_flux(*args)
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
def test_halfspace_heat_flux_mantle_temperature_physical_bound():
|
|
636
|
+
args = [1, 1, 1, 300, 1300]
|
|
637
|
+
args[4] = 0
|
|
638
|
+
with pytest.raises(ValueError):
|
|
639
|
+
domain.halfspace_heat_flux(*args)
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
def test_mantle_rayleigh_number_reference():
|
|
643
|
+
result = domain.mantle_rayleigh_number(*[1, 2, 3, 4, 5, 6, 7])
|
|
644
|
+
np.testing.assert_allclose(result, 3000 / 42, rtol=1e-11, atol=1e-12)
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
648
|
+
def test_mantle_rayleigh_number_rejects_invalid(bad):
|
|
649
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
650
|
+
args[0] = bad
|
|
651
|
+
with pytest.raises(ValueError):
|
|
652
|
+
domain.mantle_rayleigh_number(*args)
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
def test_mantle_rayleigh_number_broadcasting():
|
|
656
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
657
|
+
reference = domain.mantle_rayleigh_number(*args)
|
|
658
|
+
args[0] = np.full((2, 1), args[0])
|
|
659
|
+
result = domain.mantle_rayleigh_number(*args)
|
|
660
|
+
assert result.shape == (2, 1)
|
|
661
|
+
np.testing.assert_allclose(result, reference)
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
def test_mantle_rayleigh_number_thermal_expansivity_physical_bound():
|
|
665
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
666
|
+
args[0] = 0
|
|
667
|
+
with pytest.raises(ValueError):
|
|
668
|
+
domain.mantle_rayleigh_number(*args)
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
def test_mantle_rayleigh_number_density_physical_bound():
|
|
672
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
673
|
+
args[1] = 0
|
|
674
|
+
with pytest.raises(ValueError):
|
|
675
|
+
domain.mantle_rayleigh_number(*args)
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
def test_mantle_rayleigh_number_gravity_physical_bound():
|
|
679
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
680
|
+
args[2] = 0
|
|
681
|
+
with pytest.raises(ValueError):
|
|
682
|
+
domain.mantle_rayleigh_number(*args)
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
def test_mantle_rayleigh_number_temperature_difference_physical_bound():
|
|
686
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
687
|
+
args[3] = -1
|
|
688
|
+
with pytest.raises(ValueError):
|
|
689
|
+
domain.mantle_rayleigh_number(*args)
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
def test_mantle_rayleigh_number_thickness_physical_bound():
|
|
693
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
694
|
+
args[4] = 0
|
|
695
|
+
with pytest.raises(ValueError):
|
|
696
|
+
domain.mantle_rayleigh_number(*args)
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
def test_mantle_rayleigh_number_diffusivity_physical_bound():
|
|
700
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
701
|
+
args[5] = 0
|
|
702
|
+
with pytest.raises(ValueError):
|
|
703
|
+
domain.mantle_rayleigh_number(*args)
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
def test_mantle_rayleigh_number_viscosity_physical_bound():
|
|
707
|
+
args = [1, 2, 3, 4, 5, 6, 7]
|
|
708
|
+
args[6] = 0
|
|
709
|
+
with pytest.raises(ValueError):
|
|
710
|
+
domain.mantle_rayleigh_number(*args)
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
def test_flexural_deflection_reference():
|
|
714
|
+
result = domain.flexural_deflection(*[0, 8, 1, 4, 1])
|
|
715
|
+
np.testing.assert_allclose(result, 1, rtol=1e-11, atol=1e-12)
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
719
|
+
def test_flexural_deflection_rejects_invalid(bad):
|
|
720
|
+
args = [0, 8, 1, 4, 1]
|
|
721
|
+
args[0] = bad
|
|
722
|
+
with pytest.raises(ValueError):
|
|
723
|
+
domain.flexural_deflection(*args)
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
def test_flexural_deflection_broadcasting():
|
|
727
|
+
args = [0, 8, 1, 4, 1]
|
|
728
|
+
reference = domain.flexural_deflection(*args)
|
|
729
|
+
args[0] = np.full((2, 1), args[0])
|
|
730
|
+
result = domain.flexural_deflection(*args)
|
|
731
|
+
assert result.shape == (2, 1)
|
|
732
|
+
np.testing.assert_allclose(result, reference)
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
def test_flexural_deflection_line_load_physical_bound():
|
|
736
|
+
args = [0, 8, 1, 4, 1]
|
|
737
|
+
args[1] = -1
|
|
738
|
+
with pytest.raises(ValueError):
|
|
739
|
+
domain.flexural_deflection(*args)
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
def test_flexural_deflection_rigidity_physical_bound():
|
|
743
|
+
args = [0, 8, 1, 4, 1]
|
|
744
|
+
args[2] = 0
|
|
745
|
+
with pytest.raises(ValueError):
|
|
746
|
+
domain.flexural_deflection(*args)
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
def test_flexural_deflection_density_contrast_physical_bound():
|
|
750
|
+
args = [0, 8, 1, 4, 1]
|
|
751
|
+
args[3] = 0
|
|
752
|
+
with pytest.raises(ValueError):
|
|
753
|
+
domain.flexural_deflection(*args)
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
def test_flexural_deflection_gravity_physical_bound():
|
|
757
|
+
args = [0, 8, 1, 4, 1]
|
|
758
|
+
args[4] = 0
|
|
759
|
+
with pytest.raises(ValueError):
|
|
760
|
+
domain.flexural_deflection(*args)
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
def test_hotspot_age_reference():
|
|
764
|
+
result = domain.hotspot_age(*[6, 1, 2, 1.5707963267948966])
|
|
765
|
+
np.testing.assert_allclose(result, 3, rtol=1e-11, atol=1e-12)
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
769
|
+
def test_hotspot_age_rejects_invalid(bad):
|
|
770
|
+
args = [6, 1, 2, 1.5707963267948966]
|
|
771
|
+
args[0] = bad
|
|
772
|
+
with pytest.raises(ValueError):
|
|
773
|
+
domain.hotspot_age(*args)
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
def test_hotspot_age_broadcasting():
|
|
777
|
+
args = [6, 1, 2, 1.5707963267948966]
|
|
778
|
+
reference = domain.hotspot_age(*args)
|
|
779
|
+
args[0] = np.full((2, 1), args[0])
|
|
780
|
+
result = domain.hotspot_age(*args)
|
|
781
|
+
assert result.shape == (2, 1)
|
|
782
|
+
np.testing.assert_allclose(result, reference)
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
def test_hotspot_age_track_length_physical_bound():
|
|
786
|
+
args = [6, 1, 2, 1.5707963267948966]
|
|
787
|
+
args[0] = -1
|
|
788
|
+
with pytest.raises(ValueError):
|
|
789
|
+
domain.hotspot_age(*args)
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
def test_hotspot_age_angular_speed_physical_bound():
|
|
793
|
+
args = [6, 1, 2, 1.5707963267948966]
|
|
794
|
+
args[1] = 0
|
|
795
|
+
with pytest.raises(ValueError):
|
|
796
|
+
domain.hotspot_age(*args)
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
def test_hotspot_age_radius_physical_bound():
|
|
800
|
+
args = [6, 1, 2, 1.5707963267948966]
|
|
801
|
+
args[2] = 0
|
|
802
|
+
with pytest.raises(ValueError):
|
|
803
|
+
domain.hotspot_age(*args)
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
def test_hotspot_age_pole_distance_physical_bound():
|
|
807
|
+
args = [6, 1, 2, 1.5707963267948966]
|
|
808
|
+
args[3] = 0
|
|
809
|
+
with pytest.raises(ValueError):
|
|
810
|
+
domain.hotspot_age(*args)
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
def test_ocean_depth_reference():
|
|
814
|
+
result = domain.ocean_depth(*[0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300])
|
|
815
|
+
np.testing.assert_allclose(result, 3500, rtol=1e-11, atol=1e-12)
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
819
|
+
def test_ocean_depth_rejects_invalid(bad):
|
|
820
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
821
|
+
args[0] = bad
|
|
822
|
+
with pytest.raises(ValueError):
|
|
823
|
+
domain.ocean_depth(*args)
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
def test_ocean_depth_broadcasting():
|
|
827
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
828
|
+
reference = domain.ocean_depth(*args)
|
|
829
|
+
args[0] = np.full((2, 1), args[0])
|
|
830
|
+
result = domain.ocean_depth(*args)
|
|
831
|
+
assert result.shape == (2, 1)
|
|
832
|
+
np.testing.assert_allclose(result, reference)
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
def test_ocean_depth_age_physical_bound():
|
|
836
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
837
|
+
args[0] = -1
|
|
838
|
+
with pytest.raises(ValueError):
|
|
839
|
+
domain.ocean_depth(*args)
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
def test_ocean_depth_ridge_depth_physical_bound():
|
|
843
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
844
|
+
args[1] = -1
|
|
845
|
+
with pytest.raises(ValueError):
|
|
846
|
+
domain.ocean_depth(*args)
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
def test_ocean_depth_mantle_density_physical_bound():
|
|
850
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
851
|
+
args[2] = 0
|
|
852
|
+
with pytest.raises(ValueError):
|
|
853
|
+
domain.ocean_depth(*args)
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
def test_ocean_depth_water_density_physical_bound():
|
|
857
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
858
|
+
args[3] = 0
|
|
859
|
+
with pytest.raises(ValueError):
|
|
860
|
+
domain.ocean_depth(*args)
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
def test_ocean_depth_thermal_expansivity_physical_bound():
|
|
864
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
865
|
+
args[4] = 0
|
|
866
|
+
with pytest.raises(ValueError):
|
|
867
|
+
domain.ocean_depth(*args)
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
def test_ocean_depth_diffusivity_physical_bound():
|
|
871
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
872
|
+
args[5] = 0
|
|
873
|
+
with pytest.raises(ValueError):
|
|
874
|
+
domain.ocean_depth(*args)
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
def test_ocean_depth_surface_temperature_physical_bound():
|
|
878
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
879
|
+
args[6] = 0
|
|
880
|
+
with pytest.raises(ValueError):
|
|
881
|
+
domain.ocean_depth(*args)
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
def test_ocean_depth_mantle_temperature_physical_bound():
|
|
885
|
+
args = [0.25 * np.pi, 2500, 2, 1, 0.5, 1, 300, 1300]
|
|
886
|
+
args[7] = 0
|
|
887
|
+
with pytest.raises(ValueError):
|
|
888
|
+
domain.ocean_depth(*args)
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
def test_hotspot_age_pole_distance_upper_bound():
|
|
892
|
+
with pytest.raises(ValueError):
|
|
893
|
+
domain.hotspot_age(6, 1, 2, np.pi)
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
def test_compose_euler_vectors_reference():
|
|
897
|
+
result = domain.compose_euler_vectors(*[[1, 2, 3], [4, -5, 6]])
|
|
898
|
+
np.testing.assert_allclose(result, [5, -3, 9], rtol=1e-11, atol=1e-12)
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
902
|
+
def test_compose_euler_vectors_rejects_invalid(bad):
|
|
903
|
+
args = [[1, 2, 3], [4, -5, 6]]
|
|
904
|
+
args[0] = bad
|
|
905
|
+
with pytest.raises(ValueError):
|
|
906
|
+
domain.compose_euler_vectors(*args)
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
def test_compose_euler_vectors_broadcasting():
|
|
910
|
+
result = domain.compose_euler_vectors(np.full((2, 3), 1.0), [4, -5, 6])
|
|
911
|
+
assert result.shape == (2, 3)
|
|
912
|
+
np.testing.assert_allclose(result, [[5, -4, 7]] * 2)
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
@pytest.mark.parametrize("shape", [(2,), (3, 2)])
|
|
916
|
+
def test_compose_euler_vectors_requires_three_components(shape):
|
|
917
|
+
with pytest.raises(ValueError):
|
|
918
|
+
domain.compose_euler_vectors(np.ones(shape), [1, 2, 3])
|
|
919
|
+
with pytest.raises(ValueError):
|
|
920
|
+
domain.compose_euler_vectors([1, 2, 3], np.ones(shape))
|