Did I find the right examples for you? yes no

All Samples(10)  |  Call(10)  |  Derive(0)  |  Import(0)
Returns the mean (average) of the input.  Ignores unknown values, if no 
values found besides unknown it will just return 'None'

Inputs:
  - a dictionary of occurances of numeric data.  For example:
    {5:31, 8:4} indicating 31 occurances of 5 and 4 occurances of 8
Outputs:
  - a single value - the mean of the inputs
Test Coverage:
  - complete via test harness

        def get_mean(values):
    """ Returns the mean (average) of the input.  Ignores unknown values, if no 
        values found besides unknown it will just return 'None'

        Inputs:
          - a dictionary of occurances of numeric data.  For example:
            {5:31, 8:4} indicating 31 occurances of 5 and 4 occurances of 8
        Outputs:
          - a single value - the mean of the inputs
        Test Coverage:
          - complete via test harness
    """
    count   = 0
    accum   = 0
    for value in values:
        try:
            accum += float(value) * float(values[value])
            count += float(values[value])
        except ValueError:      # catches occasional garbage data
            pass

    try:
        return accum / count
    except ZeroDivisionError:
        return None
        


src/d/a/datagristle-0.56/gristle/field_determinator.py   datagristle(Download)
 
            if self.field_types[f_no] in ['integer','float']:
                self.field_mean[f_no]   = mather.get_mean(self.field_freqs[f_no])
                self.field_median[f_no] = mather.GetDictMedian().run(self.field_freqs[f_no])
                (self.variance[f_no], self.stddev[f_no])   \

src/d/a/DataGristle-HEAD/gristle/field_determinator.py   DataGristle(Download)
 
            if self.field_types[f_no] in ['integer','float']:
                self.field_mean[f_no]   = mather.get_mean(self.field_freqs[f_no])
                self.field_median[f_no] = mather.GetDictMedian().run(self.field_freqs[f_no])
                (self.variance[f_no], self.stddev[f_no])   \

src/d/a/datagristle-0.56/gristle/tests/test_field_math.py   datagristle(Download)
    def test_math_f01_emptiness(self):
        assert mod.get_mean(self.empty_dict_1) is None
        assert mod.get_mean(self.empty_dict_2) is None
 
    def test_math_f03_small_sets(self):
        pass
 
    def test_math_f04_medium_sets(self):
        assert mod.get_mean(self.med_dict_1)  == 96.00
        result = '%.4f' % mod.get_mean(self.med_dict_3)

src/d/a/DataGristle-HEAD/gristle/tests/test_field_math.py   DataGristle(Download)
    def test_math_f01_emptiness(self):
        assert mod.get_mean(self.empty_dict_1) is None
        assert mod.get_mean(self.empty_dict_2) is None
 
    def test_math_f03_small_sets(self):
        pass
 
    def test_math_f04_medium_sets(self):
        assert mod.get_mean(self.med_dict_1)  == 96.00
        result = '%.4f' % mod.get_mean(self.med_dict_3)