Skip to content

Commit 866b6f6

Browse files
author
Lachlan Grose
committed
formatting tests
1 parent 7efe910 commit 866b6f6

File tree

11 files changed

+334
-241
lines changed

11 files changed

+334
-241
lines changed

tests/integration/test_fold_models.py

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,63 @@
55

66
data, boundary_points = load_noddy_single_fold()
77
data.head()
8+
9+
810
def test_average_fold_axis():
9-
mdata = pd.concat([data[:100],data[data['feature_name']=='s1']])
10-
model = GeologicalModel(boundary_points[0,:],boundary_points[1,:])
11+
mdata = pd.concat([data[:100], data[data["feature_name"] == "s1"]])
12+
model = GeologicalModel(boundary_points[0, :], boundary_points[1, :])
1113
model.set_model_data(mdata)
12-
fold_frame = model.create_and_add_fold_frame('s1',nelements=10000)
13-
stratigraphy = model.create_and_add_folded_foliation('s0',
14-
fold_frame,
15-
nelements=10000,
16-
av_fold_axis=True
17-
# fold_axis=[-6.51626577e-06, -5.00013645e-01, -8.66017526e-01],
18-
# limb_wl=1
19-
)
14+
fold_frame = model.create_and_add_fold_frame("s1", nelements=10000)
15+
stratigraphy = model.create_and_add_folded_foliation(
16+
"s0",
17+
fold_frame,
18+
nelements=10000,
19+
av_fold_axis=True
20+
# fold_axis=[-6.51626577e-06, -5.00013645e-01, -8.66017526e-01],
21+
# limb_wl=1
22+
)
23+
24+
2025
def test_fixed_fold_axis():
21-
mdata = pd.concat([data[:100],data[data['feature_name']=='s1']])
22-
model = GeologicalModel(boundary_points[0,:],boundary_points[1,:])
26+
mdata = pd.concat([data[:100], data[data["feature_name"] == "s1"]])
27+
model = GeologicalModel(boundary_points[0, :], boundary_points[1, :])
2328
model.set_model_data(mdata)
24-
fold_frame = model.create_and_add_fold_frame('s1',nelements=10000)
25-
stratigraphy = model.create_and_add_folded_foliation('s0',
26-
fold_frame,
27-
nelements=10000,
28-
# av_fold_axis=True
29-
fold_axis=[-6.51626577e-06, -5.00013645e-01, -8.66017526e-01],
30-
# limb_wl=1
31-
)
29+
fold_frame = model.create_and_add_fold_frame("s1", nelements=10000)
30+
stratigraphy = model.create_and_add_folded_foliation(
31+
"s0",
32+
fold_frame,
33+
nelements=10000,
34+
# av_fold_axis=True
35+
fold_axis=[-6.51626577e-06, -5.00013645e-01, -8.66017526e-01],
36+
# limb_wl=1
37+
)
38+
3239

3340
def test_fixed_wavelength():
34-
mdata = pd.concat([data[:100],data[data['feature_name']=='s1']])
35-
model = GeologicalModel(boundary_points[0,:],boundary_points[1,:])
41+
mdata = pd.concat([data[:100], data[data["feature_name"] == "s1"]])
42+
model = GeologicalModel(boundary_points[0, :], boundary_points[1, :])
3643
model.set_model_data(mdata)
37-
fold_frame = model.create_and_add_fold_frame('s1',nelements=10000)
38-
stratigraphy = model.create_and_add_folded_foliation('s0',
39-
fold_frame,
40-
nelements=10000,
41-
# av_fold_axis=True
42-
fold_axis=[-6.51626577e-06, -5.00013645e-01, -8.66017526e-01],
43-
limb_wl=1
44-
)
44+
fold_frame = model.create_and_add_fold_frame("s1", nelements=10000)
45+
stratigraphy = model.create_and_add_folded_foliation(
46+
"s0",
47+
fold_frame,
48+
nelements=10000,
49+
# av_fold_axis=True
50+
fold_axis=[-6.51626577e-06, -5.00013645e-01, -8.66017526e-01],
51+
limb_wl=1,
52+
)
53+
4554

4655
def test_no_fold_frame():
47-
mdata = pd.concat([data[:100],data[data['feature_name']=='s1']])
48-
model = GeologicalModel(boundary_points[0,:],boundary_points[1,:])
56+
mdata = pd.concat([data[:100], data[data["feature_name"] == "s1"]])
57+
model = GeologicalModel(boundary_points[0, :], boundary_points[1, :])
4958
model.set_model_data(mdata)
50-
fold_frame = model.create_and_add_fold_frame('s1',nelements=10000)
51-
stratigraphy = model.create_and_add_folded_foliation('s0',
52-
# fold_frame,
53-
nelements=10000,
54-
# av_fold_axis=True
55-
fold_axis=[-6.51626577e-06, -5.00013645e-01, -8.66017526e-01],
56-
limb_wl=1
57-
)
59+
fold_frame = model.create_and_add_fold_frame("s1", nelements=10000)
60+
stratigraphy = model.create_and_add_folded_foliation(
61+
"s0",
62+
# fold_frame,
63+
nelements=10000,
64+
# av_fold_axis=True
65+
fold_axis=[-6.51626577e-06, -5.00013645e-01, -8.66017526e-01],
66+
limb_wl=1,
67+
)
Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,80 @@
11
from LoopStructural import GeologicalModel
22
from LoopStructural.datasets import load_claudius
33

4+
45
def test_create_model():
56
data, bb = load_claudius()
6-
model = GeologicalModel(bb[0,:],bb[1,:])
7+
model = GeologicalModel(bb[0, :], bb[1, :])
8+
79

810
def test_add_data():
911
data, bb = load_claudius()
10-
model = GeologicalModel(bb[0,:],bb[1,:])
12+
model = GeologicalModel(bb[0, :], bb[1, :])
1113
model.set_model_data(data)
1214

15+
1316
def test_create_stratigraphy_FDI_cg():
1417
data, bb = load_claudius()
1518
model = GeologicalModel(bb[0, :], bb[1, :])
1619
model.set_model_data(data)
17-
s0 = model.create_and_add_foliation('s0',
18-
interpolatortype='FDI',
19-
nelements=1000,
20-
solver='cg',
21-
damp=False)
20+
s0 = model.create_and_add_foliation(
21+
"s0", interpolatortype="FDI", nelements=1000, solver="cg", damp=False
22+
)
2223

2324

2425
def test_remove_constraints_PLI():
2526
data, bb = load_claudius()
2627
model = GeologicalModel(bb[0, :], bb[1, :])
2728
model.set_model_data(data)
28-
s0 = model.create_and_add_foliation('s0',
29-
interpolatortype='FDI',
30-
nelements=1000,
31-
solver='cg',
32-
damp=False)
29+
s0 = model.create_and_add_foliation(
30+
"s0", interpolatortype="FDI", nelements=1000, solver="cg", damp=False
31+
)
32+
3333

3434
def test_create_stratigraphy_FDI_lu():
3535
data, bb = load_claudius()
3636
model = GeologicalModel(bb[0, :], bb[1, :])
3737
model.set_model_data(data)
38-
s0 = model.create_and_add_foliation('s0',
39-
interpolatortype='FDI',
40-
nelements=1000,
41-
solver='lu',
42-
damp=True)
38+
s0 = model.create_and_add_foliation(
39+
"s0", interpolatortype="FDI", nelements=1000, solver="lu", damp=True
40+
)
4341

4442

4543
def test_create_stratigraphy_FDI_pyamg():
4644
data, bb = load_claudius()
4745
model = GeologicalModel(bb[0, :], bb[1, :])
4846
model.set_model_data(data)
49-
s0 = model.create_and_add_foliation('s0',
50-
interpolatortype='FDI',
51-
nelements=1000,
52-
solver='pyamg',
53-
damp=True)
47+
s0 = model.create_and_add_foliation(
48+
"s0", interpolatortype="FDI", nelements=1000, solver="pyamg", damp=True
49+
)
50+
5451

5552
def test_create_stratigraphy_PLI_cg():
5653
data, bb = load_claudius()
5754
model = GeologicalModel(bb[0, :], bb[1, :])
5855
model.set_model_data(data)
59-
s0 = model.create_and_add_foliation('s0',
60-
interpolatortype='PLI',
61-
nelements=1000,
62-
solver='cg',
63-
damp=False)
56+
s0 = model.create_and_add_foliation(
57+
"s0", interpolatortype="PLI", nelements=1000, solver="cg", damp=False
58+
)
59+
6460

6561
def test_create_stratigraphy_PLI_lu():
6662
data, bb = load_claudius()
6763
model = GeologicalModel(bb[0, :], bb[1, :])
6864
model.set_model_data(data)
69-
s0 = model.create_and_add_foliation('s0',
70-
interpolatortype='PLI',
71-
nelements=1000,
72-
solver='lu',
73-
damp=True)
65+
s0 = model.create_and_add_foliation(
66+
"s0", interpolatortype="PLI", nelements=1000, solver="lu", damp=True
67+
)
7468

7569

7670
def test_create_stratigraphy_PLI_pyamg():
7771
data, bb = load_claudius()
7872
model = GeologicalModel(bb[0, :], bb[1, :])
7973
model.set_model_data(data)
80-
s0 = model.create_and_add_foliation('s0',
81-
interpolatortype='PLI',
82-
nelements=1000,
83-
solver='pyamg',
84-
damp=True)
74+
s0 = model.create_and_add_foliation(
75+
"s0", interpolatortype="PLI", nelements=1000, solver="pyamg", damp=True
76+
)
77+
8578

8679
def test_model_with_data_outside_of_bounding_box():
8780
pass
88-

tests/integration/test_refolded.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
from LoopStructural import GeologicalModel
22
from LoopStructural.datasets import load_laurent2016
33

4+
45
def average_axis():
56
data, bb = load_laurent2016()
67

7-
model = GeologicalModel(bb[0,:],bb[1,:])
8+
model = GeologicalModel(bb[0, :], bb[1, :])
89
model.set_model_data(data)
9-
s2 = model.create_and_add_fold_frame('s2',
10-
nelements=10000)
10+
s2 = model.create_and_add_fold_frame("s2", nelements=10000)
1111

12-
s1 = model.create_and_add_folded_fold_frame('s1',
13-
limb_wl=.4,
14-
av_fold_axis=True,
15-
nelements=50000
16-
)
12+
s1 = model.create_and_add_folded_fold_frame(
13+
"s1", limb_wl=0.4, av_fold_axis=True, nelements=50000
14+
)
1715

18-
s0 = model.create_and_add_folded_fold_frame('s0',
19-
limb_wl=1.,
20-
av_fold_axis=True,
21-
nelements=50000
22-
)
16+
s0 = model.create_and_add_folded_fold_frame(
17+
"s0", limb_wl=1.0, av_fold_axis=True, nelements=50000
18+
)

tests/unit_tests/input/test_data_processor.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import pandas as pd
33
import numpy as np
44

5+
56
def test_create_processor():
6-
df = pd.DataFrame(np.random.rand(10,3),columns=['X','Y','Z'])
7-
df['name'] = ['unit_{}'.format(name%2) for name in range(10)]
8-
stratigraphic_order = [('sg',['unit_0','unit_1'])]
9-
thicknesses = {'unit_0':1.,'unit_1':0.5}
10-
processor = ProcessInputData(contacts=df,stratigraphic_order=stratigraphic_order,thicknesses=thicknesses)
11-
assert((processor.data['val'].unique() == np.array([0.5,0])).all())
12-
7+
df = pd.DataFrame(np.random.rand(10, 3), columns=["X", "Y", "Z"])
8+
df["name"] = ["unit_{}".format(name % 2) for name in range(10)]
9+
stratigraphic_order = [("sg", ["unit_0", "unit_1"])]
10+
thicknesses = {"unit_0": 1.0, "unit_1": 0.5}
11+
processor = ProcessInputData(
12+
contacts=df, stratigraphic_order=stratigraphic_order, thicknesses=thicknesses
13+
)
14+
assert (processor.data["val"].unique() == np.array([0.5, 0])).all()

0 commit comments

Comments
 (0)