X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Futil%2Ffit.py;h=f0bf32c9f915595ab859befd6adeb5147719554f;hp=f8312f289ddc40a0e0a2d271242a70c88b8026ee;hb=HEAD;hpb=a0f5948309cc4644a8e2e0bf2bf433b92e52b76a diff --git a/hooke/util/fit.py b/hooke/util/fit.py index f8312f2..f0bf32c 100644 --- a/hooke/util/fit.py +++ b/hooke/util/fit.py @@ -1,20 +1,19 @@ -# Copyright (C) 2010-2012 W. Trevor King +# Copyright (C) 2010-2012 W. Trevor King # # This file is part of Hooke. # -# Hooke is free software: you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. +# Hooke is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. # -# Hooke is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General -# Public License for more details. +# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. # -# You should have received a copy of the GNU Lesser General Public -# License along with Hooke. If not, see -# . +# You should have received a copy of the GNU Lesser General Public License +# along with Hooke. If not, see . """Provide :class:`ModelFitter` to make arbitrary model fitting easy. """ @@ -116,9 +115,9 @@ class ModelFitter (object): machine rounding during computation. We expect the values to be close to the input settings (slope 7, offset -33). - >>> print '%.3f' % slope + >>> print('{:.3f}'.format(slope)) 7.000 - >>> print '%.3f' % offset + >>> print('{:.3f}'.format(offset)) -32.890 The offset is a bit off because, the range is not a multiple of @@ -129,9 +128,9 @@ class ModelFitter (object): >>> m = LinearModel(data, rescale=True) >>> outqueue = Queue() >>> slope,offset = m.fit(outqueue=outqueue) - >>> print '%.3f' % slope + >>> print('{:.3f}'.format(slope)) 7.000 - >>> print '%.3f' % offset + >>> print('{:.3f}'.format(offset)) -32.890 Test single-parameter models: @@ -150,7 +149,7 @@ class ModelFitter (object): >>> data = 20*numpy.sin(arange(1000)) + 7.*arange(1000) >>> m = SingleParameterModel(data) >>> slope, = m.fit(outqueue=outqueue) - >>> print '%.3f' % slope + >>> print('{:.3f}'.format(slope)) 7.000 """ def __init__(self, *args, **kwargs): @@ -286,7 +285,7 @@ class ModelFitter (object): # def dist(px,py,linex,liney): # distancesx=scipy.array([(px-x)**2 for x in linex]) # minindex=numpy.argmin(distancesx) -# print px, linex[0], linex[-1] +# print(px, linex[0], linex[-1]) # return (py-liney[minindex])**2 # #