2626class Morph (object ):
2727 '''Base class for implementing a morph given a target.
2828
29- Adapted from diffpy.pdfgetx to include two sets of arrays that get passed
30- through.
31-
32- Note that attributes are taken from config when not found locally. The
33- morph may modify the config dictionary. This is the means by which to
34- communicate automatically modified attributes.
35-
36- Class attributes:
37-
38- summary -- short description of a morph
39- xinlabel -- descriptive label for the x input array
40- yinlabel -- descriptive label for the y input array
41- xoutlabel -- descriptive label for the x output array
42- youtlabel -- descriptive label for the y output array
43- parnames -- list of names of configuration variables
44-
45- Instance attributes:
46-
47- config -- dictionary that contains all configuration variables
48- x_morph_in -- last morph input x data
49- y_morph_in -- last morph input y data
50- x_morph_out -- last morph result x data
51- y_morph_out -- last morph result y data
52- x_target_in -- last target input x data
53- y_target_in -- last target input y data
54- x_target_out -- last target result x data
55- y_target_out -- last target result y data
56-
57- Properties:
58-
59- xy_morph_in -- tuple of (x_morph_in, y_morph_in)
60- xy_morph_out -- tuple of (x_morph_out, y_morph_out)
61- xy_target_in -- tuple of (x_target_in, y_target_in)
62- xy_target_out -- tuple of (x_target_out, y_target_out)
63- xyallout -- tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out)
29+ Adapted from diffpy.pdfgetx to include two sets of arrays that get passed through.
30+
31+ Attributes are taken from config when not found locally. The morph may modify the config dictionary.
32+ This is the means by which to communicate automatically modified attributes.
33+
34+ Class Attributes
35+ ----------------
36+ summary
37+ Short description of a morph.
38+ xinlabel
39+ Descriptive label for the x input array.
40+ yinlabel
41+ Descriptive label for the y input array.
42+ xoutlabel
43+ Descriptive label for the x output array.
44+ youtlabel
45+ Descriptive label for the y output array.
46+ parnames: list
47+ Names of configuration variables.
48+
49+ Instance Attributes
50+ -------------------
51+ config: dict
52+ All configuration variables.
53+ x_morph_in
54+ Last morph input x data.
55+ y_morph_in
56+ Last morph input y data.
57+ x_morph_out
58+ Last morph result x data.
59+ y_morph_out
60+ Last morph result y data.
61+ x_target_in
62+ Last target input x data.
63+ y_target_in
64+ Last target input y data.
65+ x_target_out
66+ Last target result x data.
67+ y_target_out
68+ Last target result y data.
69+
70+ Properties
71+ ----------
72+ xy_morph_in
73+ Tuple of (x_morph_in, y_morph_in).
74+ xy_morph_out
75+ Tuple of (x_morph_out, y_morph_out).
76+ xy_target_in
77+ Tuple of (x_target_in, y_target_in).
78+ xy_target_out
79+ Tuple of (x_target_out, y_target_out).
80+ xyallout
81+ Tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out).
6482 '''
6583
6684 # Class variables
@@ -98,7 +116,8 @@ class Morph(object):
98116 def __init__ (self , config = None ):
99117 '''Create a default Morph instance.
100118
101- config -- dictionary that contains all configuration variables
119+ config: dict
120+ All configuration variables.
102121 '''
103122 # declare empty attributes
104123 if config is None :
@@ -118,13 +137,19 @@ def __init__(self, config=None):
118137 def morph (self , x_morph , y_morph , x_target , y_target ):
119138 '''Morph arrays morphed or target.
120139
121- x_morph, y_morph -- Morphed arrays.
122- x_target, y_target -- Target arrays.
140+ Identity operation. This method should be overloaded in a derived class.
123141
124- Identity operation. This method should be overloaded in a derived
125- class.
142+ Parameters
143+ ----------
144+ x_morph, y_morph
145+ Morphed arrays.
146+ x_target, y_target
147+ Target arrays.
126148
127- Return a tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out)
149+ Returns
150+ -------
151+ tuple
152+ A tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out)
128153 '''
129154 self .x_morph_in = x_morph
130155 self .y_morph_in = y_morph
@@ -144,15 +169,20 @@ def __call__(self, x_morph, y_morph, x_target, y_target):
144169 def applyConfig (self , config ):
145170 '''Process any configuration data from a dictionary.
146171
147- config -- Configuration dictionary.
172+ Parameters
173+ ----------
174+ config: dict
175+ Configuration dictionary.
148176
177+ Returns
178+ -------
149179 No return value.
150180 '''
151181 self .config = config
152182 return
153183
154184 def checkConfig (self ):
155- '''Verify data in self.config. No action by default.
185+ '''Verify data in self.config. No action by default.
156186
157187 To be overridden in a derived class.
158188 '''
@@ -161,9 +191,15 @@ def checkConfig(self):
161191 def plotInputs (self , xylabels = True ):
162192 '''Plot input arrays using matplotlib.pyplot
163193
164- xylabels -- flag for updating x and y axes labels
194+ Parameters
195+ ----------
196+ xylabels
197+ Flag for updating x and y axes labels.
165198
166- Return a list of matplotlib line objects.
199+ Returns
200+ -------
201+ list:
202+ A list of matplotlib line objects.
167203 '''
168204 from matplotlib .pyplot import plot , xlabel , ylabel
169205
@@ -177,11 +213,17 @@ def plotInputs(self, xylabels=True):
177213 def plotOutputs (self , xylabels = True , ** plotargs ):
178214 '''Plot output arrays using matplotlib.pyplot
179215
180- xylabels -- flag for updating x and y axes labels
181- plotargs -- arguments passed to the pylab plot function. Note that
182- "label" will be ignored.
183-
184- Return a list of matplotlib line objects.
216+ Parameters
217+ ----------
218+ xylabels: bool
219+ Flag for updating x and y axes labels.
220+ plotargs
221+ Arguments passed to the pylab plot function. Note that "label" will be ignored.
222+
223+ Returns
224+ -------
225+ list
226+ A list of matplotlib line objects.
185227 '''
186228 from matplotlib .pyplot import plot , xlabel , ylabel
187229
@@ -197,10 +239,19 @@ def plotOutputs(self, xylabels=True, **plotargs):
197239 def __getattr__ (self , name ):
198240 '''Obtain the value from self.config, when normal lookup fails.
199241
200- name -- name of the attribute to be recovered
242+ Parameters
243+ ----------
244+ name
245+ Name of the attribute to be recovered.
246+
247+ Returns
248+ -------
249+ self.config.get(name)
201250
202- Return self.config.get(name).
203- Raise AttributeError, when name is not available from self.config.
251+ Raises
252+ ------
253+ AttributeError
254+ Name is not available from self.config.
204255 '''
205256 if name in self .config :
206257 return self .config [name ]
@@ -211,9 +262,12 @@ def __getattr__(self, name):
211262 def __setattr__ (self , name , val ):
212263 '''Set configuration variables to config.
213264
214- name -- name of the attribute
215- val -- value of the attribute
216-
265+ Parameters
266+ ----------
267+ name
268+ Name of the attribute.
269+ val
270+ Value of the attribute.
217271 '''
218272 if name in self .parnames :
219273 self .config [name ] = val
0 commit comments