@@ -1345,10 +1345,13 @@ def autocyclic(self, key=None, coord=None, verbose=None, config={}):
1345
1345
# Don't do anything
1346
1346
return
1347
1347
1348
+ dry_run = config .get ("dry_run" )
1349
+
1348
1350
if "cyclic" in config :
1349
1351
if not config ["cyclic" ]:
1350
- if not noop :
1352
+ if not dry_run :
1351
1353
self .cyclic (key , iscyclic = False , config = config )
1354
+
1352
1355
return False
1353
1356
else :
1354
1357
period = coord .period ()
@@ -1357,23 +1360,45 @@ def autocyclic(self, key=None, coord=None, verbose=None, config={}):
1357
1360
else :
1358
1361
period = config .get ("period" )
1359
1362
1360
- self .cyclic (key , iscyclic = True , period = period , config = config )
1363
+ if not dry_run :
1364
+ self .cyclic (
1365
+ key , iscyclic = True , period = period , config = config
1366
+ )
1367
+
1361
1368
return True
1362
1369
1370
+ # if axis is not None:
1371
+ # if coord is not None:
1372
+ # raise ValueError("TODO")
1373
+ #
1374
+ # key, coord = self.dimension_coordinate(
1375
+ # filter_by_axis=(axis,), item=True, default=(None, None)
1376
+ # )
1377
+ # if coord is None:
1378
+ # if not dry_run:
1379
+ # self.cyclic(key, iscyclic=False, config=config)
1380
+ #
1381
+ # return False
1382
+
1363
1383
if coord is None :
1364
1384
key , coord = self .dimension_coordinate (
1365
1385
"X" , item = True , default = (None , None )
1366
1386
)
1367
1387
if coord is None :
1388
+ if not dry_run :
1389
+ self .cyclic (key , iscyclic = False , config = config )
1390
+
1368
1391
return False
1369
1392
elif "X" in config :
1370
1393
if not config ["X" ]:
1371
- if not noop :
1394
+ if not dry_run :
1372
1395
self .cyclic (key , iscyclic = False , config = config )
1396
+
1373
1397
return False
1374
1398
elif not coord .X :
1375
- if not noop :
1399
+ if not dry_run :
1376
1400
self .cyclic (key , iscyclic = False , config = config )
1401
+
1377
1402
return False
1378
1403
1379
1404
bounds_range = config .get ("bounds_range" )
@@ -1382,14 +1407,16 @@ def autocyclic(self, key=None, coord=None, verbose=None, config={}):
1382
1407
else :
1383
1408
bounds = coord .get_bounds (None )
1384
1409
if bounds is None :
1385
- if not noop :
1410
+ if not dry_run :
1386
1411
self .cyclic (key , iscyclic = False , config = config )
1412
+
1387
1413
return False
1388
1414
1389
1415
data = bounds .get_data (None , _fill_value = False )
1390
1416
if data is None :
1391
- if not noop :
1417
+ if not dry_run :
1392
1418
self .cyclic (key , iscyclic = False , config = config )
1419
+
1393
1420
return False
1394
1421
1395
1422
bounds_units = bounds .Units
@@ -1411,7 +1438,9 @@ def autocyclic(self, key=None, coord=None, verbose=None, config={}):
1411
1438
elif bounds_units .equivalent (_units_degrees ):
1412
1439
period = Data (360.0 , units = "degrees" )
1413
1440
else :
1414
- self .cyclic (key , iscyclic = False , config = config )
1441
+ if not dry_run :
1442
+ self .cyclic (key , iscyclic = False , config = config )
1443
+
1415
1444
return False
1416
1445
1417
1446
period .Units = bounds_units
@@ -1422,14 +1451,16 @@ def autocyclic(self, key=None, coord=None, verbose=None, config={}):
1422
1451
bounds_range = None
1423
1452
1424
1453
if bounds_range is None or bounds_range != period :
1425
- if not noop :
1454
+ if not dry_run :
1426
1455
self .cyclic (key , iscyclic = False , config = config )
1456
+
1427
1457
return False
1428
1458
1429
1459
config = config .copy ()
1430
1460
config ["axis" ] = self .get_data_axes (key , default = (None ,))[0 ]
1431
1461
1432
- self .cyclic (key , iscyclic = True , period = period , config = config )
1462
+ if not dry_run :
1463
+ self .cyclic (key , iscyclic = True , period = period , config = config )
1433
1464
1434
1465
return True
1435
1466
@@ -1885,6 +1916,7 @@ def cyclic(
1885
1916
coordinates, otherwise it is assumed to have the same
1886
1917
units as the dimension coordinates.
1887
1918
1919
+
1888
1920
config: `dict`, optional
1889
1921
Additional parameters for optimising the
1890
1922
operation. See the code for details.
@@ -1923,7 +1955,15 @@ def cyclic(
1923
1955
cyclic = self ._cyclic
1924
1956
1925
1957
if not identity and not filter_kwargs :
1926
- return cyclic .copy ()
1958
+ cyclic = cyclic .copy ()
1959
+ if (
1960
+ len (cyclic ) < len (self .domain_axes (todict = True ))
1961
+ and self .autocyclic ()
1962
+ ):
1963
+ cyclic = cyclic .update (self ._cyclic )
1964
+ self ._cyclic = cyclic
1965
+
1966
+ return cyclic
1927
1967
1928
1968
axis = config .get ("axis" )
1929
1969
if axis is None :
@@ -2251,6 +2291,8 @@ def get_coordinate_reference(
2251
2291
def iscyclic (self , * identity , ** filter_kwargs ):
2252
2292
"""Returns True if the given axis is cyclic.
2253
2293
2294
+ If
2295
+
2254
2296
{{unique construct}}
2255
2297
2256
2298
.. versionadded:: 1.0
0 commit comments