@@ -132,6 +132,16 @@ def test_nbins(self):
132132 bond .nbins = 70
133133 assert bond .nbins == 70
134134
135+ def test_nbins_error (self ):
136+ with pytest .raises (ValueError ):
137+ Bond (type1 = "A" , type2 = "B" , optimize = True , nbins = None )
138+
139+ with pytest .raises (ValueError ):
140+ Bond (type1 = "A" , type2 = "B" , optimize = True , nbins = 0 )
141+
142+ with pytest .raises (ValueError ):
143+ Bond (type1 = "A" , type2 = "B" , optimize = True , nbins = - 3 )
144+
135145 def test_set_potential_error (self ):
136146 bond = Bond (type1 = "A" , type2 = "B" , optimize = False )
137147 bond .set_harmonic (k = 500 , r0 = 2 )
@@ -195,9 +205,15 @@ def test_not_optimized_errors(self, angle, stateY):
195205 with pytest .raises (PotentialNotOptimizedError ):
196206 angle .smooth_potential ()
197207
208+ with pytest .raises (PotentialNotOptimizedError ):
209+ angle .distribution_fit (state = stateY )
210+
198211 with pytest .raises (PotentialNotOptimizedError ):
199212 angle .save_potential_history (file_path = "pot.csv" )
200213
214+ with pytest .raises (PotentialNotOptimizedError ):
215+ angle .plot_potential_history ()
216+
201217 with pytest .raises (PotentialNotOptimizedError ):
202218 angle .save_state_data (state = stateY , file_path = "statey.npz" )
203219
@@ -248,6 +264,27 @@ def test_save_table_potential(self, tmp_path, bond):
248264 bond .save_potential (path )
249265 assert os .path .isfile (path )
250266
267+ def test_save_potential_history (self , tmp_path , bond ):
268+ bond = Bond (
269+ type1 = "A" ,
270+ type2 = "B" ,
271+ optimize = True ,
272+ nbins = 60 ,
273+ )
274+ bond .set_polynomial (
275+ x0 = 2 ,
276+ k4 = 1 ,
277+ k3 = 1 ,
278+ k2 = 1 ,
279+ x_min = 1 ,
280+ x_max = 3 ,
281+ )
282+ for i in range (2 ):
283+ bond .potential_history .append (np .copy (bond .potential ))
284+ path = os .path .join (tmp_path , "AB_history.npy" )
285+ bond .save_potential (path )
286+ assert os .path .isfile (path )
287+
251288
252289class TestAngle (BaseTest ):
253290 def test_angle_name (self , angle ):
0 commit comments