Code Duplication    Length = 14-17 lines in 2 locations

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

@@ 207-220 (lines=14) @@
204
#         print peakpos
205
        return peakpos
206
207
    def getAreas(self, fun, x, positions, fitmatrix):
208
        rest = fitmatrix
209
        numargsinp = self.getFitFunctionNumArgs(str(fun.__name__))  # 2 in
210
        npts = len(fitmatrix) // numargsinp
211
        weights = rest[:npts]
212
        widths = rest[npts:2*npts]
213
        areas = []
214
        for ii in range(len(weights)):
215
            areas.append(np.sum(fun(weights[ii],
216
                                    widths[ii],
217
                                    x,
218
                                    positions[ii],
219
                                    )))
220
        return weights, widths, np.array(areas)
221
222
    def getFitFunctionNumArgs(self,key):
223
        self.lookup = {

savu/plugins/fitters/base_fitter.py 1 location

@@ 143-159 (lines=17) @@
140
        self.lookup = {"lorentzian": 2, "gaussian": 2}
141
        return self.lookup[key]
142
143
    def getAreas(self, fun, x, positions, fitmatrix):
144
        rest = fitmatrix
145
        numargsinp = self.getFitFunctionNumArgs(str(fun.__name__))  # 2 in
146
        npts = len(fitmatrix) // numargsinp
147
        weights = rest[:npts]
148
        #print 'the weights are'+str(weights)
149
        widths = rest[npts:2*npts]
150
        #print 'the widths are'+str(widths)
151
        #print(len(widths))
152
        areas = []
153
        for ii in range(len(weights)):
154
            areas.append(np.sum(fun(weights[ii],
155
                                    widths[ii],
156
                                    x,
157
                                    positions[ii],
158
                                    )))
159
        return weights, widths, np.array(areas)
160
161
    def spectrum_sum_dfun(self, fun, multiplier, x, pos, *p):
162
        rest = p