Code Duplication    Length = 14-18 lines in 2 locations

savu/plugins/fitters/base_fitter.py 1 location

@@ 152-169 (lines=18) @@
149
        self.lookup = {"lorentzian": 2, "gaussian": 2}
150
        return self.lookup[key]
151
152
    def getAreas(self, fun, x, positions, fitmatrix):
153
        rest = fitmatrix
154
        numargsinp = self.getFitFunctionNumArgs(str(fun.__name__))  # 2 in
155
        npts = len(fitmatrix) / numargsinp
156
        #print npts
157
        weights = rest[:npts]
158
        #print 'the weights are'+str(weights)
159
        widths = rest[npts:2*npts]
160
        #print 'the widths are'+str(widths)
161
        #print(len(widths))
162
        areas = []
163
        for ii in range(len(weights)):
164
            areas.append(np.sum(fun(weights[ii],
165
                                    widths[ii],
166
                                    x,
167
                                    positions[ii],
168
                                    )))
169
        return weights, widths, np.array(areas)
170
171
    def spectrum_sum_dfun(self, fun, multiplier, x, pos, *p):
172
        rest = p

savu/plugins/unregistered/fluo_fitters/base_fluo_fitter.py 1 location

@@ 221-234 (lines=14) @@
218
#         print peakpos
219
        return peakpos
220
221
    def getAreas(self, fun, x, positions, fitmatrix):
222
        rest = fitmatrix
223
        numargsinp = self.getFitFunctionNumArgs(str(fun.__name__))  # 2 in
224
        npts = len(fitmatrix) // numargsinp
225
        weights = rest[:npts]
226
        widths = rest[npts:2*npts]
227
        areas = []
228
        for ii in range(len(weights)):
229
            areas.append(np.sum(fun(weights[ii],
230
                                    widths[ii],
231
                                    x,
232
                                    positions[ii],
233
                                    )))
234
        return weights, widths, np.array(areas)
235
236
    def getFitFunctionNumArgs(self,key):
237
        self.lookup = {