77
88from napari_deeplabcut import _writer , misc
99
10+ rng = np .random .default_rng (42 )
11+
1012
1113# Basic tests
1214def test_write_config (tmp_path ):
@@ -22,7 +24,7 @@ def test_write_config(tmp_path):
2224
2325
2426def test_write_image (tmp_path ):
25- img = (np .random . rand ( 10 , 10 ) * 255 ).astype (np .uint8 )
27+ img = (rng .random (( 10 , 10 ) ) * 255 ).astype (np .uint8 )
2628 output = tmp_path / "test.png"
2729
2830 _writer ._write_image (img , str (output ))
@@ -81,7 +83,7 @@ def test_form_df_multi_animal(fake_keypoints):
8183 metadata = _fake_metadata_for_df (fake_keypoints , [f"img{ i } .png" for i in range (n )])
8284
8385 # inds + (x,y)
84- data = np .column_stack ([np .arange (n ), np .random . rand (n ), np .random . rand (n )])
86+ data = np .column_stack ([np .arange (n ), rng .random (n ), rng .random (n )])
8587
8688 df = _writer ._form_df (data , metadata )
8789
@@ -116,7 +118,7 @@ def test_form_df_single_animal(fake_keypoints):
116118 metadata = _fake_metadata_for_df (df_single , [f"img{ i } .png" for i in range (n )])
117119
118120 # inds + (x,y)
119- points = np .column_stack ([np .arange (n ), np .random . rand (n ), np .random . rand (n )])
121+ points = np .column_stack ([np .arange (n ), rng .random (n ), rng .random (n )])
120122 out = _writer ._form_df (points , metadata )
121123
122124 assert isinstance (out , pd .DataFrame )
@@ -166,8 +168,8 @@ def test_write_hdf_basic(tmp_path, fake_keypoints):
166168 points = np .column_stack (
167169 [
168170 np .arange (n_rows ),
169- np .random . rand (n_rows ),
170- np .random . rand (n_rows ),
171+ rng .random (n_rows ),
172+ rng .random (n_rows ),
171173 ]
172174 )
173175
@@ -230,8 +232,8 @@ def test_write_hdf_machine_prediction_merge(tmp_path, fake_keypoints):
230232 points = np .column_stack (
231233 [
232234 np .arange (n_rows ),
233- np .random . rand (n_rows ),
234- np .random . rand (n_rows ),
235+ rng .random (n_rows ),
236+ rng .random (n_rows ),
235237 ]
236238 )
237239
@@ -291,8 +293,8 @@ def test_write_hdf_machine_pred_no_gt(tmp_path, fake_keypoints):
291293 points = np .column_stack (
292294 [
293295 np .arange (n_rows ),
294- np .random . rand (n_rows ),
295- np .random . rand (n_rows ),
296+ rng .random (n_rows ),
297+ rng .random (n_rows ),
296298 ]
297299 )
298300
0 commit comments