Skip to content

Commit 0bb7bd5

Browse files
committed
Fixed Python compatibility issues in UnitTests.py and in geobb_srf.py
1 parent ee7f56c commit 0bb7bd5

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

bbp/comps/geobb_srf.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
BSD 3-Clause License
44
5-
Copyright (c) 2023, University of Southern California
5+
Copyright (c) 2026, University of Southern California
66
All rights reserved.
77
88
Redistribution and use in source and binary forms, with or without
@@ -376,7 +376,7 @@ def write_xyz_srf(self, srf_file, xyz_srf_file, T3M):
376376
lon = float(tokens[0])
377377
lat = float(tokens[1])
378378
[x_cart, y_cart] = self.geo2cart(lon, lat, self.min_lon, self.min_lat)
379-
tmp = T3M * np.mat([x_cart, y_cart, 0, 1]).transpose()
379+
tmp = T3M * np.asmatrix([x_cart, y_cart, 0, 1]).transpose()
380380
tokens[0] = str(float(tmp[0]))
381381
tokens[1] = str(float(tmp[1]))
382382
outfile.write(" %s\n" % " ".join(tokens))
@@ -411,7 +411,7 @@ def write_xyz_srf(self, srf_file, xyz_srf_file, T3M):
411411
lat = float(tokens[1])
412412
[x_cart, y_cart] = self.geo2cart(lon, lat,
413413
self.min_lon, self.min_lat)
414-
tmp = T3M * np.mat([x_cart, y_cart, 0, 1]).transpose()
414+
tmp = T3M * np.asmatrix([x_cart, y_cart, 0, 1]).transpose()
415415
tokens[0] = str(float(tmp[0]))
416416
tokens[1] = str(float(tmp[1]))
417417
outfile.write(" %s\n" % " ".join(tokens))
@@ -540,9 +540,9 @@ def run(self, slo, coord_out_file, fault_out_file,
540540

541541
# % matrix to translate to new minimum values (minimum is [0 0])
542542
T3 = self.translation_matrix([-x_min, -y_min, 0])
543-
T3M = np.mat(T3)
543+
T3M = np.asmatrix(T3)
544544
# % shift opposite corner in x-y
545-
tmp = T3M * np.mat([x_max, y_max, 0, 1]).transpose()
545+
tmp = T3M * np.asmatrix([x_max, y_max, 0, 1]).transpose()
546546
bbextent = [float(tmp[0]), float(tmp[1])]
547547

548548
# Write station coord_out file
@@ -551,13 +551,13 @@ def run(self, slo, coord_out_file, fault_out_file,
551551

552552
sfile = open(coord_out_file, 'w')
553553
for i in range(0, n_stat):
554-
tmp = T3M * np.mat([x_stat[i], y_stat[i], 0, 1]).transpose()
554+
tmp = T3M * np.asmatrix([x_stat[i], y_stat[i], 0, 1]).transpose()
555555
BBx_stat.append(float(tmp[0]))
556556
BBy_stat.append(float(tmp[1]))
557557
sfile.write("%8.4f\t%8.4f\n" % (BBx_stat[i], BBy_stat[i]))
558558
sfile.close()
559559

560-
tmp = T3M * np.mat([hypo_x_cart, hypo_y_cart, 0, 1]).transpose()
560+
tmp = T3M * np.asmatrix([hypo_x_cart, hypo_y_cart, 0, 1]).transpose()
561561
BBx_hypo = float(tmp[0])
562562
BBy_hypo = float(tmp[1])
563563

@@ -574,14 +574,14 @@ def run(self, slo, coord_out_file, fault_out_file,
574574

575575
# < put the 'where' point at the axis origin >
576576
T1 = self.translation_matrix([-corn_x, -corn_y, 0])
577-
T1M = np.mat(T1)
577+
T1M = np.asmatrix(T1)
578578

579579
# < align the fault plane to the north axis >
580580
c = np.cos(np.pi / 180 * self.f_strike[0])
581581
s = np.sin(np.pi / 180 * self.f_strike[0])
582582
T2 = np.array([[c, -s, 0, 0], [s, c, 0, 0],
583583
[0, 0, 1, 0], [0, 0, 0, 1]])
584-
T2M = np.mat(T2)
584+
T2M = np.asmatrix(T2)
585585

586586
# inverse matrixes for inverse transform
587587
T1M_inv = np.linalg.inv(T1M)
@@ -608,7 +608,7 @@ def run(self, slo, coord_out_file, fault_out_file,
608608
math.sin(math.radians(self.f_dip[plane])) +
609609
j * math.sin(math.radians(self.f_dip[plane])))
610610
tmp = (T1M_inv * T2M_inv *
611-
np.mat([x_term, y_term, 0, 1]).transpose())
611+
np.asmatrix([x_term, y_term, 0, 1]).transpose())
612612
sub_coord[j].append([float(tmp[0]),
613613
float(tmp[1]),
614614
z_term])

bbp/tests/UnitTests.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
BSD 3-Clause License
44
5-
Copyright (c) 2021, University of Southern California
5+
Copyright (c) 2026, University of Southern California
66
All rights reserved.
77
88
Redistribution and use in source and binary forms, with or without
@@ -91,50 +91,50 @@ def close(self):
9191

9292
# Add broadband platform generic tests
9393
TS.addTests(CoreTestSuite())
94-
TS.addTest(unittest.makeSuite(TestPyNGA))
95-
TS.addTest(unittest.makeSuite(TestVm2vm))
96-
TS.addTest(unittest.makeSuite(TestCC))
94+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestPyNGA))
95+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestVm2vm))
96+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestCC))
9797

9898
# Add Graves & Pitarka tests
99-
TS.addTest(unittest.makeSuite(TestGenslip))
100-
TS.addTest(unittest.makeSuite(TestJbsim))
101-
TS.addTest(unittest.makeSuite(TestHfsims))
102-
TS.addTest(unittest.makeSuite(TestWccSiteamp))
103-
TS.addTest(unittest.makeSuite(TestMatch))
99+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestGenslip))
100+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestJbsim))
101+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestHfsims))
102+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestWccSiteamp))
103+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestMatch))
104104

105105
# Add Irikura tests
106-
TS.addTest(unittest.makeSuite(TestGenSRF))
107-
TS.addTest(unittest.makeSuite(TestIrikuraHF))
106+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestGenSRF))
107+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestIrikuraHF))
108108

109109
# Add UCSB tests
110-
TS.addTest(unittest.makeSuite(TestUCFaultUtils))
111-
TS.addTest(unittest.makeSuite(TestUCrmg))
112-
TS.addTest(unittest.makeSuite(TestSyn1D))
113-
TS.addTest(unittest.makeSuite(TestUCSite))
110+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestUCFaultUtils))
111+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestUCrmg))
112+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestSyn1D))
113+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestUCSite))
114114

115115
# Add SDSU tests
116116
if sys.platform == 'darwin':
117117
print("*** Mac OS X detected: skipping SDSU BBToolbox unit test.")
118118
else:
119119
# Don't add on Mac OS X since test will fail due to raytracer issue
120-
TS.addTest(unittest.makeSuite(TestBBToolbox))
120+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestBBToolbox))
121121

122122
# Add ExSIM tests
123-
TS.addTest(unittest.makeSuite(TestExsim))
123+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestExsim))
124124

125125
# Add Song tests
126-
TS.addTest(unittest.makeSuite(TestRMG))
126+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestRMG))
127127

128128
# Add Post-Processing tests
129-
TS.addTest(unittest.makeSuite(TestRotD50))
130-
TS.addTest(unittest.makeSuite(TestRotD100))
131-
TS.addTest(unittest.makeSuite(TestGPGof))
132-
TS.addTest(unittest.makeSuite(TestFAS))
133-
TS.addTest(unittest.makeSuite(TestFASGof))
134-
TS.addTest(unittest.makeSuite(TestSDSUMOGof))
135-
TS.addTest(unittest.makeSuite(TestAndersonGof))
136-
TS.addTest(unittest.makeSuite(TestRZZ2015))
137-
TS.addTest(unittest.makeSuite(TestAS16))
129+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestRotD50))
130+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestRotD100))
131+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestGPGof))
132+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestFAS))
133+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestFASGof))
134+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestSDSUMOGof))
135+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestAndersonGof))
136+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestRZZ2015))
137+
TS.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(TestAS16))
138138

139139
# Done, run the tests
140140
print("==> Running BBP Unit Tests...")

0 commit comments

Comments
 (0)