Memory error with quadratic interpolation

Ulrich Eckhardt ulrich.eckhardt at dominolaser.com
Wed Jan 23 03:55:14 EST 2013


Am 23.01.2013 05:06, schrieb Isaac Won:
> I have tried to use different interpolation methods with Scipy. My
> code seems just fine with linear interpolation, but shows memory
> error with quadratic. I am a novice for python. I will appreciate any
> help.
 >
> #code
> f = open(filin, "r")

Check out the "with open(...) as f" syntax.


> for columns in ( raw.strip().split() for raw in f ):

For the record, this first builds a sequence and then iterates over that 
sequence. This is not very memory-efficient, try this instead:

    for line in f:
        columns = line.strip().split()


Concerning the rest of your problems, there is lots of code and the 
datafile missing. However, there is also too much of it, try replacing 
the file with generated data and remove everything from the code that is 
not absolutely necessary.

Good luck!

Uli





More information about the Python-list mailing list