@@ -133,14 +133,14 @@ def __init__(
133133 The index values describing a topological relationship. Constructed
134134 of 2 dimensions - the list of 'location elements', and within each:
135135 the indices of the 'connected elements' it relates to.
136- Use a :class:`numpy.ma.core.MaskedArray` if :attr:`location_element `
137- lengths vary - mask unused index 'slots' within each
138- :attr:`location_element` . Use a :class:`dask.array.Array` to keep
136+ Use a :class:`numpy.ma.core.MaskedArray` if :attr:`location `
137+ element lengths vary - mask unused index 'slots' within each
138+ :attr:`location` element . Use a :class:`dask.array.Array` to keep
139139 indices 'lazy'.
140140 * cf_role (str):
141141 Denotes the topological relationship that this connectivity
142- describes. Made up of this array's 'location element ', and the
143- 'connected element' indexed by the array.
142+ describes. Made up of this array's 'location', and the 'connected'
143+ that is indexed by the array.
144144 See :attr:`UGRID_CF_ROLES` for valid arguments.
145145
146146 Kwargs:
@@ -166,10 +166,10 @@ def __init__(
166166 for Fortran and legacy NetCDF files).
167167 * location_axis (int):
168168 Either ``0`` or ``1``. Default is ``0``. Denotes which axis
169- of :attr:`indices` varies over the :attr:`location_element` \\ s (the
170- alternate axis therefore varying within individual
171- :attr:`location_element` \\ s ). (This parameter allows support for fastest varying index being
172- either first or last).
169+ of :attr:`indices` varies over the :attr:`location` elements (the
170+ alternate axis therefore varying within individual :attr:`location`
171+ elements ). (This parameter allows support for fastest varying index
172+ being either first or last).
173173 E.g. for ``face_node_connectivity``, for 10 faces:
174174 ``indices.shape[location_axis] = 10``.
175175
@@ -196,9 +196,7 @@ def validate_arg_vs_list(arg_name, arg, valid_list):
196196 self ._metadata_manager .cf_role = cf_role
197197
198198 self ._connected_axis = 1 - location_axis
199- self ._location_element , self ._connected_element = cf_role .split ("_" )[
200- :2
201- ]
199+ self ._location , self ._connected = cf_role .split ("_" )[:2 ]
202200
203201 super ().__init__ (
204202 values = indices ,
@@ -285,25 +283,25 @@ def cf_role(self):
285283 return self ._metadata_manager .cf_role
286284
287285 @property
288- def location_element (self ):
286+ def location (self ):
289287 """
290288 Derived from the connectivity's :attr:`cf_role` - the first part, e.g.
291289 ``face`` in ``face_node_connectivity``. Refers to the elements
292290 listed by the :attr:`location_axis` of the connectivity's :attr:`indices`
293291 array.
294292
295293 """
296- return self ._location_element
294+ return self ._location
297295
298296 @property
299- def connected_element (self ):
297+ def connected (self ):
300298 """
301299 Derived from the connectivity's :attr:`cf_role` - the second part, e.g.
302300 ``node`` in ``face_node_connectivity``. Refers to the elements indexed
303301 by the values in the connectivity's :attr:`indices` array.
304302
305303 """
306- return self ._connected_element
304+ return self ._connected
307305
308306 @property
309307 def start_index (self ):
@@ -321,7 +319,7 @@ def start_index(self):
321319 def location_axis (self ):
322320 """
323321 The axis of the connectivity's :attr:`indices` array that varies
324- over the connectivity's :attr:`location_element` \\ s . Either ``0`` or ``1``.
322+ over the connectivity's :attr:`location` elements . Either ``0`` or ``1``.
325323 **Read-only** - validity of :attr:`indices` is dependent on
326324 :attr:`location_axis`. Use :meth:`transpose` to create a new, transposed
327325 :class:`Connectivity` if a different :attr:`location_axis` is needed.
@@ -335,7 +333,7 @@ def connected_axis(self):
335333 Derived as the alternate value of :attr:`location_axis` - each must equal
336334 either ``0`` or ``1``.
337335 The axis of the connectivity's :attr:`indices` array that varies
338- within the connectivity's individual :attr:`location_element` \\ s .
336+ within the connectivity's individual :attr:`location` elements .
339337
340338 """
341339 return self ._connected_axis
@@ -345,8 +343,8 @@ def indices(self):
345343 """
346344 The index values describing the topological relationship of the
347345 connectivity, as a NumPy array. Masked points indicate a
348- :attr:`location_element` shorter than the longest :attr:`location_element `
349- described in this array - unused index 'slots' are masked.
346+ :attr:`location` element shorter than the longest :attr:`location `
347+ element described in this array - unused index 'slots' are masked.
350348 **Read-only** - index values are only meaningful when combined with
351349 an appropriate :attr:`cf_role`, :attr:`start_index` and
352350 :attr:`location_axis`. A new :class:`Connectivity` must therefore be
@@ -394,8 +392,8 @@ def indices_by_location(self, indices=None):
394392 def _validate_indices (self , indices , shapes_only = False ):
395393 # Use shapes_only=True for a lower resource, less thorough validation
396394 # of indices by just inspecting the array shape instead of inspecting
397- # individual masks. So will not catch individual location_elements being
398- # unacceptably small.
395+ # individual masks. So will not catch individual location elements
396+ # being unacceptably small.
399397
400398 def indices_error (message ):
401399 raise ValueError ("Invalid indices provided. " + message )
@@ -434,14 +432,14 @@ def indices_error(message):
434432 # shapes_only==False is only called manually, i.e. after
435433 # initialisation.
436434 location_lengths = self .lazy_location_lengths ()
437- if self .location_element in ("edge" , "boundary" ):
435+ if self .location in ("edge" , "boundary" ):
438436 if (location_lengths != 2 ).any ().compute ():
439437 len_req_fail = "len=2"
440438 else :
441- if self .location_element == "face" :
439+ if self .location == "face" :
442440 min_size = 3
443- elif self .location_element == "volume" :
444- if self .connected_element == "edge" :
441+ elif self .location == "volume" :
442+ if self .connected == "edge" :
445443 min_size = 6
446444 else :
447445 min_size = 4
@@ -451,15 +449,15 @@ def indices_error(message):
451449 len_req_fail = f"len>={ min_size } "
452450 if len_req_fail :
453451 indices_error (
454- f"Not all location_elements meet requirement: { len_req_fail } - "
452+ f"Not all location elements meet requirement: { len_req_fail } - "
455453 f"needed to describe '{ self .cf_role } ' ."
456454 )
457455
458456 def validate_indices (self ):
459457 """
460458 Perform a thorough validity check of this connectivity's
461459 :attr:`indices`. Includes checking the sizes of individual
462- :attr:`location_element` \\ s (specified using masks on the
460+ :attr:`location` elements (specified using masks on the
463461 :attr:`indices` array) against the :attr:`cf_role`.
464462
465463 Raises a ``ValueError`` if any problems are encountered, otherwise
@@ -565,7 +563,7 @@ def has_lazy_indices(self):
565563 def lazy_location_lengths (self ):
566564 """
567565 Return a lazy array representing the lengths of each
568- :attr:`location_element` in the :attr:`location_axis` of the connectivity's
566+ :attr:`location` element in the :attr:`location_axis` of the connectivity's
569567 :attr:`indices` array, accounting for masks if present.
570568
571569 Accessing this method will never cause the :attr:`indices` values to be
@@ -576,7 +574,7 @@ def lazy_location_lengths(self):
576574 :attr:`indices` have already been loaded.
577575
578576 Returns:
579- A lazy array, representing the lengths of each :attr:`location_element` .
577+ A lazy array, representing the lengths of each :attr:`location` element .
580578
581579 """
582580 location_mask_counts = da .sum (
@@ -588,11 +586,11 @@ def lazy_location_lengths(self):
588586 def location_lengths (self ):
589587 """
590588 Return a NumPy array representing the lengths of each
591- :attr:`location_element` in the :attr:`location_axis` of the connectivity's
589+ :attr:`location` element in the :attr:`location_axis` of the connectivity's
592590 :attr:`indices` array, accounting for masks if present.
593591
594592 Returns:
595- A NumPy array, representing the lengths of each :attr:`location_element` .
593+ A NumPy array, representing the lengths of each :attr:`location` element .
596594
597595 """
598596 return self .lazy_location_lengths ().compute ()
@@ -2513,17 +2511,13 @@ def add(self, *connectivities):
25132511 # Validate shapes.
25142512 proposed_members = {** self ._members , ** add_dict }
25152513 elements = set (
2516- [
2517- c .location_element
2518- for c in proposed_members .values ()
2519- if c is not None
2520- ]
2514+ [c .location for c in proposed_members .values () if c is not None ]
25212515 )
25222516 for element in elements :
25232517 counts = [
25242518 len (c .indices_by_location (c .lazy_indices ()))
25252519 for c in proposed_members .values ()
2526- if c is not None and c .location_element == element
2520+ if c is not None and c .location == element
25272521 ]
25282522 # Check is list values are identical.
25292523 if not counts .count (counts [0 ]) == len (counts ):
@@ -2591,8 +2585,8 @@ def element_filter(instances, loc_arg, loc_name):
25912585 for instance in instances
25922586 if loc_name
25932587 not in (
2594- instance .location_element ,
2595- instance .connected_element ,
2588+ instance .location ,
2589+ instance .connected ,
25962590 )
25972591 ]
25982592 elif loc_arg is None :
@@ -2602,8 +2596,7 @@ def element_filter(instances, loc_arg, loc_name):
26022596 filtered = [
26032597 instance
26042598 for instance in instances
2605- if loc_name
2606- in (instance .location_element , instance .connected_element )
2599+ if loc_name in (instance .location , instance .connected )
26072600 ]
26082601
26092602 return filtered
0 commit comments