@@ -96,9 +96,7 @@ def __create_array(self, array_name: str, element_type: type, elements: list):
9696 elif issubclass (element_type , Element ):
9797 return ElementArray (array_name , elements , self .__use_aggregator )
9898 else :
99- raise PyAMLException (
100- f"Unsupported sliced array for type { str (element_type )} "
101- )
99+ raise PyAMLException (f"Unsupported sliced array for type { str (element_type )} " )
102100
103101 def __eval_field (self , attribute_name : str , element : Element ) -> str :
104102 function_name = "get_" + attribute_name
@@ -109,16 +107,14 @@ def __ensure_compatible_operand(self, other: object) -> "ElementArray":
109107 """Validate the operand used for set-like operations between arrays."""
110108 if not isinstance (other , ElementArray ):
111109 raise TypeError (
112- f"Unsupported operand type(s) for set operation: "
113- f"'{ type (self ).__name__ } ' and '{ type (other ).__name__ } '"
110+ f"Unsupported operand type(s) for set operation: '{ type (self ).__name__ } ' and '{ type (other ).__name__ } '"
114111 )
115112
116113 if len (self ) > 0 and len (other ) > 0 :
117114 if self .get_peer () is not None and other .get_peer () is not None :
118115 if self .get_peer () != other .get_peer ():
119116 raise PyAMLException (
120- f"{ self .__class__ .__name__ } : cannot operate on arrays "
121- "attached to different peers"
117+ f"{ self .__class__ .__name__ } : cannot operate on arrays attached to different peers"
122118 )
123119 return other
124120
@@ -170,9 +166,7 @@ def __is_bool_mask(self, other: object) -> bool:
170166 pass
171167
172168 # --- python sequence of bools (but not a string/bytes) ---
173- if isinstance (other , Sequence ) and not isinstance (
174- other , (str , bytes , bytearray )
175- ):
169+ if isinstance (other , Sequence ) and not isinstance (other , (str , bytes , bytearray )):
176170 # Avoid treating ElementArray as a mask
177171 if isinstance (other , ElementArray ):
178172 return False
@@ -195,8 +189,7 @@ def __and__(self, other: object):
195189 If ``other`` is an ElementArray, the result contains elements
196190 whose names are present in both arrays.
197191
198- Example
199- -------
192+ **Example**
200193
201194 .. code-block:: python
202195
@@ -208,8 +201,8 @@ def __and__(self, other: object):
208201 If ``other`` is a boolean mask (list[bool] or numpy.ndarray of bool),
209202 elements are kept where the mask is True.
210203
211- Example
212- -------
204+ ** Example**
205+
213206 .. code-block:: python
214207
215208 >>> mask = cell1.mask_by_type(Magnet)
@@ -232,8 +225,7 @@ def __and__(self, other: object):
232225 mask = list (other ) # works for list/tuple and numpy arrays
233226 if len (mask ) != len (self ):
234227 raise ValueError (
235- f"{ self .__class__ .__name__ } : mask length ({ len (mask )} ) "
236- f"does not match array length ({ len (self )} )"
228+ f"{ self .__class__ .__name__ } : mask length ({ len (mask )} ) does not match array length ({ len (self )} )"
237229 )
238230 res = [e for e , keep in zip (self , mask , strict = True ) if bool (keep )]
239231 return self .__auto_array (res )
@@ -261,8 +253,7 @@ def __sub__(self, other: object):
261253 If ``other`` is an ElementArray, the result contains elements
262254 whose names are present in ``self`` but not in ``other``.
263255
264- Example
265- -------
256+ **Example**
266257
267258 .. code-block:: python
268259
@@ -275,8 +266,7 @@ def __sub__(self, other: object):
275266 elements are removed where the mask is True.
276267 This is the inverse of ``& mask``.
277268
278- Example
279- -------
269+ **Example**
280270
281271 .. code-block:: python
282272
@@ -300,8 +290,7 @@ def __sub__(self, other: object):
300290 mask = list (other )
301291 if len (mask ) != len (self ):
302292 raise ValueError (
303- f"{ self .__class__ .__name__ } : mask length ({ len (mask )} ) "
304- f"does not match array length ({ len (self )} )"
293+ f"{ self .__class__ .__name__ } : mask length ({ len (mask )} ) does not match array length ({ len (self )} )"
305294 )
306295 res = [e for e , remove in zip (self , mask , strict = True ) if not bool (remove )]
307296 return self .__auto_array (res )
0 commit comments