nDimensional sparse histogram in python.

John McMonagle johnmc at velseis.com.au
Wed Feb 1 22:20:39 EST 2006


On Wed, 2006-02-01 at 19:06 -0800, KraftDiner wrote:
> Cool.
> Ok so my histogram class had two methods 1) To increment a point and 2)
> to get the point.
> 
> def class histo:
>    def __init__(self):
>        histo = {}
> def update(point):
>    '''searches the dictionary for point and if it exists increment the
> value.
>     if it doesn't exist set the value to 1'''
> 
> def get(point):
>    return self.histo[point]
> 
> I'm not sure how to code up the update routine...
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

def update(point);
  
  if histo.get(point) != None:
    histo[point] = histo[point] + 1

Regards,

John


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the Python-list mailing list