Package: python-scientific
Version: 2.4.11-1
Severity: normal
Tags: patch

leastSquaresFit does not work with 3-tuple data points (with the third
number specifying the error of the point), at least when the third point
is of type numpy.float64. This is the type you would get if you constructed
the "data" variable using NumPy's array tools (specifically, I used:
yerr = numpy.ones(l), where "l" was the number of my data points, and using
a for-loop later to built a list of 3-tuples, with elements from yerr
as the third number in the 3-tuple).

The relevant code in LeastSquares.py seems to be:
----
sigma = 1
if len(point) == 3:
   sigma = point[2]
----

Adding a conversion of point[2] to a common python type, such as float
seems to fix my particular problem. The changed code is:
----
sigma = 1
if len(pint) == 3:
   sigma = float(point[2])
----

I am not entirely sure if it's leastSquaresFit's fault (for example, it's
possible that the LinearAlgebra package should have handled different
types better), and I am almost sure that in the current version of NumPy
and ScientificPython, this should be fixed.

I am submitting this patch in case anyone else runs into the same problem
as I did (and being new to Python, it took me an hour to track it down),
and don't want to upgrade the whole thing just for this little functionality.

Regards,

Andrzej

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (1000, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages python-scientific depends on:
ii  python                        2.4.4-2    An interactive high-level object-o
ii  python-central                0.5.12     register and build utility for Pyt
ii  python-netcdf                 2.4.11-1   A netCDF interface for Python
ii  python-numeric-ext            24.2-7     Extension modules for Numeric Pyth
ii  python2.4                     2.4.4-3    An interactive high-level object-o

Versions of packages python-scientific recommends:
ii  python-tk                     2.4.4-1    Tkinter - Writing Tk applications 

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to