Skip to content

Commit a80a7f1

Browse files
sotorrio1ksbeattielbianchi-lbl
authored
Adding more tests to SDoE (#1225)
* Tweaking test_plot_utils and test_sdoe. Adding test_df_utils * clean up imports --------- Co-authored-by: Keith Beattie <ksbeattie@lbl.gov> Co-authored-by: Ludovico Bianchi <lbianchi@lbl.gov>
1 parent 70f62e2 commit a80a7f1

8 files changed

Lines changed: 364 additions & 6 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
__id,w,G,lldg,L
2+
0,0.125,1000,0.1,3495
3+
1,0.125,1000,0.15,3302
4+
2,0.125,1000,0.2,3110
5+
3,0.125,1000,0.2,3035
6+
4,0.125,1000,0.25,3496
7+
5,0.125,1000,0.25,4075
8+
6,0.125,1000,0.25,4654
9+
7,0.125,1000,0.3,3957
10+
8,0.125,1000,0.3,5190
11+
9,0.125,1000,0.3,6423
12+
10,0.125,1500,0.1,3257
13+
11,0.125,1500,0.15,3284
14+
12,0.125,1500,0.15,3408
15+
13,0.125,1500,0.15,3532
16+
14,0.125,1500,0.15,3656
17+
15,0.125,1500,0.2,3310
18+
16,0.125,1500,0.2,3955
19+
17,0.125,1500,0.2,4601
20+
18,0.125,1500,0.2,5247
21+
19,0.125,1500,0.25,3336
22+
20,0.125,1500,0.25,4503
23+
21,0.125,1500,0.25,5670
24+
22,0.125,1500,0.25,6838
25+
23,0.125,1500,0.3,3362
26+
24,0.125,1500,0.3,5051
27+
25,0.125,1500,0.3,6740
28+
26,0.125,1500,0.3,8429
29+
27,0.125,2000,0.1,3020
30+
28,0.125,2000,0.1,3607
31+
29,0.125,2000,0.1,4194
32+
30,0.125,2000,0.1,4781
33+
31,0.125,2000,0.15,3265
34+
32,0.125,2000,0.15,4241
35+
33,0.125,2000,0.15,5218
36+
34,0.125,2000,0.15,6194
37+
35,0.125,2000,0.2,3510
38+
36,0.125,2000,0.2,4876
39+
37,0.125,2000,0.2,6242
40+
38,0.125,2000,0.2,7608
41+
39,0.125,2000,0.25,3755
42+
40,0.125,2000,0.25,5510
43+
41,0.125,2000,0.25,7266
44+
42,0.125,2000,0.25,9021
45+
43,0.125,2000,0.3,4000
46+
44,0.125,2000,0.3,6145
47+
45,0.125,2000,0.3,8290
48+
46,0.125,2000,0.3,10435
49+
47,0.125,2500,0.1,4354
50+
48,0.125,2500,0.1,5926
51+
49,0.125,2500,0.1,7498
52+
50,0.125,2500,0.15,3246
53+
51,0.125,2500,0.15,5075
54+
52,0.125,2500,0.15,6904
55+
53,0.125,2500,0.15,8733
56+
54,0.125,2500,0.2,3709
57+
55,0.125,2500,0.2,5796
58+
56,0.125,2500,0.2,7883
59+
57,0.125,2500,0.2,9969
60+
58,0.125,2500,0.25,4173
61+
59,0.125,2500,0.25,6517
62+
60,0.125,2500,0.25,8861
63+
61,0.125,2500,0.25,11205
64+
62,0.125,2500,0.3,4637
65+
63,0.125,2500,0.3,7238
66+
64,0.125,2500,0.3,9839
67+
65,0.125,2700,0.1,4653
68+
66,0.125,2700,0.1,6618
69+
67,0.125,2700,0.1,8584
70+
68,0.125,2700,0.15,3238
71+
69,0.125,2700,0.15,5408
72+
70,0.125,2700,0.15,7579
73+
71,0.125,2700,0.15,9749
74+
72,0.125,2700,0.2,3789
75+
73,0.125,2700,0.2,6164
76+
74,0.125,2700,0.2,8539
77+
75,0.125,2700,0.2,10914
78+
76,0.125,2700,0.25,4341
79+
77,0.125,2700,0.25,6920
80+
78,0.125,2700,0.25,9499
81+
79,0.125,2700,0.3,4892
82+
80,0.125,2700,0.3,7676
83+
81,0.125,2700,0.3,10459
84+
82,0.15,1000,0.2,3072
85+
83,0.15,1000,0.2,3219
86+
84,0.15,1000,0.2,3367
87+
85,0.15,1000,0.25,3621
88+
86,0.15,1000,0.25,4320
89+
87,0.15,1000,0.25,5019
90+
88,0.15,1000,0.3,4171
91+
89,0.15,1000,0.3,5421
92+
90,0.15,1000,0.3,6672
93+
91,0.15,1500,0.15,3100
94+
92,0.15,1500,0.15,3454
95+
93,0.15,1500,0.15,3809
96+
94,0.15,1500,0.15,4163
97+
95,0.15,1500,0.2,3317
98+
96,0.15,1500,0.2,4090
99+
97,0.15,1500,0.2,4864
100+
98,0.15,1500,0.2,5638
101+
99,0.15,1500,0.25,3534
102+
100,0.15,1500,0.25,4727
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
__id,w,G,lldg,L
2+
101,0.15,1500,0.25,5920
3+
102,0.15,1500,0.25,7113
4+
103,0.15,1500,0.3,3751
5+
104,0.15,1500,0.3,5363
6+
105,0.15,1500,0.3,6975
7+
106,0.15,1500,0.3,8587
8+
107,0.15,2000,0.1,3664
9+
108,0.15,2000,0.1,4489
10+
109,0.15,2000,0.1,5314
11+
110,0.15,2000,0.15,3274
12+
111,0.15,2000,0.15,4386
13+
112,0.15,2000,0.15,5499
14+
113,0.15,2000,0.15,6611
15+
114,0.15,2000,0.2,3710
16+
115,0.15,2000,0.2,5109
17+
116,0.15,2000,0.2,6509
18+
117,0.15,2000,0.2,7908
19+
118,0.15,2000,0.25,4145
20+
119,0.15,2000,0.25,5832
21+
120,0.15,2000,0.25,7519
22+
121,0.15,2000,0.25,9206
23+
122,0.15,2000,0.3,4581
24+
123,0.15,2000,0.3,6555
25+
124,0.15,2000,0.3,8529
26+
125,0.15,2000,0.3,10503
27+
126,0.15,2500,0.1,4509
28+
127,0.15,2500,0.1,6225
29+
128,0.15,2500,0.1,7940
30+
129,0.15,2500,0.15,3448
31+
130,0.15,2500,0.15,5318
32+
131,0.15,2500,0.15,7189
33+
132,0.15,2500,0.15,9060
34+
133,0.15,2500,0.2,4102
35+
134,0.15,2500,0.2,6128
36+
135,0.15,2500,0.2,8154
37+
136,0.15,2500,0.2,10179
38+
137,0.15,2500,0.25,4757
39+
138,0.15,2500,0.25,6937
40+
139,0.15,2500,0.25,9118
41+
140,0.15,2500,0.25,11299
42+
141,0.15,2500,0.3,5411
43+
142,0.15,2500,0.3,7747
44+
143,0.15,2500,0.3,10082
45+
144,0.15,2700,0.1,4847
46+
145,0.15,2700,0.1,6919
47+
146,0.15,2700,0.1,8990
48+
147,0.15,2700,0.15,3518
49+
148,0.15,2700,0.15,5691
50+
149,0.15,2700,0.15,7865
51+
150,0.15,2700,0.15,10039
52+
151,0.15,2700,0.2,4259
53+
152,0.15,2700,0.2,6535
54+
153,0.15,2700,0.2,8811
55+
154,0.15,2700,0.2,11087
56+
155,0.15,2700,0.25,5001
57+
156,0.15,2700,0.25,7379
58+
157,0.15,2700,0.25,9758
59+
158,0.15,2700,0.3,5743
60+
159,0.15,2700,0.3,8224
61+
160,0.15,2700,0.3,10704
62+
161,0.175,1000,0.2,3108
63+
162,0.175,1000,0.2,3479
64+
163,0.175,1000,0.2,3849
65+
164,0.175,1000,0.25,3746
66+
165,0.175,1000,0.25,4566
67+
166,0.175,1000,0.25,5385
68+
167,0.175,1000,0.3,3116
69+
168,0.175,1000,0.3,4384
70+
169,0.175,1000,0.3,5653
71+
170,0.175,1000,0.3,6921
72+
171,0.175,1500,0.1,3044
73+
172,0.175,1500,0.1,3312
74+
173,0.175,1500,0.15,3501
75+
174,0.175,1500,0.15,4086
76+
175,0.175,1500,0.15,4670
77+
176,0.175,1500,0.2,3324
78+
177,0.175,1500,0.2,4226
79+
178,0.175,1500,0.2,5127
80+
179,0.175,1500,0.2,6029
81+
180,0.175,1500,0.25,3731
82+
181,0.175,1500,0.25,4950
83+
182,0.175,1500,0.25,6169
84+
183,0.175,1500,0.25,7387
85+
184,0.175,1500,0.3,4139
86+
185,0.175,1500,0.3,5675
87+
186,0.175,1500,0.3,7210
88+
187,0.175,1500,0.3,8746
89+
188,0.175,2000,0.1,3720
90+
189,0.175,2000,0.1,4784
91+
190,0.175,2000,0.1,5847
92+
191,0.175,2000,0.15,3283
93+
192,0.175,2000,0.15,4532
94+
193,0.175,2000,0.15,5780
95+
194,0.175,2000,0.15,7028
96+
195,0.175,2000,0.2,3910
97+
196,0.175,2000,0.2,5343
98+
197,0.175,2000,0.2,6776
99+
198,0.175,2000,0.2,8209
100+
199,0.175,2000,0.25,4536
101+
200,0.175,2000,0.25,6154
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__id,w,G,lldg,L
2+
201,0.175,2000,0.25,7772
3+
202,0.175,2000,0.25,9390
4+
203,0.175,2000,0.3,5162
5+
204,0.175,2000,0.3,6965
6+
205,0.175,2000,0.3,8768
7+
206,0.175,2000,0.3,10571
8+
207,0.175,2500,0.1,4664
9+
208,0.175,2500,0.1,6523
10+
209,0.175,2500,0.1,8382
11+
210,0.175,2500,0.15,3650
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__id,w,G,lldg,L
2+
211,0.175,2500,0.15,5562
3+
212,0.175,2500,0.15,7474
4+
213,0.175,2500,0.15,9386
5+
214,0.175,2500,0.2,4495
6+
215,0.175,2500,0.2,6460
7+
216,0.175,2500,0.2,8424
8+
217,0.175,2500,0.2,10389
9+
218,0.175,2500,0.25,5340
10+
219,0.175,2500,0.25,7358
11+
220,0.175,2500,0.25,9375
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__id,w,G,lldg,L
2+
990,0.125,1500,0.2,5247
3+
991,0.125,2000,0.2,6242
4+
992,0.125,2500,0.2,9969
5+
993,0.125,2700,0.1,8584
6+
994,0.125,2700,0.25,6920
7+
995,0.15,1000,0.25,5019
8+
996,0.15,1500,0.2,4864
9+
997,0.15,2000,0.15,6611
10+
998,0.15,2500,0.25,9118
11+
999,0.175,2700,0.25,10016
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#################################################################################
2+
# FOQUS Copyright (c) 2012 - 2024, by the software owners: Oak Ridge Institute
3+
# for Science and Education (ORISE), TRIAD National Security, LLC., Lawrence
4+
# Livermore National Security, LLC., The Regents of the University of
5+
# California, through Lawrence Berkeley National Laboratory, Battelle Memorial
6+
# Institute, Pacific Northwest Division through Pacific Northwest National
7+
# Laboratory, Carnegie Mellon University, West Virginia University, Boston
8+
# University, the Trustees of Princeton University, The University of Texas at
9+
# Austin, URS Energy & Construction, Inc., et al. All rights reserved.
10+
#
11+
# Please see the file LICENSE.md for full copyright and license information,
12+
# respectively. This file is also available online at the URL
13+
# "https://github.com/CCSI-Toolset/FOQUS".
14+
#################################################################################
15+
from importlib import resources
16+
from pathlib import Path
17+
18+
import pandas as pd
19+
20+
from foqus_lib.framework.sdoe.df_utils import write, load, merge, check
21+
22+
23+
def test_write():
24+
fname = "test_data.csv"
25+
df = pd.DataFrame([(1, 1), (2, 2), (3, 3), (4, 4)])
26+
27+
write(fname, df)
28+
29+
obj = Path(fname)
30+
31+
test_results = obj.exists()
32+
33+
# Clean up
34+
obj.unlink()
35+
36+
assert test_results
37+
38+
39+
def test_load():
40+
fname = "candidates_usf.csv"
41+
copy_from_package(fname)
42+
43+
df = load(fname)
44+
45+
assert df is not None
46+
47+
48+
def test_merge():
49+
fnames = ["candidates_usf.csv", "previous_data.csv"]
50+
for fname in fnames:
51+
copy_from_package(fname)
52+
53+
df = merge(fnames)
54+
55+
assert df is not None
56+
57+
58+
def test_check():
59+
cfiles = ["cand1.csv", "cand2.csv"]
60+
hfiles = ["prev1.csv", "prev2.csv"]
61+
62+
for cfile in cfiles:
63+
copy_from_package(cfile)
64+
65+
for hfile in hfiles:
66+
copy_from_package(hfile)
67+
68+
cand_df, hist_df = check(cfiles, hfiles)
69+
70+
assert cand_df is not None
71+
assert hist_df is not None
72+
73+
74+
def copy_from_package(file_name: str) -> None:
75+
content = resources.read_text(__package__, file_name)
76+
Path(file_name).write_text(content)

foqus_lib/framework/sdoe/test/test_plot_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
from pathlib import Path
1919
from unittest import mock
2020

21-
import matplotlib.pyplot as plt
2221
import pandas as pd
23-
import pytest
2422

25-
from foqus_lib.framework.sdoe import df_utils, nusf, plot_utils, sdoe
23+
from foqus_lib.framework.sdoe import df_utils, nusf, plot_utils
2624

2725

2826
@mock.patch("foqus_lib.framework.sdoe.plot_utils.plt")

0 commit comments

Comments
 (0)