4
4
import pytest
5
5
6
6
from WallGo import InterpolatableFunction , EExtrapolationType
7
-
8
7
from WallGo import PotentialTools
9
- from WallGo .PotentialTools import JbIntegral , JfIntegral
10
8
11
9
### Test real parts of Jb, Jf integrals
12
10
20
18
)
21
19
def test_directJb (x : float , expectedResult : np .array ) -> None :
22
20
23
- Jb = JbIntegral (bUseAdaptiveInterpolation = False )
21
+ Jb = PotentialTools . JbIntegral (bUseAdaptiveInterpolation = False )
24
22
assert Jb (x ) == pytest .approx (expectedResult , rel = 1e-6 )
25
23
26
24
@@ -30,7 +28,7 @@ def test_directJb(x: float, expectedResult: np.array) -> None:
30
28
)
31
29
def test_directJb_derivative (x : float , expectedResult : float ) -> None :
32
30
33
- Jb = JbIntegral (bUseAdaptiveInterpolation = False )
31
+ Jb = PotentialTools . JbIntegral (bUseAdaptiveInterpolation = False )
34
32
assert Jb .derivative (x , 1 , False ) == pytest .approx (expectedResult , rel = 1e-6 )
35
33
36
34
@@ -40,7 +38,7 @@ def test_directJb_derivative(x: float, expectedResult: float) -> None:
40
38
)
41
39
def test_directJf (x : float , expectedResult : float ) -> None :
42
40
43
- Jf = JfIntegral (bUseAdaptiveInterpolation = False )
41
+ Jf = PotentialTools . JfIntegral (bUseAdaptiveInterpolation = False )
44
42
assert Jf (x ) == pytest .approx (expectedResult , rel = 1e-6 )
45
43
46
44
@@ -50,21 +48,21 @@ def test_directJf(x: float, expectedResult: float) -> None:
50
48
)
51
49
def test_directJf_derivative (x : float , expectedResult : float ) -> None :
52
50
53
- Jf = JfIntegral (bUseAdaptiveInterpolation = False )
51
+ Jf = PotentialTools . JfIntegral (bUseAdaptiveInterpolation = False )
54
52
assert Jf .derivative (x , 1 , False ) == pytest .approx (expectedResult , rel = 1e-6 )
55
53
56
54
57
55
## Interpolated Jb integral fixture, no extrapolation. The interpolation here is very rough to make this run fast
58
56
@pytest .fixture ()
59
57
def Jb_interpolated () -> InterpolatableFunction :
60
- Jb = JbIntegral (bUseAdaptiveInterpolation = False )
58
+ Jb = PotentialTools . JbIntegral (bUseAdaptiveInterpolation = False )
61
59
Jb .newInterpolationTable (1.0 , 10.0 , 100 )
62
60
return Jb
63
61
64
62
65
63
@pytest .fixture ()
66
64
def Jf_interpolated () -> InterpolatableFunction :
67
- Jf = JfIntegral (bUseAdaptiveInterpolation = False )
65
+ Jf = PotentialTools . JfIntegral (bUseAdaptiveInterpolation = False )
68
66
Jf .newInterpolationTable (1.0 , 10.0 , 100 )
69
67
return Jf
70
68
@@ -94,7 +92,7 @@ def Jf_interpolated() -> InterpolatableFunction:
94
92
],
95
93
)
96
94
def test_Jb_interpolated (
97
- Jb_interpolated : JbIntegral ,
95
+ Jb_interpolated : PotentialTools . JbIntegral ,
98
96
x : Union [float , np .array ],
99
97
expectedResult : Union [float , np .array ],
100
98
) -> None :
@@ -103,7 +101,7 @@ def test_Jb_interpolated(
103
101
104
102
105
103
@pytest .mark .parametrize ("x" , [- 5 , - 1 , 0 , 0.5 , 1 , 5 , 10 ])
106
- def test_Jb_derivative_interpolated (Jb_interpolated : JbIntegral , x : float ) -> None :
104
+ def test_Jb_derivative_interpolated (Jb_interpolated : PotentialTools . JbIntegral , x : float ) -> None :
107
105
np .testing .assert_allclose (
108
106
Jb_interpolated .derivative (x , 1 , True ),
109
107
Jb_interpolated .derivative (x , 1 , False ),
@@ -113,7 +111,7 @@ def test_Jb_derivative_interpolated(Jb_interpolated: JbIntegral, x: float) -> No
113
111
114
112
@pytest .mark .parametrize ("x" , [- 5 , - 1 , 0 , 0.5 , 1 , 5 , 10 ])
115
113
def test_Jb_second_derivative_interpolated (
116
- Jb_interpolated : JbIntegral , x : float
114
+ Jb_interpolated : PotentialTools . JbIntegral , x : float
117
115
) -> None :
118
116
np .testing .assert_allclose (
119
117
Jb_interpolated .derivative (x , 2 , True ),
@@ -124,7 +122,7 @@ def test_Jb_second_derivative_interpolated(
124
122
125
123
126
124
@pytest .mark .parametrize ("x" , [- 5 , - 1 , 0 , 0.5 , 1 , 5 , 10 ])
127
- def test_Jf_derivative_interpolated (Jf_interpolated : JfIntegral , x : float ) -> None :
125
+ def test_Jf_derivative_interpolated (Jf_interpolated : PotentialTools . JfIntegral , x : float ) -> None :
128
126
np .testing .assert_allclose (
129
127
Jf_interpolated .derivative (x , 1 , True ),
130
128
Jf_interpolated .derivative (x , 1 , False ),
@@ -134,7 +132,7 @@ def test_Jf_derivative_interpolated(Jf_interpolated: JfIntegral, x: float) -> No
134
132
135
133
@pytest .mark .parametrize ("x" , [- 5 , - 1 , 0 , 0.5 , 1 , 5 , 10 ])
136
134
def test_Jf_second_derivative_interpolated (
137
- Jf_interpolated : JfIntegral , x : float
135
+ Jf_interpolated : PotentialTools . JfIntegral , x : float
138
136
) -> None :
139
137
np .testing .assert_allclose (
140
138
Jf_interpolated .derivative (x , 2 , True ),
@@ -148,7 +146,7 @@ def test_Jf_second_derivative_interpolated(
148
146
149
147
150
148
## Got lazy with parametrization here, so this is just one big function now
151
- def test_Jb_extrapolation_constant (Jb_interpolated : JbIntegral ) -> None :
149
+ def test_Jb_extrapolation_constant (Jb_interpolated : PotentialTools . JbIntegral ) -> None :
152
150
153
151
Jb = Jb_interpolated
154
152
Jb .setExtrapolationType (
@@ -197,7 +195,7 @@ def test_Jb_extrapolation_constant(Jb_interpolated: JbIntegral) -> None:
197
195
198
196
199
197
##
200
- def test_Jb_extend_range (Jb_interpolated : JbIntegral ) -> None :
198
+ def test_Jb_extend_range (Jb_interpolated : PotentialTools . JbIntegral ) -> None :
201
199
202
200
Jb = Jb_interpolated
203
201
relativeTolerance = 1e-6
0 commit comments