@@ -69,33 +69,118 @@ def show(self, indent=""):
6969 )
7070
7171 def _update_gpu (self , new_gpu ):
72+ """
73+ Propagate new GPU setting to parameter subclasses.
74+
75+ Parameters
76+ ----------
77+ new_gpu : bool
78+ New GPU setting.
79+ """
7280 self ._configuration ["gpu" ] = new_gpu
7381
7482 def _update_ddp (self , new_ddp ):
83+ """
84+ Propagate new DDP setting to parameter subclasses.
85+
86+ Parameters
87+ ----------
88+ new_ddp : bool
89+ New DDP setting.
90+ """
7591 self ._configuration ["ddp" ] = new_ddp
7692
7793 def _update_mpi (self , new_mpi ):
94+ """
95+ Propagate new MPI setting to parameter subclasses.
96+
97+ Parameters
98+ ----------
99+ new_mpi : bool
100+ New MPI setting.
101+ """
78102 self ._configuration ["mpi" ] = new_mpi
79103
80104 def _update_device (self , new_device ):
105+ """
106+ Propagate new device setting to parameter subclasses.
107+
108+ Parameters
109+ ----------
110+ new_device : str
111+ New device setting. Can be "cpu" or "cuda:x", where x is some
112+ integer.
113+ """
81114 self ._configuration ["device" ] = new_device
82115
83116 def _update_openpmd_configuration (self , new_openpmd ):
117+ """
118+ Propagate new openPMD configuration to parameter subclasses.
119+
120+ Parameters
121+ ----------
122+ new_openpmd : dict
123+ New openPMD configuration, which is a dict containing different
124+ settings.
125+ """
84126 self ._configuration ["openpmd_configuration" ] = new_openpmd
85127
86128 def _update_openpmd_granularity (self , new_granularity ):
129+ """
130+ Propagate new openPMD granularity to parameter subclasses.
131+
132+ Parameters
133+ ----------
134+ new_granularity : int
135+ New openPMD granularity.
136+ """
87137 self ._configuration ["openpmd_granularity" ] = new_granularity
88138
89139 def _update_lammps (self , new_lammps ):
140+ """
141+ Propagate new LAMMPS setting to parameter subclasses.
142+
143+ Parameters
144+ ----------
145+ new_lammps : bool
146+ New LAMMPS setting. Setting here means whether LAMMPS
147+ will be used.
148+ """
90149 self ._configuration ["lammps" ] = new_lammps
91150
92151 def _update_atomic_density_formula (self , new_atomic_density_formula ):
152+ """
153+ Propagate new atomic density formula setting to parameter subclasses.
154+
155+ Parameters
156+ ----------
157+ new_atomic_density_formula : bool
158+ New atomic density formula setting, i.e., whether to use this
159+ option.
160+ """
93161 self ._configuration ["atomic_density_formula" ] = (
94162 new_atomic_density_formula
95163 )
96164
97165 @staticmethod
98166 def _member_to_json (member ):
167+ """
168+ Convert a member to a JSON serializable object.
169+
170+ For a class that inherits from JSONSerializable, this will call the
171+ to_json method of that class. Otherwise, it will return the member
172+ itself (for basic data types)
173+
174+ Parameters
175+ ----------
176+ member : any, JSONSerializable
177+ Member to be converted to JSON serializable object.
178+
179+ Returns
180+ -------
181+ json_serializable : any
182+ JSON serializable object.
183+ """
99184 if isinstance (member , (int , float , type (None ), str )):
100185 return member
101186 else :
@@ -147,6 +232,24 @@ def to_json(self):
147232
148233 @staticmethod
149234 def _json_to_member (json_value ):
235+ """
236+ Convert a JSON dictionary to a member.
237+
238+ This function is used to convert a JSON dictionary to a member of this
239+ class. If the member is a JSONSerializable object, it will call the
240+ from_json method of that class. Otherwise, it will return the member
241+ directly (for basic data types)
242+
243+ Parameters
244+ ----------
245+ json_value : any
246+ JSON value/dictionary entry to be converted to a member.
247+
248+ Returns
249+ -------
250+ member : any
251+ Loaded member of this class.
252+ """
150253 if isinstance (json_value , (int , float , type (None ), str )):
151254 return json_value
152255 else :
@@ -181,7 +284,6 @@ def from_json(cls, json_dict):
181284 -------
182285 deserialized_object : JSONSerializable
183286 The object as read from the JSON file.
184-
185287 """
186288 deserialized_object = cls ()
187289 for key in json_dict :
@@ -474,6 +576,16 @@ def bispectrum_switchflag(self, value):
474576 self ._snap_switchflag = 1
475577
476578 def _update_mpi (self , new_mpi ):
579+ """
580+ Propagate new MPI setting to parameter subclasses.
581+
582+ Also deletes old inputs files that are no longer valid.
583+
584+ Parameters
585+ ----------
586+ new_mpi : bool
587+ New MPI setting.
588+ """
477589 self ._configuration ["mpi" ] = new_mpi
478590
479591 # There may have been a serial or parallel run before that is now
@@ -856,6 +968,16 @@ def __init__(self):
856968 self .profiler_range = [1000 , 2000 ]
857969
858970 def _update_ddp (self , new_ddp ):
971+ """
972+ Propagate new DDP setting to parameter subclasses.
973+
974+ Also ensures only metrics are used which work with DDP.
975+
976+ Parameters
977+ ----------
978+ new_ddp : bool
979+ New DDP setting.
980+ """
859981 super (ParametersRunning , self )._update_ddp (new_ddp )
860982 self .during_training_metric = self .during_training_metric
861983 self .after_training_metric = self .after_training_metric
0 commit comments