# Calculate emissions
        self.cal.get_emissions()

        # Compare with references
        self.assertAlmostEqual(self.case.emis_tot, emis_tot_ref, places=3)
        self.assertDictEqual(self.case.emis_dict, emis_dict_ref)

    def test_get_computational_time_ratio(self):
        '''Uses the KPI calculator to calculate the computational time ratio
        and compares with references.
           
        '''

        # Reset test-case
        self.case.reset()

        # Advance three simulation steps to compute elapsed times
        for _ in range(3):
            self.case.advance(u={})

        # Calculate computational time ratio
        self.cal.get_computational_time_ratio()

        # Compare with references
        self.assertAlmostEqual(self.case.time_rat, time_rat_ref, places=3)


if __name__ == '__main__':
    utilities.run_tests(os.path.basename(__file__))
Exemple #2
0
    m = mapnik.Map(10,10)
    m.background = mapnik.Color('rgba(255,255,255,.5)')
    m.background_image = '../data/images/yellow_half_trans.png'
    im = mapnik.Image(m.width,m.height)
    mapnik.render(m,im)
    eq_(get_unique_colors(im),['rgba(255,255,85,191)'])

def test_background_image_with_alpha_and_background_color_against_composited_control():
    m = mapnik.Map(10,10)
    m.background = mapnik.Color('rgba(255,255,255,.5)')
    m.background_image = '../data/images/yellow_half_trans.png'
    im = mapnik.Image(m.width,m.height)
    mapnik.render(m,im)
    # create and composite the expected result
    im1 = mapnik.Image(10,10)
    im1.background = mapnik.Color('rgba(255,255,255,.5)')
    im1.premultiply()
    im2 = mapnik.Image(10,10)
    im2.background = mapnik.Color('rgba(255,255,0,.5)')
    im2.premultiply()
    im1.composite(im2)
    im1.demultiply()
    # compare image rendered (compositing in `agg_renderer<T>::setup`)
    # vs image composited via python bindings
    raise Todo("looks like we need to investigate PNG rounding when saving")
    eq_(get_unique_colors(im),get_unique_colors(im1))

if __name__ == "__main__":
    setup()
    run_tests(eval(x) for x in dir() if x.startswith("test_"))
Exemple #3
0
    im = mapnik.Image(m.width, m.height)
    mapnik.render(m, im)
    eq_(get_unique_colors(im), ['rgba(255,255,85,191)'])


def test_background_image_with_alpha_and_background_color_against_composited_control(
):
    m = mapnik.Map(10, 10)
    m.background = mapnik.Color('rgba(255,255,255,.5)')
    m.background_image = '../data/images/yellow_half_trans.png'
    im = mapnik.Image(m.width, m.height)
    mapnik.render(m, im)
    # create and composite the expected result
    im1 = mapnik.Image(10, 10)
    im1.background = mapnik.Color('rgba(255,255,255,.5)')
    im1.premultiply()
    im2 = mapnik.Image(10, 10)
    im2.background = mapnik.Color('rgba(255,255,0,.5)')
    im2.premultiply()
    im1.composite(im2)
    im1.demultiply()
    # compare image rendered (compositing in `agg_renderer<T>::setup`)
    # vs image composited via python bindings
    raise Todo("looks like we need to investigate PNG rounding when saving")
    eq_(get_unique_colors(im), get_unique_colors(im1))


if __name__ == "__main__":
    setup()
    run_tests(eval(x) for x in dir() if x.startswith("test_"))