def test_frequency_sane_fmap(self):
        """
        Test that the hint is respected for MPI regions within a
        user marked region with the compute hint.
        """
        report = geopmpy.io.RawReport(self._fmap_report_path)
        host_name = report.host_names()[0]

        region = report.raw_region(host_name, 'compute_region')
        assigned_freq = report.get_field(region, 'frequency-map')
        achieved_freq = report.get_field(region, 'frequency', 'Hz')

        # Fmap agent should assign policy default frequency for regions not
        # in the map.
        self.assertEqual(
            self._freq_default,
            assigned_freq,
            msg=
            'Expected assigned frequency to be max from policy since this region has the COMPUTE hint. ({} != {})'
            .format(self._freq_default, assigned_freq))
        util.assertNear(
            self,
            self._freq_default,
            achieved_freq,
            msg=
            'Expected achieved frequency to be near default from policy. ({} !~= {})'
            .format(self._freq_default, achieved_freq))
Exemple #2
0
 def testBmiNotNan(self):
   #tombomist is too old for most calculations, but BMI should be calculated
   visit_stats = VisitStatistics.get_stats(
                                           datetime.date(1995,03,21),
                                           datetime.date(2007,03,25),
                                           Sex.MALE,
                                           30, 49.5, 140,
                                           Measured.STANDING, None)
   util.assertNear(self, 15.3, visit_stats.body_mass_index, 0.1)
Exemple #3
0
    def test_uniform_performance(self):
        """Test that the reports generated show uniform performance with
           respect to CPU frequency.

        """
        report = geopmpy.io.RawReport(self._report_path)
        host_names = report.host_names()
        for host in host_names:
            for rn in report.region_names(host):
                if rn.startswith('timed_scaling_region'):
                    region = report.raw_region(host, rn)
                    util.assertNear(self, 1.0, report.get_field(region, 'runtime', 'sec'))
Exemple #4
0
 def testZeroDayStats(self):
   # Age is 0 days, whcih is still valid.
   # Equivalent to AA2 in the anthrotest.csv
   visit_stats = VisitStatistics.get_stats(
                                           datetime.date(2009,11,27),
                                           datetime.date(2009,11,27),
                                           Sex.FEMALE,
                                           4, 35, 49,
                                           Measured.RECUMBENT, None)
   
   # Length-or-height for age
   zandp = visit_stats.get_zandp('length_or_height_for_age')
   util.assertNear(self, -0.08, zandp.zscore, 0.01)
   util.assertNear(self, 46.8, zandp.percentile, 0.1)
Exemple #5
0
 def testLengthOrHeightForAgeNotNan(self):
   # Age is right on the border, but still valid.
   # Equivalent to AA2 in the anthrotest.csv.
   visit_stats = VisitStatistics.get_stats(
                                           datetime.date(2002,03,15),
                                           datetime.date(2007,04,14),
                                           Sex.MALE,
                                           10, 50, 65.6,
                                           Measured.RECUMBENT, None)
    
   # Length-or-height for age
   zandp = visit_stats.get_zandp('length_or_height_for_age')
   util.assertNear(self, -9.76, zandp.zscore, 0.01)
   self.assertTrue(util.isNaN(zandp.percentile))
Exemple #6
0
    def test_achieved_frequency(self):
        """Test that the reports show achieved frequencies near target
           frequency.

        """
        report = geopmpy.io.RawReport(self._report_path)
        host_names = report.host_names()
        for host in host_names:
            for rn in ['timed_scaling_region_{}'.format(idx)
                       for idx in range(len(self._region_freq))]:
                region = report.raw_region(host, rn)
                request_freq = report.get_field(region, 'frequency-map')
                actual_freq = report.get_field(region, 'frequency', 'Hz')
                util.assertNear(self, request_freq, actual_freq)
Exemple #7
0
 def test2(self):
   visit_stats = VisitStatistics.get_stats(
                                           datetime.date(2005,03,21),
                                           datetime.date(2007,03,25),
                                           Sex.FEMALE, 
                                           8.2, 45, 74,
                                           Measured.RECUMBENT, None)
   
   # BMI
   util.assertNear(self, 15.3, visit_stats.body_mass_index, 0.1)
   
   # Weight-for-length-or-height
   zandp = visit_stats.get_zandp('weight_for_length_or_height')
   util.assertNear(self, -1.00, zandp.zscore, 0.01)
   util.assertNear(self, 15.9, zandp.percentile, 0.1)
   
   # Weight-for-age
   zandp = visit_stats.get_zandp('weight_for_age')
   util.assertNear(self, -2.87, zandp.zscore, 0.01)
   util.assertNear(self, 0.2, zandp.percentile, 0.1)
   
   # Length-or-height for age
   zandp = visit_stats.get_zandp('length_or_height_for_age')
   util.assertNear(self, -3.87, zandp.zscore, 0.01)
   self.assertTrue(util.isNaN(zandp.percentile))
   
   # BMI-for-age
   zandp = visit_stats.get_zandp('body_mass_index_for_age')
   util.assertNear(self, -0.33, zandp.zscore, 0.01)
   util.assertNear(self, 37.2, zandp.percentile, 0.1)
   
   # HC-for-age
   zandp = visit_stats.get_zandp('head_circumference_for_age')
   util.assertNear(self, -1.58, zandp.zscore, 0.01)
   util.assertNear(self, 5.8, zandp.percentile, 0.1)
Exemple #8
0
  def test1(self):    
    # Bernadette
    sex = Sex.FEMALE
    dateOfBirth = datetime.date(2005,03,21)
    dateOfVisit = datetime.date(2007,03,25)
    ageInDays = (dateOfVisit - dateOfBirth).days
    weight = 8.2 # kg
    length = 74.0 # cm
    headCircumference = 45.0 # cm
    measured = Measured.RECUMBENT
    
    loh = growthcalc.growthcalc.NormalizedLengthOrHeight(
                                                   ageInDays, length, measured)  
    bmi = growthcalc.growthcalc.heightAndWeightToBmi(loh.lengthOrHeight, weight)
    util.assertNear(self, 15.3, bmi, 0.1)
    
    anthro = growthcalc.growthcalc.Anthro()
    
    # Weight-for-length-or-height
    zscore = anthro.getWeightZscoreConfigForLengthOrHeight(
                                          Sex.map[sex], loh, weight, ageInDays)
    percentile = growthcalc.growthcalc.zscoreToPercentile(zscore)
    util.assertNear(self, -1.00, zscore, 0.01)
    util.assertNear(self, 15.9, percentile, 0.1)

    # Weight-for-age
    zscore = anthro.getWeightZscoreConfigForAge(Sex.map[sex], ageInDays, weight)
    percentile = growthcalc.growthcalc.zscoreToPercentile(zscore)
    util.assertNear(self, -2.87, zscore, 0.01)
    util.assertNear(self, 0.2, percentile, 0.1)
    
    # Length-or-height for age
    zscore = anthro.getLengthOrHeightZscoreConfigForAge(
                          Sex.map[sex], ageInDays, loh.lengthOrHeight, measured)
    percentile = growthcalc.growthcalc.zscoreToPercentile(zscore)
    util.assertNear(self, -3.87, zscore, 0.01)
    self.assertTrue(util.isNaN(percentile))
    
    # BMI-for-age
    zscore = anthro.getBodyMassIndexZscoreConfigForAge(
                       Sex.map[sex], ageInDays, bmi, weight, loh.lengthOrHeight)
    percentile = growthcalc.growthcalc.zscoreToPercentile(zscore)
    util.assertNear(self, -0.33, zscore, 0.01)
    util.assertNear(self, 37.2, percentile, 0.1)
    
    # HC-for-age
    zscore = anthro.getHeadCircumferenceZscoreConfigForAge(
                                     Sex.map[sex], ageInDays, headCircumference)
    percentile = growthcalc.growthcalc.zscoreToPercentile(zscore)
    util.assertNear(self, -1.58, zscore, 0.01)
    util.assertNear(self, 5.8, percentile, 0.1)