24
24
25
25
26
26
class Morph (object ):
27
- '''Base class for implementing a morph on an objective given a reference .
27
+ '''Base class for implementing a morph given a target .
28
28
29
29
Adapted from diffpy.pdfgetx to include two sets of arrays that get passed
30
- through. In most cases, the objective is modified by a morph , but it is
31
- acceptable for morph the reference as well, such as to change the range of
30
+ through. In most cases, only the morph is modified, but it is
31
+ acceptable for morph the target as well, such as to change the range of
32
32
the array.
33
33
34
34
Note that attributes are taken from config when not found locally. The
@@ -47,22 +47,22 @@ class Morph(object):
47
47
Instance attributes:
48
48
49
49
config -- dictionary that contains all configuration variables
50
- xobjin -- last objective input x data
51
- yobjin -- last objective input y data
52
- xobjout -- last objective result x data
53
- yobjout -- last objective result y data
54
- xrefin -- last reference input x data
55
- yrefin -- last reference input y data
56
- xrefout -- last reference result x data
57
- yrefout -- last reference result y data
50
+ x_morph_in -- last morph input x data
51
+ y_morph_in -- last morph input y data
52
+ x_morph_out -- last morph result x data
53
+ y_morph_out -- last morph result y data
54
+ x_target_in -- last target input x data
55
+ y_target_in -- last target input y data
56
+ x_target_out -- last target result x data
57
+ y_target_out -- last target result y data
58
58
59
59
Properties:
60
60
61
- xyobjin -- tuple of (xobjin, yobjin )
62
- xyobjout -- tuple of (xobjout, yobjout )
63
- xyrefin -- tuple of (xrefin, yrefin )
64
- xyrefout -- tuple of (xrefout, yrefout )
65
- xyallout -- tuple of (xobjout, yobjout, xrefout, yrefout )
61
+ xy_morph_in -- tuple of (x_morph_in, y_morph_in )
62
+ xy_morph_out -- tuple of (x_morph_out, y_morph_out )
63
+ xy_target_in -- tuple of (x_target_in, y_target_in )
64
+ xy_target_out -- tuple of (x_target_out, y_target_out )
65
+ xyallout -- tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out )
66
66
'''
67
67
68
68
# Class variables
@@ -76,24 +76,24 @@ class Morph(object):
76
76
77
77
# Properties
78
78
79
- xyobjin = property (
80
- lambda self : (self .xobjin , self .yobjin ),
81
- doc = 'Return a tuple of objective input arrays' ,
79
+ xy_morph_in = property (
80
+ lambda self : (self .x_morph_in , self .y_morph_in ),
81
+ doc = 'Return a tuple of morph input arrays' ,
82
82
)
83
- xyobjout = property (
84
- lambda self : (self .xobjout , self .yobjout ),
85
- doc = 'Return a tuple of objective output arrays' ,
83
+ xy_morph_out = property (
84
+ lambda self : (self .x_morph_out , self .y_morph_out ),
85
+ doc = 'Return a tuple of morph output arrays' ,
86
86
)
87
- xyrefin = property (
88
- lambda self : (self .xrefin , self .yrefin ),
89
- doc = 'Return a tuple of reference input arrays' ,
87
+ xy_target_in = property (
88
+ lambda self : (self .x_target_in , self .y_target_in ),
89
+ doc = 'Return a tuple of target input arrays' ,
90
90
)
91
- xyrefout = property (
92
- lambda self : (self .xrefout , self .yrefout ),
93
- doc = 'Return a tuple of reference output arrays' ,
91
+ xy_target_out = property (
92
+ lambda self : (self .x_target_out , self .y_target_out ),
93
+ doc = 'Return a tuple of target output arrays' ,
94
94
)
95
95
xyallout = property (
96
- lambda self : (self .xobjout , self .yobjout , self .xrefout , self .yrefout ),
96
+ lambda self : (self .x_morph_out , self .y_morph_out , self .x_target_out , self .y_target_out ),
97
97
doc = 'Return a tuple of all output arrays' ,
98
98
)
99
99
@@ -105,43 +105,43 @@ def __init__(self, config=None):
105
105
# declare empty attributes
106
106
if config is None :
107
107
config = {}
108
- self .xobjin = None
109
- self .yobjin = None
110
- self .xobjout = None
111
- self .yobjout = None
112
- self .xrefin = None
113
- self .yrefin = None
114
- self .xrefout = None
115
- self .yrefout = None
108
+ self .x_morph_in = None
109
+ self .y_morph_in = None
110
+ self .x_morph_out = None
111
+ self .y_morph_out = None
112
+ self .x_target_in = None
113
+ self .y_target_in = None
114
+ self .x_target_out = None
115
+ self .y_target_out = None
116
116
# process arguments
117
117
self .applyConfig (config )
118
118
return
119
119
120
- def morph (self , xobj , yobj , xref , yref ):
121
- '''Morph arrays objective or reference .
120
+ def morph (self , x_morph , y_morph , x_target , y_target ):
121
+ '''Morph arrays morphed or target .
122
122
123
- xobj, yobj -- Objective arrays.
124
- xref, yref -- Reference arrays.
123
+ x_morph, y_morph -- Morphed arrays.
124
+ x_target, y_target -- Target arrays.
125
125
126
126
Identity operation. This method should be overloaded in a derived
127
127
class.
128
128
129
- Return a tuple of numpy arrays (xobjout, yobjout, xrefout, yrefout )
129
+ Return a tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out )
130
130
'''
131
- self .xobjin = xobj
132
- self .yobjin = yobj
133
- self .xrefin = xref
134
- self .yrefin = yref
135
- self .xobjout = xobj .copy ()
136
- self .yobjout = yobj .copy ()
137
- self .xrefout = xref .copy ()
138
- self .yrefout = yref .copy ()
131
+ self .x_morph_in = x_morph
132
+ self .y_morph_in = y_morph
133
+ self .x_target_in = x_target
134
+ self .y_target_in = y_target
135
+ self .x_morph_out = x_morph .copy ()
136
+ self .y_morph_out = y_morph .copy ()
137
+ self .x_target_out = x_target .copy ()
138
+ self .y_target_out = y_target .copy ()
139
139
self .checkConfig ()
140
140
return self .xyallout
141
141
142
- def __call__ (self , xobj , yobj , xref , yref ):
142
+ def __call__ (self , x_morph , y_morph , x_target , y_target ):
143
143
'''Alias for morph.'''
144
- return self .morph (xobj , yobj , xref , yref )
144
+ return self .morph (x_morph , y_morph , x_target , y_target )
145
145
146
146
def applyConfig (self , config ):
147
147
'''Process any configuration data from a dictionary.
@@ -163,14 +163,14 @@ def checkConfig(self):
163
163
def plotInputs (self , xylabels = True ):
164
164
'''Plot input arrays using matplotlib.pyplot
165
165
166
- xylabels -- flag for updating x and y axis labels
166
+ xylabels -- flag for updating x and y axes labels
167
167
168
168
Return a list of matplotlib line objects.
169
169
'''
170
170
from matplotlib .pyplot import plot , xlabel , ylabel
171
171
172
- rv = plot (self .xrefin , self .yrefin , label = "reference " )
173
- rv = plot (self .xobjin , self .yobjin , label = "objective " )
172
+ rv = plot (self .x_target_in , self .y_target_in , label = "target " )
173
+ rv = plot (self .x_morph_in , self .y_morph_in , label = "morph " )
174
174
if xylabels :
175
175
xlabel (self .xinlabel )
176
176
ylabel (self .yinlabel )
@@ -179,7 +179,7 @@ def plotInputs(self, xylabels=True):
179
179
def plotOutputs (self , xylabels = True , ** plotargs ):
180
180
'''Plot output arrays using matplotlib.pyplot
181
181
182
- xylabels -- flag for updating x and y axis labels
182
+ xylabels -- flag for updating x and y axes labels
183
183
plotargs -- arguments passed to the pylab plot function. Note that
184
184
"label" will be ignored.
185
185
@@ -189,8 +189,8 @@ def plotOutputs(self, xylabels=True, **plotargs):
189
189
190
190
pargs = dict (plotargs )
191
191
pargs .pop ("label" , None )
192
- rv = plot (self .xrefout , self .yrefout , label = "reference " , ** pargs )
193
- rv = plot (self .xobjout , self .yobjout , label = "objective " , ** pargs )
192
+ rv = plot (self .x_target_out , self .y_target_out , label = "target " , ** pargs )
193
+ rv = plot (self .x_morph_out , self .y_morph_out , label = "morph " , ** pargs )
194
194
if xylabels :
195
195
xlabel (self .xoutlabel )
196
196
ylabel (self .youtlabel )
0 commit comments