9
9
10
10
import numpy as np
11
11
import pytest
12
+ from packaging .version import Version
12
13
13
14
import xarray as xr
14
15
from xarray import DataTree , load_datatree , open_datatree , open_groups
@@ -633,7 +634,15 @@ def test_inherited_coords(self, url=simplegroup_datatree_url) -> None:
633
634
│ Temperature (time, Z, Y, X) float32 ...
634
635
| Salinity (time, Z, Y, X) float32 ...
635
636
"""
636
- tree = open_datatree (url , engine = self .engine )
637
+ import pydap
638
+ from requests_cache import CachedSession
639
+
640
+ _version_ = Version (pydap .__version__ )
641
+
642
+ session = CachedSession ()
643
+ session .cache .clear ()
644
+
645
+ tree = open_datatree (url , engine = self .engine , session = session )
637
646
assert set (tree .dims ) == {"time" , "Z" , "nv" }
638
647
assert tree ["/SimpleGroup" ].coords ["time" ].dims == ("time" ,)
639
648
assert tree ["/SimpleGroup" ].coords ["Z" ].dims == ("Z" ,)
@@ -644,6 +653,19 @@ def test_inherited_coords(self, url=simplegroup_datatree_url) -> None:
644
653
list (expected .dims ) + ["Z" , "nv" ]
645
654
)
646
655
656
+ # group (including root). So in this case 3. In the future there
657
+ # should a only be 2 downloads (all dimensions should be downloaded)
658
+ # within single
659
+
660
+ if _version_ > Version ("3.5.5" ):
661
+ # Total downloads are: 1 dmr, + 1 dap url per Group | root.
662
+ # since there is a group then 2 dap url. In the future there
663
+ # should only be 1 dap url downloaded.
664
+ assert len (session .cache .urls ()) == 3
665
+ else :
666
+ # 1 dmr + 1 dap url per dimension (total there are 4 dimension arrays)
667
+ assert len (session .cache .urls ()) == 5
668
+
647
669
def test_open_groups_to_dict (self , url = all_aligned_child_nodes_url ) -> None :
648
670
aligned_dict_of_datasets = open_groups (url , engine = self .engine )
649
671
aligned_dt = DataTree .from_dict (aligned_dict_of_datasets )
0 commit comments