@@ -479,3 +479,64 @@ def test_add_3rd_axis_name(yt_geom):
479479
480480 with pytest .raises (ValueError , match = "Unsupported geometry type" ):
481481 _ = xr2yt ._add_3rd_axis_name ("bad_geometry" , expected [:- 1 ])
482+
483+
484+ def _get_pixelized_slice (yt_ds ):
485+ slc = yt_ds .slice (
486+ yt_ds .coordinates .axis_id ["depth" ],
487+ yt_ds .domain_center [yt_ds .coordinates .axis_id ["depth" ]],
488+ center = yt_ds .domain_center ,
489+ )
490+ vals = yt_ds .coordinates .pixelize (
491+ 0 ,
492+ slc ,
493+ ("stream" , "test_field" ),
494+ yt_ds .arr ([1 , 359 , - 89 , 89 ], "code_length" ),
495+ (400 , 400 ),
496+ )
497+ return slc , vals
498+
499+
500+ def _get_ds_for_reverse_tests (stretched , use_callable , chunksizes ):
501+ ds = construct_minimal_ds (
502+ min_x = 1 ,
503+ max_x = 359 ,
504+ min_z = 50 ,
505+ max_z = 650 ,
506+ min_y = 89 ,
507+ max_y = - 89 ,
508+ n_x = 50 ,
509+ n_y = 100 ,
510+ n_z = 30 ,
511+ z_stretched = stretched ,
512+ npseed = True ,
513+ )
514+ yt_ds = ds .yt .load_grid (use_callable = use_callable , chunksizes = chunksizes )
515+ return yt_ds
516+
517+
518+ @pytest .mark .parametrize (
519+ "stretched,use_callable,chunksizes" ,
520+ [
521+ (True , False , None ),
522+ (False , False , None ),
523+ (False , True , None ),
524+ (False , True , 20 ),
525+ (False , False , 20 ),
526+ ],
527+ )
528+ def test_reversed_axis (stretched , use_callable , chunksizes ):
529+ # tests for when the incoming data is not positive-monotonic
530+
531+ yt_ds = _get_ds_for_reverse_tests (stretched , use_callable , chunksizes )
532+
533+ if stretched :
534+ grid_obj = yt_ds .index .grids [0 ]
535+ ax_id = yt_ds .coordinates .axis_id ["latitude" ]
536+ assert np .all (grid_obj .cell_widths [ax_id ] > 0 )
537+
538+ slc , vals = _get_pixelized_slice (yt_ds )
539+
540+ pdy_lats = slc ._generate_container_field ("pdy" )
541+ assert np .all (pdy_lats > 0 )
542+ assert np .all (np .isfinite (vals ))
0 commit comments