@@ -537,28 +537,23 @@ def test_reversed_axis(stretched, use_callable, chunksizes):
537537 assert np .all (np .isfinite (vals ))
538538
539539
540- def _invalid_nc4_windows ():
541- import sys
542-
543- import netCDF4
544-
545- nc4_v = netCDF4 .__version__
546- return "1.7.1" in nc4_v and sys .platform .startswith ("win" )
547-
548-
549540def test_cf_xarray_disambiguation ():
550541
551- if _invalid_nc4_windows ():
552- # https://github.com/Unidata/netcdf4-python/issues/1373
553- # https://github.com/data-exp-lab/yt_xarray/pull/99
554- pytest .skip ("Known nc4, windows endian issue." )
542+ # using dim names based on xr.tutorial.open_dataset("air_temperature")
543+ clist = ["lon" , "lat" , "time" ]
544+ ds = construct_minimal_ds (
545+ x_name = clist [0 ],
546+ y_name = clist [1 ],
547+ z_name = clist [2 ],
548+ )
549+ # now populate the .cf.standard_names dict
550+ ds = ds .cf .guess_coord_axis ()
555551
556- airds = xr .tutorial .open_dataset ("air_temperature" )
557552 # run the whole selection (will internally run coord disambiguation)
558553 sel = xr2yt .Selection (
559- airds , fields = ["air " ], sel_dict = {"time" : 0 }, sel_dict_type = "isel"
554+ ds , fields = ["test_field " ], sel_dict = {"time" : 0 }, sel_dict_type = "isel"
560555 )
561- xr_da = airds . air
556+ xr_da = ds . test_field
562557 selected_names = []
563558 for c in sel .selected_coords :
564559 selected_names .append (xr2yt ._cf_xr_coord_disamb (c , xr_da )[0 ])
@@ -568,22 +563,25 @@ def test_cf_xarray_disambiguation():
568563
569564
570565def test_missing_cfxarray (monkeypatch ):
571- if _invalid_nc4_windows ():
572- # https://github.com/Unidata/netcdf4-python/issues/1373
573- # https://github.com/data-exp-lab/yt_xarray/pull/99
574- pytest . skip ( "Known nc4, windows endian issue." )
575-
576- airds = xr . tutorial . open_dataset ( "air_temperature" )
566+ clist = [ "latitude" , "longitude" , "time" ]
567+ ds = construct_minimal_ds (
568+ x_name = clist [ 0 ],
569+ y_name = clist [ 1 ],
570+ z_name = clist [ 2 ],
571+ )
577572
578573 def _bad_import (name , globals = None , locals = None , fromlist = (), level = 0 ):
579574 raise ImportError
580575
581- xr_da = airds . air
576+ xr_da = ds . test_field
582577 clist = list (xr_da .dims )
583578 with monkeypatch .context () as m :
584579 m .setattr (builtins , "__import__" , _bad_import )
585- with pytest .raises (ValueError , match = f"{ clist [0 ]} is not" ):
586580
581+ _ , cf_xarray_exists = xr2yt ._cf_xr_coord_disamb (clist [0 ], xr_da )
582+ assert cf_xarray_exists is False
583+
584+ with pytest .raises (ValueError , match = f"{ clist [0 ]} is not" ):
587585 _ = xr2yt ._convert_to_yt_internal_coords (clist , xr_da )
588586
589587
0 commit comments