Skip to content

Commit 605ec3a

Browse files
committed
update test
1 parent 4aec49f commit 605ec3a

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed

tests/unit/test_coeff.py

+25-31
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
ConstantCoefficient
1515
)
1616

17-
class IntegrationPointMock:
18-
def __init__(self, y):
19-
self.y = y
20-
def __getitem__(self, idx):
21-
return [0, self.y][idx]
22-
2317
class TestCoefficients(unittest.TestCase):
2418

2519
def test_TotalXSCoefficient(self):
@@ -32,20 +26,20 @@ def test_TotalXSCoefficient(self):
3226
def test_ScatteringXSCoefficient(self):
3327
xs_s_data = [0.5, 1.5, 2.5]
3428
coeff = ScatteringXSCoefficient(xs_s_data, 1.0, 4.0)
35-
self.assertAlmostEqual(coeff.EvalValue([0, 0]), 0.5)
36-
self.assertAlmostEqual(coeff.EvalValue([0, 0.5]), 1.5)
29+
self.assertAlmostEqual(coeff.EvalValue([0, 1.0]), 0.5)
30+
self.assertAlmostEqual(coeff.EvalValue([0, 2.5]), 1.5)
3731

3832
def test_StoppingPowerCoefficient(self):
3933
S_data = [10, 20, 30]
4034
coeff = StoppingPowerCoefficient(S_data, 2.0, 5.0)
41-
self.assertAlmostEqual(coeff.EvalValue([0, 0]), 10)
42-
self.assertAlmostEqual(coeff.EvalValue([0, 1]), 30)
35+
self.assertAlmostEqual(coeff.EvalValue([0, 2.0]), 10)
36+
self.assertAlmostEqual(coeff.EvalValue([0, 4.9]), 30)
4337

4438
def test_StoppingPowerDerivativeCoefficient(self):
4539
dS_data = [-1, -2, -3]
46-
coeff = StoppingPowerDerivativeCoefficient(dS_data=dS_data, E_start=0.0, E_end=3.0)
47-
self.assertAlmostEqual(coeff.EvalValue([0, 0]), -1)
48-
self.assertAlmostEqual(coeff.EvalValue([0, 1]), -3)
40+
coeff = StoppingPowerDerivativeCoefficient(dS_data, E_start=0.0, E_end=3.0)
41+
self.assertAlmostEqual(coeff.EvalValue([0, 0.0]), -1)
42+
self.assertAlmostEqual(coeff.EvalValue([0, 2.9]), -3)
4943

5044
def test_InflowCoefficientSN_positive_mu(self):
5145
coeff = InflowCoefficientSN(in_flux=5.0, mu=0.7)
@@ -64,14 +58,28 @@ def test_QCoefficient_constant(self):
6458
def test_QCoefficient_energy_dependent(self):
6559
Q_data = [1.0, 2.0, 3.0, 4.0]
6660
coeff = QCoefficient(Q_data, 0.0, 4.0)
67-
self.assertEqual(coeff.EvalValue([0, 0]), 1.0)
68-
self.assertEqual(coeff.EvalValue([0, 1]), 4.0)
61+
self.assertEqual(coeff.EvalValue([0, 0.0]), 1.0)
62+
self.assertEqual(coeff.EvalValue([0, 3.9]), 4.0)
6963

7064
def test_EnergyDependentCoefficient(self):
7165
data = [10.0, 20.0, 30.0]
7266
coeff = EnergyDependentCoefficient(data, 0, 3)
73-
self.assertAlmostEqual(coeff.EvalValue([0, 0]), 10.0)
74-
self.assertAlmostEqual(coeff.EvalValue([0, 1]), 30.0)
67+
self.assertAlmostEqual(coeff.EvalValue([0, 0.0]), 10.0)
68+
self.assertAlmostEqual(coeff.EvalValue([0, 2.9]), 30.0)
69+
70+
def test_VelocityCoefficient(self):
71+
mu = 0.8
72+
S_arr = [1.0, 2.0, 3.0]
73+
E_start, E_end = 0.0, 3.0
74+
coeff = VelocityCoefficient(mu, S_arr, E_start, E_end)
75+
self.assertEqual(coeff.EvalValue([0, 0.0]), [0.8, 1.0])
76+
self.assertEqual(coeff.EvalValue([0, 2.9]), [0.8, 3.0])
77+
78+
def test_ConstantCoefficient(self):
79+
const_value = 7.0
80+
coeff = ConstantCoefficient(const_value)
81+
self.assertEqual(coeff.EvalValue([0, 0.5]), 7.0)
82+
self.assertEqual(coeff.EvalValue([10, 100]), 7.0)
7583

7684
def test_XDependentCoefficient(self):
7785
data = [1.0, 3.0, 5.0]
@@ -86,19 +94,5 @@ def test_VelocityCoefficientOld(self):
8694
self.assertEqual(coeff._EvalPy([0, 0]), [0.5, 2.0])
8795
self.assertEqual(coeff._EvalPy([1, 1]), [0.5, 2.0])
8896

89-
def test_VelocityCoefficient(self):
90-
mu = 0.8
91-
S_arr = [1.0, 2.0, 3.0]
92-
E_start, E_end = 0.0, 3.0
93-
coeff = VelocityCoefficient(mu, S_arr, E_start, E_end)
94-
self.assertEqual(coeff.EvalValue([0, 0]), [0.8, 1.0])
95-
self.assertEqual(coeff.EvalValue([0, 1]), [0.8, 3.0])
96-
97-
def test_ConstantCoefficient(self):
98-
const_value = 7.0
99-
coeff = ConstantCoefficient(const_value)
100-
self.assertEqual(coeff.EvalValue([0, 0.5]), 7.0)
101-
self.assertEqual(coeff.EvalValue([10, 100]), 7.0)
102-
10397
if __name__ == '__main__':
10498
unittest.main()

0 commit comments

Comments
 (0)