Exemplo n.º 1
0
 def avMPP(self, value):
     # TODO: shall we use the real density of the screen?
     # We could use real density but how much important is it?
     mppScreen = 0.00025 # 0.25 mm/px 
     label = "Mag: "
     if self.inimage.mpp:
         magIm = mppScreen / self.inimage.mpp # as if 1 im.px == 1 sc.px
         if magIm >= 1:
             label += "×" + str(units.round_significant(magIm, 3))
         else:
             label += "/" + str(units.round_significant(1.0/magIm, 3))
         magDig =  self.inimage.mpp / self.viewmodel.mpp.value
         if magDig >= 1:
             label += " ×" + str(units.round_significant(magDig, 3))
         else:
             label += " /" + str(units.round_significant(1.0/magDig, 3))
     self.LegendMag.SetLabel(label)
     
     if self.sizer:
         self.sizer.Layout()
Exemplo n.º 2
0
 def test_round_significant(self):
     #         (input) (expected output)
     values = [((1, 1), 1),
               ((-1.234, 1), -1),
               ((-1234, 1), -1000),
               ((1600, 1), 2000),
               ((-1600, 1), -2000),
               ((0.0001236, 3), 0.000124),
               ((0, 5), 0),
               ]
     for (i, eo) in values:
         o = units.round_significant(*i)
         self.assertEquals(o, eo,
                           "%f to %d figures = %f should be %f" % (i[0], i[1], o, eo))