11import pytest
22import numpy as np
33from diffpy .snmf .subroutines import objective_function , get_stretched_component , reconstruct_data , get_residual_matrix , \
4- update_weights_matrix , initialize_arrays , lift_data , create_components
4+ update_weights_matrix , initialize_arrays , lift_data , initialize_components
55
66to = [
77 ([[[1 , 2 ], [3 , 4 ]], [[5 , 6 ], [7 , 8 ]], 1e11 , [[1 , 2 ], [3 , 4 ]], [[1 , 2 ], [3 , 4 ]], 1 ], 2.574e14 ),
@@ -152,18 +152,12 @@ def test_lift_data(tld):
152152 expected = tld [1 ]
153153 np .testing .assert_allclose (actual , expected )
154154
155- tcc = [(2 , [0 , .5 , 1 , 1.5 ], 3 , 3 ),
156- (3 ,[0 ,10 ,20 ,30 ],10 ,15 ),
157- (0 ,[0 ],11 ,30 ),
158- (5 ,[1 ,1 ,1 ,1 ,1 ,1 ],10000 ,40000 ),
159- (3 ,np .arange (stop = 125 ,step = .05 ),20 ,2500 ),
155+ tcc = [(2 , 3 ,[0 , .5 , 1 , 1.5 ]), # Regular usage
156+ #(0, 3,[0, .5, 1, 1.5]), # Zero components raise an exception. Not tested
160157 ]
161158@pytest .mark .parametrize ('tcc' , tcc )
162- def test_create_components (tcc ):
163- actual = create_components (tcc [0 ], tcc [1 ], tcc [2 ], tcc [ 3 ])
159+ def test_initialize_components (tcc ):
160+ actual = initialize_components (tcc [0 ], tcc [1 ], tcc [2 ])
164161 assert len (actual ) == tcc [0 ]
165- for c in actual :
166- assert len (c .iq ) == tcc [3 ]
167- assert len (c .weights ) == tcc [2 ]
168- assert len (c .stretching_factors ) == tcc [2 ]
169- assert (c .grid == tcc [1 ]).all ()
162+ assert len (actual [0 ].weights ) == tcc [1 ]
163+ assert (actual [0 ].grid == np .array (tcc [2 ])).all ()
0 commit comments