Here's the Script it was being used in (forgive it if it seems a bit messy, i have been tinkering with variables and such to try different ideas and haven't really cleaned it up).

import ctest
import Tkinter
import threading

hue_map = ("#FFFFFF","#FEFEFF","#FDFDFF","#FCFCFF","#FBFBFF","#FAFAFF","#F9F9FF","#F8F8F8","#F7F7FF","#F6F6F6","#EEEEFF","#DDDDFF","#CCCCFF","#BBBBFF","#AAAAFF","#9999FF","#8888FF",\
        "#7777FF","#6666FF","#5555FF","#4444FF","#3333FF","#2222FF","#1111FF","#0000FF")

class Mandelbrot_Set(Tkinter.Canvas):
    def __init__(self,master,iters):
        Tkinter.Canvas.__init__(self,master)
        self.dims = {'x':500,'y':500}
        self.config(height=self.dims['y'],width=self.dims['x'])
        self.r_range = (-2.0,2.0)
        self.i_range = (-2.0,2.0)
        self.iters = iters
        self.prec = {'r':1.*(self.r_range[1]-self.r_range[0])/(self.dims['x']),'i':1.*(self.i_range[1]-self.i_range[0])/self.dims['y']}
       
self.escapemap = ctest.escapeMap(-1j,self.iters,(self.dims['x'],self.dims['y']),(self.r_range[0],self.r_range[1]),(self.i_range[0],self.i_range[1]))
        self.select = False
        self.select_event = (0,0)
        self.sbox = None
        self.bind("<Button-1>",self.selection_box)
        self.bind("<Motion>",self.select_update)
        self.t_draw = threading.Thread(target=self.draw)
        self.t_draw.start()
       
    def draw(self):
        for j in range(self.dims['y']):
            i = 0
            while i < self.dims['x']:
                cur = 0;
                try:
                    color = self.escapemap[j][i]
                    while self.escapemap[j][i+cur] == color:
                        cur+=1
                except IndexError:
                    break;
                hue_step = 1.*len(hue_map)/self.iters
                if color == -1: f = "#000000"
                else: f = hue_map[int(hue_step*color)]
                self.create_line(i,j,i+cur,j,fill=f)
                i+=cur
               
    def selection_box(self,event):
        if not self.select:
            self.select_event = (event.x,event.y)
            self.select = True
        else:
            self.r_range = self.new_range(event.x,self.select_event[0])
            self.i_range = self.new_range(event.y,self.select_event[1])
            print self.r_range,self.i_range
            self.select = False
            self.delete(Tkinter.ALL)
            self.t_draw.run()
        self.select_update(event)
       
    def new_range(self,x,y):
        if x > y:
            return (y,x)
        else:
            return (x,y)
       
    def select_update(self,event):
        if not self.select:
            return
        else:
            if self.sbox != None:
                self.delete(self.sbox)
                self.sbox = self.create_rectangle(self.select_event[0],self.select_event[1],event.x,event.y,fill=None,outline="#000000")
            else:
                self.sbox = self.create_rectangle(self.select_event[0],self.select_event[1],event.x,event.y,fill=None,outline="#000000")
           
if __name__ == "__main__":
    root = Tkinter.Tk()
    c = Mandelbrot_Set(root,50)
    c.pack()
    root.mainloop()


The error occurs in the instantiation of the Mandelbrot_Set object.
Additionally in little mini timing scripts such as

import time
import ctest

t = time.time()
c = ctest.escapeMap(-1j,100,(500,500))
print time.time()-t


this will crash it too
however I found that just opening up the interpreter and typing

import ctest
ctest.escapeMap(-1j,100,(50,50)) #50 yields much smaller output than 500x500


it generates a 2d tuple fine.  So the error seems really obscure to me, and I don't understand it.
Brandon Keown wrote:

  
   I have programmed a fractal generator (Julia Set/Mandelbrot Set) in
python in the past, and have had good success, but it would run so
slowly because of the overhead involved with the calculation.  I
recently purchased VS .NET 2003 (Win XP, precomp binary of python
2.4.2rc1) to make my own extensions.  I was wondering if anyone could
help me figure out why I'm getting obscure memory exceptions (runtime
errors resulting in automatic closing of Python) with my extension.  It
seems to run okay if imported alone, but when accompanied in a list of
instructions such as a function it crashes.
    

a short script or interpreter session that illustrates how to get the errors
would help.

</F> 



  

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to