1+ import sys
12import time
23from typing import Any , Callable , Tuple
34
1213import flopy4 .xarray_jinja .filters as filters
1314
1415test_combinations = [
15- (1_000 , 100 ),
16- (1_000_000 , 1_000 ),
16+ # (1_000, 100),
17+ # (1_000_000, 1_000),
1718 (1_000_000 , 10_000 ),
18- (10_000_000 , 1_000 ),
19+ # (10_000_000, 1_000),
1920 (10_000_000 , 10_000 ),
20- (100_000_000 , 10_000 ),
21+ # (100_000_000, 10_000),
2122 (100_000_000 , 100_000 ),
23+ (100_000_000 , 1_000_000 ), # 1_000_000 is about 8MB of chunks.
24+ (
25+ 100_000_000 ,
26+ 10_000_000 ,
27+ ), # 10_000_000 is about 80MB of chunks. Copilot advised 100MB.
2228]
2329
2430
@@ -74,6 +80,7 @@ def create_and_write_jinja(tmp_path, data: xr.DataArray):
7480 "max_size,chunks" ,
7581 test_combinations ,
7682)
83+ @pytest .mark .skip ("Too slow for large data" )
7784def test_xarray_to_text_jinja (
7885 tmp_path , max_size , chunks , time_file , memory_file
7986):
@@ -143,6 +150,7 @@ def create_and_write_np_savetxt(tmp_path, data: xr.DataArray):
143150 "max_size,chunks" ,
144151 test_combinations ,
145152)
153+ @pytest .mark .skip ("Too slow for large data" )
146154def test_xarray_to_text_np_savetxt (
147155 tmp_path , max_size , chunks , memory_file , time_file
148156):
@@ -162,16 +170,24 @@ def test_xarray_to_text_np_savetxt(
162170
163171
164172def create_and_write_extras (tmp_path , data : xr .DataArray ):
173+ file_path = tmp_path / "test_xarray_to_text_extras.disu"
174+ with open (file_path , "w" ) as f :
175+ f .write ("BEGIN GRIDDATA\n " )
165176 promise = xarray_extras .csv .to_csv (
166177 data ,
167- tmp_path / "test_xarray_to_text_extras.disu" ,
178+ file_path ,
168179 header = False ,
169180 index = False ,
170181 float_format = "%.4f" ,
171182 lineterminator = " " ,
172183 compression = None ,
184+ mode = "a" ,
173185 )
174186 promise .compute ()
187+ # we have to open the file again,
188+ # because xarray_extras only allows paths and no file handlers.
189+ with open (file_path , "a" ) as f :
190+ f .write ("\n END GRIDDATA\n " )
175191
176192
177193@pytest .mark .parametrize (
@@ -193,4 +209,4 @@ def test_xarray_to_text_extras(
193209
194210 with open (tmp_path / "test_xarray_to_text_extras.disu" , "r" ) as f :
195211 output = f .readlines ()
196- assert len (output ) == 1
212+ assert len (output ) == 3
0 commit comments