@@ -377,7 +377,7 @@ def test_allclose_xy_success(self, tmp_path, actual_dir, expected_dir):
377377 actual_ds .to_netcdf (actual_dir / "data.nc" )
378378 assert_job_results_allclose (actual = actual_dir , expected = expected_dir , tmp_path = tmp_path , rtol = 1 )
379379
380- def test_allclose_minimal_xy_different (self , tmp_path , actual_dir , expected_dir ):
380+ def test_allclose_xy_different (self , tmp_path , actual_dir , expected_dir ):
381381 expected_ds = xarray .Dataset (
382382 {
383383 "b1" : xarray .Variable (dims = ["t" , "x" , "y" ], data = 2 * numpy .ones ((3 , 4 , 5 ))),
@@ -415,6 +415,71 @@ def test_allclose_minimal_xy_different(self, tmp_path, actual_dir, expected_dir)
415415 ):
416416 assert_job_results_allclose (actual = actual_dir , expected = expected_dir , tmp_path = tmp_path )
417417
418+ def test_allclose_bytes_minimal_xy_success (self , tmp_path , actual_dir , expected_dir ):
419+ expected_ds = xarray .Dataset (
420+ {
421+ "b1" : xarray .Variable (dims = ["t" , "x" , "y" ], data = (2 * numpy .ones ((3 , 4 , 5 )))),
422+ "b2" : xarray .Variable (dims = ["t" , "x" , "y" ], data = (3 * numpy .ones ((3 , 4 , 5 )))),
423+ },
424+ coords = {
425+ "t" : range (0 , 3 ),
426+ "x" : range (4 , 8 ),
427+ "y" : range (5 , 10 ),
428+ },
429+ )
430+ expected_ds .astype (dtype = numpy .dtype ("B" )).to_netcdf (expected_dir / "data.nc" )
431+ actual_ds = xarray .Dataset (
432+ {
433+ "b1" : xarray .Variable (dims = ["t" , "x" , "y" ], data = (1 * numpy .ones ((3 , 4 , 5 )))),
434+ "b2" : xarray .Variable (dims = ["t" , "x" , "y" ], data = (3 * numpy .ones ((3 , 4 , 5 )))),
435+ },
436+ coords = {
437+ "t" : range (0 , 3 ),
438+ "x" : range (4 , 8 ),
439+ "y" : range (5 , 10 ),
440+ },
441+ )
442+ actual_ds .astype (dtype = numpy .dtype ("B" )).to_netcdf (actual_dir / "data.nc" )
443+ assert_job_results_allclose (actual = actual_dir , expected = expected_dir , tmp_path = tmp_path , atol = 2 )
444+
445+ def test_allclose_bytes_minimal_xy_different (self , tmp_path , actual_dir , expected_dir ):
446+ expected_ds = xarray .Dataset (
447+ {
448+ "b1" : xarray .Variable (dims = ["t" , "x" , "y" ], data = (2 * numpy .ones ((3 , 4 , 5 )))),
449+ "b2" : xarray .Variable (dims = ["t" , "x" , "y" ], data = (3 * numpy .ones ((3 , 4 , 5 )))),
450+ },
451+ coords = {
452+ "t" : range (0 , 3 ),
453+ "x" : range (4 , 8 ),
454+ "y" : range (5 , 10 ),
455+ },
456+ )
457+ expected_ds .astype (dtype = numpy .dtype ("B" )).to_netcdf (expected_dir / "data.nc" )
458+ actual_ds = xarray .Dataset (
459+ {
460+ "b1" : xarray .Variable (dims = ["t" , "x" , "y" ], data = (1 * numpy .ones ((3 , 4 , 5 )))),
461+ "b2" : xarray .Variable (dims = ["t" , "x" , "y" ], data = (3 * numpy .ones ((3 , 4 , 5 )))),
462+ },
463+ coords = {
464+ "t" : range (0 , 3 ),
465+ "x" : range (4 , 8 ),
466+ "y" : range (5 , 10 ),
467+ },
468+ )
469+ actual_ds .astype (dtype = numpy .dtype ("B" )).to_netcdf (actual_dir / "data.nc" )
470+ with raises_assertion_error_or_not (
471+ r"Issues for file 'data.nc'.*"
472+ r"Issues for variable 'b1'.*"
473+ r"Left and right DataArray objects are not close.*Differing values:.*"
474+ r"t 0: value difference exceeds tolerance \(rtol 1e-06, atol 0.2\), min:1.0, max: 1.0, mean: 1.0, var: 0.0.*"
475+ r"t 0: differing pixels: 20/20 \(100.0%\), bbox \(\(4, 5\), \(7, 9\)\) - 100.0% of the area.*"
476+ r"t 1: value difference exceeds tolerance \(rtol 1e-06, atol 0.2\), min:1.0, max: 1.0, mean: 1.0, var: 0.0.*"
477+ r"t 1: differing pixels: 20/20 \(100.0%\), bbox \(\(4, 5\), \(7, 9\)\) - 100.0% of the area.*"
478+ r"t 2: value difference exceeds tolerance \(rtol 1e-06, atol 0.2\), min:1.0, max: 1.0, mean: 1.0, var: 0.0.*"
479+ r"t 2: differing pixels: 20/20 \(100.0%\), bbox \(\(4, 5\), \(7, 9\)\) - 100.0% of the area"
480+ ):
481+ assert_job_results_allclose (actual = actual_dir , expected = expected_dir , tmp_path = tmp_path , atol = 0.2 )
482+
418483 def test_allclose_minimal_xy_different_small_area (self , tmp_path , actual_dir , expected_dir ):
419484 expected_ds = xarray .Dataset (
420485 {
0 commit comments