66from scipy .special import jv
77
88from aspire .basis import FBBasis2D
9- from aspire .image import Image
10- from aspire .utils import complex_type , real_type , utest_tolerance
9+ from aspire .utils import complex_type , real_type
1110from aspire .utils .coor_trans import grid_2d
1211from aspire .utils .random import randn
1312
@@ -26,310 +25,6 @@ def setUp(self):
2625 def tearDown (self ):
2726 pass
2827
29- def testFBBasis2DIndices (self ):
30- indices = self .basis .indices ()
31-
32- self .assertTrue (
33- np .allclose (
34- indices ["ells" ],
35- [
36- 0.0 ,
37- 0.0 ,
38- 0.0 ,
39- 0.0 ,
40- 1.0 ,
41- 1.0 ,
42- 1.0 ,
43- 1.0 ,
44- 1.0 ,
45- 1.0 ,
46- 2.0 ,
47- 2.0 ,
48- 2.0 ,
49- 2.0 ,
50- 2.0 ,
51- 2.0 ,
52- 3.0 ,
53- 3.0 ,
54- 3.0 ,
55- 3.0 ,
56- 4.0 ,
57- 4.0 ,
58- 4.0 ,
59- 4.0 ,
60- 5.0 ,
61- 5.0 ,
62- 5.0 ,
63- 5.0 ,
64- 6.0 ,
65- 6.0 ,
66- 7.0 ,
67- 7.0 ,
68- 8.0 ,
69- 8.0 ,
70- ],
71- )
72- )
73-
74- self .assertTrue (
75- np .allclose (
76- indices ["ks" ],
77- [
78- 0.0 ,
79- 1.0 ,
80- 2.0 ,
81- 3.0 ,
82- 0.0 ,
83- 1.0 ,
84- 2.0 ,
85- 0.0 ,
86- 1.0 ,
87- 2.0 ,
88- 0.0 ,
89- 1.0 ,
90- 2.0 ,
91- 0.0 ,
92- 1.0 ,
93- 2.0 ,
94- 0.0 ,
95- 1.0 ,
96- 0.0 ,
97- 1.0 ,
98- 0.0 ,
99- 1.0 ,
100- 0.0 ,
101- 1.0 ,
102- 0.0 ,
103- 1.0 ,
104- 0.0 ,
105- 1.0 ,
106- 0.0 ,
107- 0.0 ,
108- 0.0 ,
109- 0.0 ,
110- 0.0 ,
111- 0.0 ,
112- ],
113- )
114- )
115-
116- self .assertTrue (
117- np .allclose (
118- indices ["sgns" ],
119- [
120- 1.0 ,
121- 1.0 ,
122- 1.0 ,
123- 1.0 ,
124- 1.0 ,
125- 1.0 ,
126- 1.0 ,
127- - 1.0 ,
128- - 1.0 ,
129- - 1.0 ,
130- 1.0 ,
131- 1.0 ,
132- 1.0 ,
133- - 1.0 ,
134- - 1.0 ,
135- - 1.0 ,
136- 1.0 ,
137- 1.0 ,
138- - 1.0 ,
139- - 1.0 ,
140- 1.0 ,
141- 1.0 ,
142- - 1.0 ,
143- - 1.0 ,
144- 1.0 ,
145- 1.0 ,
146- - 1.0 ,
147- - 1.0 ,
148- 1.0 ,
149- - 1.0 ,
150- 1.0 ,
151- - 1.0 ,
152- 1.0 ,
153- - 1.0 ,
154- ],
155- )
156- )
157-
158- def testFBBasis2DNorms (self ):
159- radial_norms , angular_norms = self .basis .norms ()
160- self .assertTrue (
161- np .allclose (
162- radial_norms * angular_norms ,
163- [
164- 3.68065992303471 ,
165- 2.41241466684800 ,
166- 1.92454669738088 ,
167- 1.64809729313301 ,
168- 2.01913617828263 ,
169- 1.50455726188833 ,
170- 1.25183461029289 ,
171- 1.70284654929000 ,
172- 1.36051054373844 ,
173- 1.16529703804363 ,
174- 1.49532071137207 ,
175- 1.25039038364830 ,
176- 1.34537533748304 ,
177- 1.16245357319190 ,
178- 1.23042467443861 ,
179- 1.09002083501080 ,
180- 1.13867113286781 ,
181- 1.06324777330476 ,
182- 0.999841586390824 ,
183- ],
184- )
185- )
186-
187- def testFBBasis2DEvaluate (self ):
188- coeffs = np .array (
189- [
190- 1.07338590e-01 ,
191- 1.23690941e-01 ,
192- 6.44482039e-03 ,
193- - 5.40484306e-02 ,
194- - 4.85304586e-02 ,
195- 1.09852144e-02 ,
196- 3.87838396e-02 ,
197- 3.43796455e-02 ,
198- - 6.43284705e-03 ,
199- - 2.86677145e-02 ,
200- - 1.42313328e-02 ,
201- - 2.25684091e-03 ,
202- - 3.31840727e-02 ,
203- - 2.59706174e-03 ,
204- - 5.91919887e-04 ,
205- - 9.97433028e-03 ,
206- 9.19123928e-04 ,
207- 1.19891589e-03 ,
208- 7.49154982e-03 ,
209- 6.18865229e-03 ,
210- - 8.13265715e-04 ,
211- - 1.30715655e-02 ,
212- - 1.44160603e-02 ,
213- 2.90379956e-03 ,
214- 2.37066082e-02 ,
215- 4.88805735e-03 ,
216- 1.47870707e-03 ,
217- 7.63376018e-03 ,
218- - 5.60619559e-03 ,
219- 1.05165081e-02 ,
220- 3.30510143e-03 ,
221- - 3.48652120e-03 ,
222- - 4.23228797e-04 ,
223- 1.40484061e-02 ,
224- ],
225- dtype = self .dtype ,
226- )
227- result = self .basis .evaluate (coeffs )
228-
229- self .assertTrue (
230- np .allclose (
231- result ,
232- np .load (
233- os .path .join (DATA_DIR , "fbbasis_evaluation_8_8.npy" )
234- ).T , # RCOPT
235- atol = utest_tolerance (self .dtype ),
236- )
237- )
238-
239- def testFBBasis2DEvaluate_t (self ):
240- v = np .load (os .path .join (DATA_DIR , "fbbasis_coefficients_8_8.npy" )).T # RCOPT
241- # While FB can accept arrays, prefable to pass FB2D and FFB2D Image instances.
242- img = Image (v .astype (self .dtype ))
243- result = self .basis .evaluate_t (img )
244- self .assertTrue (
245- np .allclose (
246- result ,
247- [
248- 0.10761825 ,
249- 0.12291151 ,
250- 0.00836345 ,
251- - 0.0619454 ,
252- - 0.0483326 ,
253- 0.01053718 ,
254- 0.03977641 ,
255- 0.03420101 ,
256- - 0.0060131 ,
257- - 0.02970658 ,
258- - 0.0151334 ,
259- - 0.00017575 ,
260- - 0.03987446 ,
261- - 0.00257069 ,
262- - 0.0006621 ,
263- - 0.00975174 ,
264- 0.00108047 ,
265- 0.00072022 ,
266- 0.00753342 ,
267- 0.00604493 ,
268- 0.00024362 ,
269- - 0.01711248 ,
270- - 0.01387371 ,
271- 0.00112805 ,
272- 0.02407385 ,
273- 0.00376325 ,
274- 0.00081128 ,
275- 0.00951368 ,
276- - 0.00557536 ,
277- 0.01087579 ,
278- 0.00255393 ,
279- - 0.00525156 ,
280- - 0.00839695 ,
281- 0.00802198 ,
282- ],
283- atol = utest_tolerance (self .dtype ),
284- )
285- )
286-
287- def testFBBasis2DExpand (self ):
288- v = np .load (os .path .join (DATA_DIR , "fbbasis_coefficients_8_8.npy" )).T # RCOPT
289- result = self .basis .expand (v .astype (self .dtype ))
290- self .assertTrue (
291- np .allclose (
292- result ,
293- [
294- 0.10733859 ,
295- 0.12369094 ,
296- 0.00644482 ,
297- - 0.05404843 ,
298- - 0.04853046 ,
299- 0.01098521 ,
300- 0.03878384 ,
301- 0.03437965 ,
302- - 0.00643285 ,
303- - 0.02866771 ,
304- - 0.01423133 ,
305- - 0.00225684 ,
306- - 0.03318407 ,
307- - 0.00259706 ,
308- - 0.00059192 ,
309- - 0.00997433 ,
310- 0.00091912 ,
311- 0.00119892 ,
312- 0.00749155 ,
313- 0.00618865 ,
314- - 0.00081327 ,
315- - 0.01307157 ,
316- - 0.01441606 ,
317- 0.00290380 ,
318- 0.02370661 ,
319- 0.00488806 ,
320- 0.00147871 ,
321- 0.00763376 ,
322- - 0.00560620 ,
323- 0.01051651 ,
324- 0.00330510 ,
325- - 0.00348652 ,
326- - 0.00042323 ,
327- 0.01404841 ,
328- ],
329- atol = utest_tolerance (self .dtype ),
330- )
331- )
332-
33328 def testElement (self ):
33429 ell = 1
33530 sgn = - 1
0 commit comments