1010
1111
1212class TestAccuracyAgainstOldCollect :
13- def test_single_file (self , tmpdir_factory ):
13+ def test_single_file (self , tmp_path_factory ):
1414
1515 # Create temp directory for files
16- test_dir = tmpdir_factory .mktemp ("test_data" )
16+ test_dir = tmp_path_factory .mktemp ("test_data" )
1717
1818 # Generate some test data
1919 generated_ds = create_bout_ds (syn_data_type = "linear" )
20- generated_ds .to_netcdf (str ( test_dir .join ("BOUT.dmp.0.nc" ) ))
20+ generated_ds .to_netcdf (test_dir .joinpath ("BOUT.dmp.0.nc" ))
2121
2222 var = "n"
2323 expected = old_collect (var , path = test_dir , xguards = True , yguards = False )
2424
2525 # Test against new standard - open_boutdataset
2626 with pytest .warns (UserWarning ):
27- ds = open_boutdataset (test_dir .join ("BOUT.dmp.0.nc" ))
27+ ds = open_boutdataset (test_dir .joinpath ("BOUT.dmp.0.nc" ))
2828 actual = ds [var ].values
2929
3030 assert expected .shape == actual .shape
@@ -36,24 +36,24 @@ def test_single_file(self, tmpdir_factory):
3636 assert expected .shape == actual .shape
3737 npt .assert_equal (actual , expected )
3838
39- def test_multiple_files_along_x (self , tmpdir_factory ):
39+ def test_multiple_files_along_x (self , tmp_path_factory ):
4040
4141 # Create temp directory for files
42- test_dir = tmpdir_factory .mktemp ("test_data" )
42+ test_dir = tmp_path_factory .mktemp ("test_data" )
4343
4444 # Generate some test data
4545 ds_list , file_list = create_bout_ds_list (
4646 "BOUT.dmp" , nxpe = 3 , nype = 1 , syn_data_type = "linear"
4747 )
4848 for temp_ds , file_name in zip (ds_list , file_list ):
49- temp_ds .to_netcdf (str ( test_dir .join ( str ( file_name )) ))
49+ temp_ds .to_netcdf (test_dir .joinpath ( file_name ))
5050
5151 var = "n"
5252 expected = old_collect (var , path = test_dir , prefix = "BOUT.dmp" , xguards = True )
5353
5454 # Test against new standard - open_boutdataset
5555 with pytest .warns (UserWarning ):
56- ds = open_boutdataset (test_dir .join ("BOUT.dmp.*.nc" ))
56+ ds = open_boutdataset (test_dir .joinpath ("BOUT.dmp.*.nc" ))
5757 actual = ds [var ].values
5858
5959 assert expected .shape == actual .shape
@@ -65,24 +65,24 @@ def test_multiple_files_along_x(self, tmpdir_factory):
6565 assert expected .shape == actual .shape
6666 npt .assert_equal (actual , expected )
6767
68- def test_multiple_files_along_y (self , tmpdir_factory ):
68+ def test_multiple_files_along_y (self , tmp_path_factory ):
6969
7070 # Create temp directory for files
71- test_dir = tmpdir_factory .mktemp ("test_data" )
71+ test_dir = tmp_path_factory .mktemp ("test_data" )
7272
7373 # Generate some test data
7474 ds_list , file_list = create_bout_ds_list (
7575 "BOUT.dmp" , nxpe = 1 , nype = 3 , syn_data_type = "linear"
7676 )
7777 for temp_ds , file_name in zip (ds_list , file_list ):
78- temp_ds .to_netcdf (str ( test_dir .join ( str ( file_name )) ))
78+ temp_ds .to_netcdf (test_dir .joinpath ( file_name ))
7979
8080 var = "n"
8181 expected = old_collect (var , path = test_dir , prefix = "BOUT.dmp" , xguards = True )
8282
8383 # Test against new standard - .open_boutdataset
8484 with pytest .warns (UserWarning ):
85- ds = open_boutdataset (test_dir .join ("BOUT.dmp.*.nc" ))
85+ ds = open_boutdataset (test_dir .joinpath ("BOUT.dmp.*.nc" ))
8686 actual = ds [var ].values
8787
8888 assert expected .shape == actual .shape
@@ -94,24 +94,24 @@ def test_multiple_files_along_y(self, tmpdir_factory):
9494 assert expected .shape == actual .shape
9595 npt .assert_equal (actual , expected )
9696
97- def test_multiple_files_along_xy (self , tmpdir_factory ):
97+ def test_multiple_files_along_xy (self , tmp_path_factory ):
9898
9999 # Create temp directory for files
100- test_dir = tmpdir_factory .mktemp ("test_data" )
100+ test_dir = tmp_path_factory .mktemp ("test_data" )
101101
102102 # Generate some test data
103103 ds_list , file_list = create_bout_ds_list (
104104 "BOUT.dmp" , nxpe = 3 , nype = 3 , syn_data_type = "linear"
105105 )
106106 for temp_ds , file_name in zip (ds_list , file_list ):
107- temp_ds .to_netcdf (str ( test_dir .join ( str ( file_name )) ))
107+ temp_ds .to_netcdf (test_dir .joinpath ( file_name ))
108108
109109 var = "n"
110110 expected = old_collect (var , path = test_dir , prefix = "BOUT.dmp" , xguards = True )
111111
112112 # Test against new standard - .open_boutdataset
113113 with pytest .warns (UserWarning ):
114- ds = open_boutdataset (test_dir .join ("BOUT.dmp.*.nc" ))
114+ ds = open_boutdataset (test_dir .joinpath ("BOUT.dmp.*.nc" ))
115115 actual = ds [var ].values
116116
117117 assert expected .shape == actual .shape
@@ -123,16 +123,16 @@ def test_multiple_files_along_xy(self, tmpdir_factory):
123123 assert expected .shape == actual .shape
124124 npt .assert_equal (actual , expected )
125125
126- def test_metadata (self , tmpdir_factory ):
126+ def test_metadata (self , tmp_path_factory ):
127127 # Create temp directory for files
128- test_dir = tmpdir_factory .mktemp ("test_data" )
128+ test_dir = tmp_path_factory .mktemp ("test_data" )
129129
130130 # Generate some test data
131131 generated_ds = create_bout_ds (syn_data_type = "linear" )
132- generated_ds .to_netcdf (str ( test_dir .join ("BOUT.dmp.0.nc" ) ))
132+ generated_ds .to_netcdf (test_dir .joinpath ("BOUT.dmp.0.nc" ))
133133
134134 with pytest .warns (UserWarning ):
135- ds = open_boutdataset (test_dir .join ("BOUT.dmp.*.nc" ))
135+ ds = open_boutdataset (test_dir .joinpath ("BOUT.dmp.*.nc" ))
136136
137137 for v in METADATA_VARS :
138138 expected = old_collect (v , path = test_dir )
@@ -144,17 +144,17 @@ def test_metadata(self, tmpdir_factory):
144144 actual = new_collect (v , path = test_dir )
145145 npt .assert_equal (actual , expected )
146146
147- def test_new_collect_indexing_int (self , tmpdir_factory ):
147+ def test_new_collect_indexing_int (self , tmp_path_factory ):
148148 # Create temp directory for files
149- test_dir = tmpdir_factory .mktemp ("test_data" )
149+ test_dir = tmp_path_factory .mktemp ("test_data" )
150150
151151 # Generate some test data
152152 ds_list , file_list = create_bout_ds_list (
153153 "BOUT.dmp" , nxpe = 3 , nype = 3 , syn_data_type = "linear"
154154 )
155155
156156 for temp_ds , file_name in zip (ds_list , file_list ):
157- temp_ds .to_netcdf (str ( test_dir .join ( str ( file_name )) ))
157+ temp_ds .to_netcdf (test_dir .joinpath ( file_name ))
158158
159159 var = "n"
160160 indexers = ["tind" , "xind" , "yind" , "zind" ]
@@ -170,16 +170,16 @@ def test_new_collect_indexing_int(self, tmpdir_factory):
170170 assert expected .shape == actual .shape
171171 npt .assert_equal (actual , expected )
172172
173- def test_new_collect_indexing_list (self , tmpdir_factory ):
173+ def test_new_collect_indexing_list (self , tmp_path_factory ):
174174 # Create temp directory for files
175- test_dir = tmpdir_factory .mktemp ("test_data" )
175+ test_dir = tmp_path_factory .mktemp ("test_data" )
176176
177177 # Generate some test data
178178 ds_list , file_list = create_bout_ds_list (
179179 "BOUT.dmp" , nxpe = 3 , nype = 3 , syn_data_type = "linear"
180180 )
181181 for temp_ds , file_name in zip (ds_list , file_list ):
182- temp_ds .to_netcdf (str ( test_dir .join ( str ( file_name )) ))
182+ temp_ds .to_netcdf (test_dir .joinpath ( file_name ))
183183
184184 var = "n"
185185 indexers = ["tind" , "xind" , "yind" , "zind" ]
@@ -195,17 +195,17 @@ def test_new_collect_indexing_list(self, tmpdir_factory):
195195 assert expected .shape == actual .shape
196196 npt .assert_equal (actual , expected )
197197
198- def test_new_collect_indexing_slice (self , tmpdir_factory ):
198+ def test_new_collect_indexing_slice (self , tmp_path_factory ):
199199 # Create temp directory for files
200- test_dir = tmpdir_factory .mktemp ("test_data" )
200+ test_dir = tmp_path_factory .mktemp ("test_data" )
201201
202202 # Generate some test data
203203 ds_list , file_list = create_bout_ds_list (
204204 "BOUT.dmp" , nxpe = 3 , nype = 3 , syn_data_type = "linear"
205205 )
206206
207207 for temp_ds , file_name in zip (ds_list , file_list ):
208- temp_ds .to_netcdf (str ( test_dir .join ( str ( file_name )) ))
208+ temp_ds .to_netcdf (test_dir .joinpath ( file_name ))
209209
210210 var = "n"
211211 indexers = ["tind" , "xind" , "yind" , "zind" ]
0 commit comments