8
8
9
9
import numpy as np
10
10
import pytest
11
+ from packaging .version import Version
11
12
12
13
import xarray as xr
13
14
from xarray .backends .api import open_datatree , open_groups
@@ -494,7 +495,15 @@ def test_inherited_coords(self, url=simplegroup_datatree_url) -> None:
494
495
│ Temperature (time, Z, Y, X) float32 ...
495
496
| Salinity (time, Z, Y, X) float32 ...
496
497
"""
497
- tree = open_datatree (url , engine = self .engine )
498
+ import pydap
499
+ from requests_cache import CachedSession
500
+
501
+ _version_ = Version (pydap .__version__ )
502
+
503
+ session = CachedSession ()
504
+ session .cache .clear ()
505
+
506
+ tree = open_datatree (url , engine = self .engine , session = session )
498
507
assert set (tree .dims ) == {"time" , "Z" , "nv" }
499
508
assert tree ["/SimpleGroup" ].coords ["time" ].dims == ("time" ,)
500
509
assert tree ["/SimpleGroup" ].coords ["Z" ].dims == ("Z" ,)
@@ -505,6 +514,19 @@ def test_inherited_coords(self, url=simplegroup_datatree_url) -> None:
505
514
list (expected .dims ) + ["Z" , "nv" ]
506
515
)
507
516
517
+ # group (including root). So in this case 3. In the future there
518
+ # should a only be 2 downloads (all dimensions should be downloaded)
519
+ # within single
520
+
521
+ if _version_ > Version ("3.5.5" ):
522
+ # Total downloads are: 1 dmr, + 1 dap url per Group | root.
523
+ # since there is a group then 2 dap url. In the future there
524
+ # should only be 1 dap url downloaded.
525
+ assert len (session .cache .urls ()) == 3
526
+ else :
527
+ # 1 dmr + 1 dap url per dimension (total there are 4 dimension arrays)
528
+ assert len (session .cache .urls ()) == 5
529
+
508
530
def test_open_groups_to_dict (self , url = all_aligned_child_nodes_url ) -> None :
509
531
aligned_dict_of_datasets = open_groups (url , engine = self .engine )
510
532
aligned_dt = DataTree .from_dict (aligned_dict_of_datasets )
0 commit comments