2121# SOFTWARE.
2222
2323"""
24- .. _ref_operator_specification:
25-
26- Operator Specification
24+ Operator Specification.
2725
2826The OperatorSpecification Provides a documentation for each Operator
2927"""
4341
4442
4543class PinSpecification :
46- """Documents an input or output pin of an Operator
44+ """Documents an input or output pin of an Operator.
4745
4846 Parameters
4947 ----------
@@ -99,7 +97,8 @@ def __init__(
9997
10098 @property
10199 def type_names (self ) -> list [str ]:
102- """
100+ """Return the list of accepted types.
101+
103102 Returns
104103 -------
105104 list[str], list[type]
@@ -144,6 +143,7 @@ def _get_copy(other, changed_types) -> PinSpecification:
144143 )
145144
146145 def __repr__ (self ):
146+ """Provide more detail in the representation of the instance."""
147147 return "{class_name}({params})" .format (
148148 class_name = self .__class__ .__name__ ,
149149 params = ", " .join (
@@ -154,11 +154,13 @@ def __repr__(self):
154154 )
155155
156156 def __eq__ (self , other ):
157+ """One instance is equal to the other if their string representation is the same."""
157158 return str (self ) == str (other )
158159
159160
160161class ConfigSpecification (dict ):
161- """Dictionary of the available configuration options and their specification
162+ """Dictionary of the available configuration options and their specification.
163+
162164 (:class:`ansys.dpf.core.operator_specification.ConfigOptionSpec`)
163165 """
164166
@@ -167,8 +169,9 @@ def __init__(self, *arg, **kw):
167169
168170
169171class ConfigOptionSpec :
170- """Documentation of a configuration option available for a given
171- Operator (:class:`ansys.dpf.core.Operator`)
172+ """Documentation of a configuration option available for a given Operator.
173+
174+ (:class:`ansys.dpf.core.Operator`)
172175
173176 Attributes
174177 ----------
@@ -207,6 +210,7 @@ def __init__(self, name: str, type_names: list, default_value_str: str, document
207210 self .document = document
208211
209212 def __repr__ (self ):
213+ """Provide more detail in the representation of the instance."""
210214 return "{class_name}({params})" .format (
211215 class_name = self .__class__ .__name__ ,
212216 params = ", " .join (
@@ -217,25 +221,29 @@ def __repr__(self):
217221
218222
219223class SpecificationBase :
224+ """Interface description for the specification base class."""
225+
220226 @property
221227 @abc .abstractmethod
222228 def description (self ) -> Union [str , None ]:
229+ """To be implemented in the subclasses."""
223230 pass
224231
225232 @property
226233 @abc .abstractmethod
227234 def inputs (self ) -> dict :
235+ """To be implemented in the subclasses."""
228236 pass
229237
230238 @property
231239 @abc .abstractmethod
232240 def outputs (self ) -> dict :
241+ """To be implemented in the subclasses."""
233242 pass
234243
235244
236245class Specification (SpecificationBase ):
237- """Documents an Operator with its description (what the Operator does),
238- its inputs and outputs and some properties.
246+ """Documents an Operator with its description (what the Operator does), its inputs and outputs and some properties.
239247
240248 Examples
241249 --------
@@ -306,11 +314,14 @@ def __init__(
306314 self ._config_specification = None
307315
308316 def __str__ (self ):
317+ """Provide more details in the string representation of the instance."""
309318 return "Description:\n " + str (self .description ) + "\n Properties:\n " + str (self .properties )
310319
311320 @property
312321 def properties (self ) -> dict :
313- """Some additional properties of the Operator, like the category, the exposure,
322+ """Additional properties of the Operator.
323+
324+ Some additional properties of the Operator, like the category, the exposure,
314325 the scripting and user names, and the plugin
315326
316327 Examples
@@ -338,7 +349,7 @@ def properties(self) -> dict:
338349
339350 @property
340351 def description (self ) -> str :
341- """Returns a description of the operation applied by the Operator
352+ """Returns a description of the operation applied by the Operator.
342353
343354 Returns
344355 -------
@@ -357,7 +368,7 @@ def description(self) -> str:
357368
358369 @property
359370 def inputs (self ) -> dict :
360- """Returns a dictionary mapping the input pin numbers to their ``PinSpecification``
371+ """Returns a dictionary mapping the input pin numbers to their ``PinSpecification``.
361372
362373 Returns
363374 -------
@@ -380,7 +391,7 @@ def inputs(self) -> dict:
380391
381392 @property
382393 def outputs (self ) -> dict :
383- """Returns a dictionary mapping the output pin numbers to their ``PinSpecification``
394+ """Returns a dictionary mapping the output pin numbers to their ``PinSpecification``.
384395
385396 Returns
386397 -------
@@ -441,7 +452,7 @@ def _fill_pins(self, binput, to_fill):
441452
442453 @property
443454 def config_specification (self ) -> ConfigSpecification :
444- """Documents the available configuration options supported by the Operator
455+ """Documents the available configuration options supported by the Operator.
445456
446457 Returns
447458 -------
@@ -471,6 +482,8 @@ def config_specification(self) -> ConfigSpecification:
471482
472483
473484class CustomConfigOptionSpec (ConfigOptionSpec ):
485+ """Custom documentation of a configuration option available for a given operator."""
486+
474487 def __init__ (self , option_name : str , default_value , document : str ):
475488 type_names = [mapping_types .map_types_to_cpp [type (default_value ).__name__ ]]
476489 super ().__init__ (
@@ -482,12 +495,16 @@ def __init__(self, option_name: str, default_value, document: str):
482495
483496
484497class Exposures :
498+ """Exposures class."""
499+
485500 private = "private"
486501 public = "public"
487502 hidden = "hidden"
488503
489504
490505class Categories :
506+ """Categories class."""
507+
491508 result = "result"
492509 math = "math"
493510 mesh = "mesh"
@@ -558,26 +575,77 @@ def __init__(
558575 )
559576
560577 def __repr__ (self ):
578+ """
579+ Return a string representation of the SpecificationProperties instance.
580+
581+ Returns
582+ -------
583+ str
584+ A string representation of the instance, including all attributes
585+ and their values.
586+ """
561587 keys = sorted (self .__dict__ )
562588 items = ("{}={!r}" .format (k , self .__dict__ [k ]) for k in keys )
563589 return "{}({})" .format (type (self ).__name__ , ", " .join (items ))
564590
565591 def __setitem__ (self , key , value ):
592+ """
593+ Set the value of a specified attribute.
594+
595+ If a specification is defined, the value is also updated in the
596+ operator specification.
597+
598+ Parameters
599+ ----------
600+ key : str
601+ The name of the attribute to set.
602+ value : any
603+ The value to assign to the attribute.
604+ """
566605 if self ._spec is not None :
567606 if value is not None :
568607 self ._spec ._api .operator_specification_set_property (self ._spec , key , value )
569608 self ._spec ._properties = None
570609 setattr (self , key , value )
571610
572611 def __getitem__ (self , item : str ):
612+ """
613+ Get the value of a specified attribute.
614+
615+ Parameters
616+ ----------
617+ item : str
618+ The name of the attribute to retrieve.
619+
620+ Returns
621+ -------
622+ any
623+ The value of the specified attribute.
624+ """
573625 return getattr (self , item )
574626
575627 def __eq__ (self , other ):
628+ """
629+ Check if two SpecificationProperties instances are equal.
630+
631+ Parameters
632+ ----------
633+ other : SpecificationProperties
634+ The other instance to compare against.
635+
636+ Returns
637+ -------
638+ bool
639+ True if the two instances have the same attributes and values,
640+ False otherwise.
641+ """
576642 return self .__dict__ == other .__dict__
577643
578644
579645class CustomSpecification (Specification ):
580- """Allows to create an Operator Specification with its description (what the Operator does),
646+ """Create an operator specification with its description.
647+
648+ Allows to create an Operator Specification with its description (what the Operator does),
581649 its inputs and outputs and some properties.
582650 Inherits from Specification (which has only getters) to implement setters.
583651
@@ -631,7 +699,7 @@ def __init__(self, description=None, server=None):
631699 @property
632700 @version_requires ("4.0" )
633701 def description (self ) -> str :
634- """Description of the operation applied by the Operator"""
702+ """Description of the operation applied by the Operator. """
635703 return super ().description
636704
637705 @description .setter
@@ -641,7 +709,7 @@ def description(self, value) -> str:
641709 @property
642710 @version_requires ("4.0" )
643711 def inputs (self ) -> dict :
644- """Dictionary mapping the input pin numbers to their ``PinSpecification``
712+ """Dictionary mapping the input pin numbers to their ``PinSpecification``.
645713
646714 Returns
647715 -------
@@ -684,7 +752,7 @@ def inputs(self, val: dict):
684752 @property
685753 @version_requires ("4.0" )
686754 def outputs (self ) -> dict :
687- """Returns a dictionary mapping the output pin numbers to their ``PinSpecification``
755+ """Returns a dictionary mapping the output pin numbers to their ``PinSpecification``.
688756
689757 Returns
690758 -------
@@ -727,7 +795,7 @@ def outputs(self, val: dict):
727795 @property
728796 @version_requires ("4.0" )
729797 def config_specification (self ) -> ConfigSpecification :
730- """Documents the available configuration options supported by the Operator
798+ """Documents the available configuration options supported by the Operator.
731799
732800 Returns
733801 -------
@@ -767,7 +835,9 @@ def config_specification(self, val: list):
767835 @property
768836 @version_requires ("4.0" )
769837 def properties (self ) -> SpecificationProperties :
770- """Returns some additional properties of the Operator, like the category, the exposure,
838+ """Return additional properties of the Operator.
839+
840+ Returns some additional properties of the Operator, like the category, the exposure,
771841 the scripting and user names and the plugin
772842 """
773843 return SpecificationProperties (** super ().properties , spec = self )
0 commit comments