fccoelho / bayesian-inference

Previously hosted on code.google.com/p/bayesian-inference
6 stars 2 forks source link

Range for histogram #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I like your ascii histogram:-)

I have added range functionality to it.

  h=asciihist.Histogram(turns,bins=8,range=(int_mean-4,int_mean+4))
  print h.vertical(20)

The output can be reduced to interesting part only:

5.00 : ||||||||||
6.00 : |||||||||||||||||
7.00 : |||||||||||||||||||
8.00 : ||||||||||||||||||||
9.00 : |||||||||||||||||
10.00: ||||||||||||||
11.00: |||||||||||
12.00: ||||||||||||||

I have changed following lines:
class Histogram(object):
    """
    Ascii histogram
    """
    def __init__(self, data, bins=10,range=None):  <== added range 
        """
        Class constructor

        :Parameters:
            - `data`: array like object
        """
        self.data = data
        self.bins = bins
        self.range = range   <== new line
        self.h = histogram(self.data, bins=self.bins, range=self.range) <==added range here

I have attached updated asciihist.py file. Could you please consider to update 
it in the repository?

Thanks
Jirka

Original issue reported on code.google.com by hladky.j...@gmail.com on 16 Aug 2010 at 9:43

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks Jirka,

I think it is a good feature to have. I'll probably add it to the repository 
later this week, when I'll have some free time. 

Thanks again,

Flávio

Original comment by fccoelho on 17 Aug 2010 at 9:32

GoogleCodeExporter commented 9 years ago
Support for range was added to the repository. Minor changes to the proposed 
change were made to avoid conflict with reserved keyword "range"
Also added a couple of tests. If you can think of better tests I'd be happy to 
include them.

Thanks.

Original comment by fccoelho on 26 Aug 2010 at 5:38

GoogleCodeExporter commented 9 years ago

Original comment by fccoelho on 26 Aug 2010 at 5:38