@@ -46,7 +46,7 @@ class BasePDFGenerator(ProfileGenerator):
4646 the PDF.
4747 _phase
4848 The structure ParameterSet used to calculate the profile.
49- stru
49+ structure
5050 The structure objected adapted by _phase.
5151 _lastr
5252 The last value of r over which the PDF was calculated. This is
@@ -72,15 +72,15 @@ class BasePDFGenerator(ProfileGenerator):
7272
7373 Usable Metadata
7474 ---------------
75- stype
75+ stype : str
7676 The scattering type "X" for x-ray, "N" for neutron (see
77- 'setScatteringType ').
77+ 'set_scattering_type ').
7878 qmax
7979 The maximum scattering vector used to generate the PDF (see
80- setQmax ).
80+ set_qmax ).
8181 qmin
8282 The minimum scattering vector used to generate the PDF (see
83- setQmin ).
83+ set_qmin ).
8484 scale
8585 See Managed Parameters.
8686 delta1
@@ -98,7 +98,7 @@ def __init__(self, name="pdf"):
9898 ProfileGenerator .__init__ (self , name )
9999
100100 self ._phase = None
101- self .stru = None
101+ self .structure = None
102102 self .meta = {}
103103 self ._lastr = numpy .empty (0 )
104104 self ._calc = None
@@ -109,7 +109,7 @@ def __init__(self, name="pdf"):
109109
110110 _parnames = ["delta1" , "delta2" , "qbroad" , "scale" , "qdamp" ]
111111
112- def _setCalculator (self , calc ):
112+ def _set_calculator (self , calc ):
113113 """Set the SrReal calculator instance.
114114
115115 Setting the calculator creates Parameters from the variable
@@ -118,13 +118,13 @@ def _setCalculator(self, calc):
118118 self ._calc = calc
119119 for pname in self .__class__ ._parnames :
120120 self .addParameter (ParameterAdapter (pname , self ._calc , attr = pname ))
121- self .processMetaData ()
121+ self ._process_metadata ()
122122 return
123123
124124 def parallel (self , ncpu , mapfunc = None ):
125125 """Run calculation in parallel.
126126
127- Attributes
127+ Parameters
128128 ----------
129129 ncpu
130130 Number of parallel processes. Revert to serial mode when 1.
@@ -155,130 +155,159 @@ def parallel(self, ncpu, mapfunc=None):
155155 self ._calc = createParallelCalculator (calc_serial , ncpu , mapfunc )
156156 return
157157
158- def processMetaData (self ):
158+ def _process_metadata (self ):
159159 """Process the metadata once it gets set."""
160- ProfileGenerator .processMetaData (self )
160+ ProfileGenerator ._process_metadata (self )
161161
162162 stype = self .meta .get ("stype" )
163163 if stype is not None :
164- self .setScatteringType (stype )
164+ self .set_scattering_type (stype )
165165
166166 qmax = self .meta .get ("qmax" )
167167 if qmax is not None :
168- self .setQmax (qmax )
168+ self .set_qmax (qmax )
169169
170170 qmin = self .meta .get ("qmin" )
171171 if qmin is not None :
172- self .setQmin (qmin )
172+ self .set_qmin (qmin )
173173
174174 for name in self .__class__ ._parnames :
175175 val = self .meta .get (name )
176176 if val is not None :
177177 par = self .get (name )
178- par .setValue (val )
178+ par .set_value (val )
179179
180180 return
181181
182- def setScatteringType (self , stype = "X" ):
182+ def set_scattering_type (self , stype = "X" ):
183183 """Set the scattering type.
184184
185- Attributes
185+ Parameters
186186 ----------
187- stype
188- "X" for x-ray, "N" for neutron, "E" for electrons,
187+ stype : str, optional
188+ The scattering type. Default is `"X"`.
189+ `"X"` for x-ray, `"N"` for neutron, `"E"` for electrons,
189190 or any registered type from diffpy.srreal from
190191 ScatteringFactorTable.getRegisteredTypes().
191192
192- Raises ValueError for unknown scattering type.
193+ Raises
194+ ------
195+ ValueError
196+ If the scattering type is unknown.
193197 """
194198 self ._calc .setScatteringFactorTableByType (stype )
195199 # update the meta dictionary only if there was no exception
196- self .meta ["stype" ] = self .getScatteringType ()
200+ self .meta ["stype" ] = self .get_scattering_type ()
197201 return
198202
199- def getScatteringType (self ):
203+ def get_scattering_type (self ):
200204 """Get the scattering type.
201205
202- See 'setScatteringType '.
206+ See 'set_scattering_type '.
203207 """
204208 return self ._calc .getRadiationType ()
205209
206- def setQmax (self , qmax ):
207- """Set the qmax value."""
210+ def set_qmax (self , qmax ):
211+ """Set the qmax value.
212+
213+ Parameters
214+ ----------
215+ qmax : float
216+ The maximum scattering vector used to generate the PDF.
217+ """
208218 self ._calc .qmax = qmax
209- self .meta ["qmax" ] = self .getQmax ()
219+ self .meta ["qmax" ] = self .get_qmax ()
210220 return
211221
212- def getQmax (self ):
213- """Get the qmax value."""
222+ def get_qmax (self ):
223+ """Get the qmax value.
224+
225+ Returns
226+ -------
227+ float
228+ The maximum scattering vector used to generate the PDF.
229+ """
214230 return self ._calc .qmax
215231
216- def setQmin (self , qmin ):
217- """Set the qmin value."""
232+ def set_qmin (self , qmin ):
233+ """Set the qmin value.
234+
235+ Parameters
236+ ----------
237+ qmin : float
238+ The minimum scattering vector used to generate the PDF.
239+ """
218240 self ._calc .qmin = qmin
219- self .meta ["qmin" ] = self .getQmin ()
241+ self .meta ["qmin" ] = self .get_qmin ()
220242 return
221243
222- def getQmin (self ):
223- """Get the qmin value."""
244+ def get_qmin (self ):
245+ """Get the qmin value.
246+
247+ Returns
248+ -------
249+ float
250+ The minimum scattering vector used to generate the PDF.
251+ """
224252 return self ._calc .qmin
225253
226- def setStructure (self , stru , name = "phase" , periodic = True ):
254+ def set_structure (self , structure , name = "phase" , periodic = True ):
227255 """Set the structure that will be used to calculate the PDF.
228256
229257 This creates a DiffpyStructureParSet, ObjCrystCrystalParSet or
230- ObjCrystMoleculeParSet that adapts stru to a ParameterSet interface.
258+ ObjCrystMoleculeParSet that adapts structure to a ParameterSet
259+ interface.
231260 See those classes (located in diffpy.srfit.structure) for how they are
232261 used. The resulting ParameterSet will be managed by this generator.
233262
234- Attributes
263+ Parameters
235264 ----------
236- stru
237- diffpy.structure.Structure, pyobjcryst.crystal.Crystal or
238- pyobjcryst.molecule.Molecule instance. Default None.
239- name
240- A name to give to the managed ParameterSet that adapts stru
265+ structure : Structure or Crystal or Molecule
266+ The diffpy.structure.Structure, pyobjcryst.crystal.Crystal or
267+ pyobjcryst.molecule.Molecule instance.
268+ name : str, optional
269+ The name to give to the managed ParameterSet that adapts structure
241270 (default "phase").
242- periodic
271+ periodic : bool, optional
243272 The structure should be treated as periodic (default
244273 True). Note that some structures do not support
245274 periodicity, in which case this will have no effect on the
246275 PDF calculation.
247276 """
248277
249278 # Create the ParameterSet
250- parset = struToParameterSet (name , stru )
279+ parset = struToParameterSet (name , structure )
251280
252281 # Set the phase
253- self .setPhase (parset , periodic )
282+ self .set_structure_from_parset (parset , periodic )
254283 return
255284
256- def setPhase (self , parset , periodic = True ):
285+ def set_structure_from_parset (self , parset , periodic = True ):
257286 """Set the phase that will be used to calculate the PDF.
258287
259288 Set the phase directly with a DiffpyStructureParSet,
260289 ObjCrystCrystalParSet or ObjCrystMoleculeParSet that adapts a structure
261290 object (from diffpy or pyobjcryst). The passed ParameterSet will be
262291 managed by this generator.
263292
264- Attributes
293+ Parameters
265294 ----------
266- parset
267- A SrRealParSet that holds the structural information.
295+ parset : SrRealParSet
296+ The SrRealParSet that holds the structural information.
268297 This can be used to share the phase between multiple
269298 BasePDFGenerators, and have the changes in one reflect in
270299 another.
271- periodic
300+ periodic : bool, optional
272301 The structure should be treated as periodic (default True).
273302 Note that some structures do not support periodicity, in
274303 which case this will be ignored.
275304 """
276305 # Store the ParameterSet for easy access
277306 self ._phase = parset
278- self .stru = self ._phase .stru
307+ self .structure = self ._phase .stru
279308
280309 # Put this ParameterSet in the ProfileGenerator.
281- self .addParameterSet (parset )
310+ self .add_parameter_set (parset )
282311
283312 # Set periodicity
284313 self ._phase .useSymmetry (periodic )
@@ -321,7 +350,7 @@ def __call__(self, r):
321350 if not numpy .array_equal (r , self ._lastr ):
322351 self ._prepare (r )
323352
324- rcalc , y = self ._calc (self ._phase ._getSrRealStructure ())
353+ rcalc , y = self ._calc (self ._phase ._get_srreal_structure ())
325354
326355 if numpy .isnan (y ).any ():
327356 y = numpy .zeros_like (r )
0 commit comments