Skip to content

Commit cb535c4

Browse files
committed
subspace mode -> config
1 parent 3a092e6 commit cb535c4

File tree

5 files changed

+45
-44
lines changed

5 files changed

+45
-44
lines changed

cf/docstring/docstring.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,13 @@
620620
"{{to_size: `int`, optional}}": """to_size: `int`, optional
621621
Pad the axis after so that the new axis has the given
622622
size.""",
623-
# subspace mode options
624-
"{{mode: optional}}": """mode: optional
625-
Specify the mode of operation (``mode``) and a halo to
626-
be added to the subspaced axes (``halo``) with
627-
positional arguments in format ``mode``, or ``halo``,
628-
or ``mode, halo``, or with no positional arguments at
629-
all.
623+
# subspace config options
624+
"{{config: optional}}": """config: optional
625+
Configure the subspace by specifying the mode of
626+
operation (``mode``) and any halo to be added to the
627+
subspaced axes (``halo``), with positional arguments
628+
in the format ``mode``, or ``halo``, or ``mode,
629+
halo``, or with no positional arguments at all.
630630
631631
A mode of operation is given as a `str`, and a halo as
632632
a non-negative `int` (or any object that can be

cf/domain.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ def identities(self):
739739

740740
return out
741741

742-
def indices(self, *mode, **kwargs):
742+
def indices(self, *config, **kwargs):
743743
"""Create indices that define a subspace of the domain
744744
construct.
745745
@@ -789,7 +789,7 @@ def indices(self, *mode, **kwargs):
789789
790790
:Parameters:
791791
792-
{{mode: optional}}
792+
{{config: optional}}
793793
794794
{{subspace valid modes Domain}}
795795
@@ -847,7 +847,7 @@ def indices(self, *mode, **kwargs):
847847
"""
848848
# Get the indices for every domain axis in the domain, without
849849
# any auxiliary masks.
850-
domain_indices = self._indices(mode, None, False, kwargs)
850+
domain_indices = self._indices(config, None, False, kwargs)
851851

852852
return domain_indices["indices"]
853853

@@ -1094,7 +1094,7 @@ def roll(self, axis, shift, inplace=False):
10941094

10951095
return d
10961096

1097-
def subspace(self, *mode, **kwargs):
1097+
def subspace(self, *config, **kwargs):
10981098
"""Create a subspace of the field construct.
10991099
11001100
Creation of a new domain construct which spans a subspace of
@@ -1141,7 +1141,7 @@ def subspace(self, *mode, **kwargs):
11411141
11421142
:Parameters:
11431143
1144-
{{mode: optional}}
1144+
{{config: optional}}
11451145
11461146
{{subspace valid modes Domain}}
11471147
@@ -1186,19 +1186,19 @@ def subspace(self, *mode, **kwargs):
11861186
11871187
"""
11881188
test = False
1189-
if "test" in mode:
1190-
mode = list(mode)
1191-
mode.remove("test")
1189+
if "test" in config:
1190+
config = list(config)
1191+
config.remove("test")
11921192
test = True
11931193

1194-
if not mode and not kwargs:
1194+
if not config and not kwargs:
11951195
if test:
11961196
return True
11971197

11981198
return self.copy()
11991199

12001200
try:
1201-
indices = self.indices(*mode, **kwargs)
1201+
indices = self.indices(*config, **kwargs)
12021202
except ValueError as error:
12031203
if test:
12041204
return False

cf/field.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8809,7 +8809,7 @@ def insert_dimension(
88098809
inplace=inplace,
88108810
)
88118811

8812-
def indices(self, *mode, **kwargs):
8812+
def indices(self, *config, **kwargs):
88138813
"""Create indices that define a subspace of the field construct.
88148814

88158815
The subspace is defined by identifying indices based on the
@@ -8879,7 +8879,7 @@ def indices(self, *mode, **kwargs):
88798879

88808880
:Parameters:
88818881

8882-
{{mode: optional}}
8882+
{{config: optional}}
88838883

88848884
{{subspace valid modes Field}}
88858885

@@ -9006,7 +9006,7 @@ def indices(self, *mode, **kwargs):
90069006
[-- -- -- -- -- -- 270.6 273.0 270.6]]]
90079007

90089008
"""
9009-
if "exact" in mode:
9009+
if "exact" in config:
90109010
_DEPRECATION_ERROR_ARG(
90119011
self,
90129012
"indices",
@@ -9020,7 +9020,7 @@ def indices(self, *mode, **kwargs):
90209020

90219021
# Get the indices for every domain axis in the domain,
90229022
# including any ancillary masks
9023-
domain_indices = self._indices(mode, data_axes, True, kwargs)
9023+
domain_indices = self._indices(config, data_axes, True, kwargs)
90249024

90259025
# Initialise the output indices with any ancillary masks.
90269026
# Ensure that each ancillary mask is broadcastable to the
@@ -13286,7 +13286,7 @@ def subspace(self):
1328613286

1328713287
:Parameters:
1328813288

13289-
{{mode: optional}}
13289+
{{config: optional}}
1329013290

1329113291
{{subspace valid modes Field}}
1329213292

cf/mixin/fielddomain.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def _equivalent_coordinate_references(
203203

204204
return True
205205

206-
def _indices(self, mode, data_axes, ancillary_mask, kwargs):
206+
def _indices(self, config, data_axes, ancillary_mask, kwargs):
207207
"""Create indices that define a subspace of the field or domain
208208
construct.
209209
@@ -217,9 +217,9 @@ def _indices(self, mode, data_axes, ancillary_mask, kwargs):
217217
218218
:Parameters:
219219
220-
mode: `tuple`
220+
config: `tuple`
221221
The mode of operation and the halo size. See the
222-
*mode* parameter of `indices` for details.
222+
*config* parameter of `indices` for details.
223223
224224
data_axes: sequence of `str`, or `None`
225225
The domain axis identifiers of the data axes, or
@@ -255,24 +255,24 @@ def _indices(self, mode, data_axes, ancillary_mask, kwargs):
255255
debug = is_log_level_debug(logger)
256256

257257
# Parse mode and halo
258-
n_mode = len(mode)
259-
if not n_mode:
258+
n_config = len(config)
259+
if not n_config:
260260
mode = None
261261
halo = None
262-
elif n_mode == 1:
262+
elif n_config == 1:
263263
try:
264-
halo = int(mode[0])
264+
halo = int(config[0])
265265
except ValueError:
266-
mode = mode[0]
266+
mode = config[0]
267267
halo = None
268268
else:
269269
mode = None
270-
elif n_mode == 2:
271-
mode, halo = mode
270+
elif n_config == 2:
271+
mode, halo = config
272272
else:
273273
raise ValueError(
274274
"Can't provide more than two positional arguments. "
275-
f"Got: {', '.join(repr(x) for x in mode)}"
275+
f"Got: {', '.join(repr(x) for x in config)}"
276276
)
277277

278278
compress = mode is None or mode == "compress"

cf/subspacefield.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@ class SubspaceField(mixin.Subspace):
8989
9090
:Parameters:
9191
92-
mode: optional
93-
Specify the mode of operation (``mode``) and a halo to be
94-
added to the subspaced axes (``halo``) with positional
95-
arguments in format ``mode``, or ``halo``, or ``mode,
96-
halo``, or with no positional arguments at all.
92+
config: optional
93+
Configure the subspace by specifying the mode of operation
94+
(``mode``) and any halo to be added to the subspaced axes
95+
(``halo``), with positional arguments in the format
96+
``mode``, or ``halo``, or ``mode, halo``, or with no
97+
positional arguments at all.
9798
9899
A mode of operation is given as a `str`, and a halo as a
99100
non-negative `int` (or any object that can be converted to
@@ -201,7 +202,7 @@ class SubspaceField(mixin.Subspace):
201202

202203
__slots__ = []
203204

204-
def __call__(self, *args, **kwargs):
205+
def __call__(self, *config, **kwargs):
205206
"""Create a subspace of a field construct.
206207
207208
Creation of a new field construct which spans a subspace of the
@@ -324,19 +325,19 @@ def __call__(self, *args, **kwargs):
324325
field = self.variable
325326

326327
test = False
327-
if "test" in args:
328-
args = list(args)
329-
args.remove("test")
328+
if "test" in config:
329+
config = list(config)
330+
config.remove("test")
330331
test = True
331332

332-
if not args and not kwargs:
333+
if not config and not kwargs:
333334
if test:
334335
return True
335336

336337
return field.copy()
337338

338339
try:
339-
indices = field.indices(*args, **kwargs)
340+
indices = field.indices(*config, **kwargs)
340341
out = field[indices]
341342
except (ValueError, IndexError) as error:
342343
if test:

0 commit comments

Comments
 (0)