/[thuban]/trunk/thuban/test/test_classgen.py
ViewVC logotype

Diff of /trunk/thuban/test/test_classgen.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1362 by jonathan, Wed Jul 2 12:59:34 2003 UTC revision 1436 by jonathan, Wed Jul 16 13:25:04 2003 UTC
# Line 21  from Thuban.Model.classgen import \ Line 21  from Thuban.Model.classgen import \
21      generate_uniform_distribution, \      generate_uniform_distribution, \
22      generate_quantiles, \      generate_quantiles, \
23      calculate_quantiles, \      calculate_quantiles, \
24      GreyRamp      GreyRamp, CustomRamp, FixedRamp
25  from Thuban.Model.range import Range  from Thuban.Model.range import Range
26  from Thuban.Model.color import Color  from Thuban.Model.color import Color
27    
28  from Thuban.Model.classification import ClassGroupRange  from Thuban.Model.classification import ClassGroupRange, ClassGroupProperties
29    
30  class ClassGenTest(unittest.TestCase):  class ClassGenTest(unittest.TestCase):
31    
# Line 299  class ClassGenTest(unittest.TestCase): Line 299  class ClassGenTest(unittest.TestCase):
299                      [.12, .24, .36, .50, .62, .76, .88, 1.0], Range("[1;5]"))                      [.12, .24, .36, .50, .62, .76, .88, 1.0], Range("[1;5]"))
300          eq(result, (1, 0, 24, [(4, .2), (9, .4), (14, .6), (19, .8), (24, 1.0)]))          eq(result, (1, 0, 24, [(4, .2), (9, .4), (14, .6), (19, .8), (24, 1.0)]))
301    
302    
303    class TestCustomRamp(unittest.TestCase):
304    
305        def test_color_interpolation(self):
306            """Test CustomRamp color interpolation"""
307            start = ClassGroupProperties()
308            start.SetFill(Color(1, 1, 1))
309            start.SetLineColor(Color(0, 0, 0))
310    
311            end = ClassGroupProperties()
312            end.SetFill(Color(1, 0, 0))
313            end.SetLineColor(Color(0, 1, 0))
314    
315            ramp = CustomRamp(start, end)
316            half = ramp.GetProperties(0.5)
317            self.assertEquals(half.GetFill(), Color(1, 0.5, 0.5))
318            self.assertEquals(half.GetLineColor(), Color(0, 0.5, 0))
319    
320    class TestFixedRamp(unittest.TestCase):
321    
322        def test(self):
323            eq = self.assertEquals
324    
325            for lineColor, lineWidth, fillColor in \
326                [(None, None, None), (Color(1, 1, 1), None, None),
327                 (None, 4, None), (None, None, Color(0, 1, 0)),
328                 (Color(1, 1, 1), 4, None), (Color(1, 1, 1), None, Color(0, 1, 0)),
329                 (None, 4, Color(0, 1, 0)), (Color(1, 1, 1), 4, Color(0, 1, 0))]:
330    
331                framp = FixedRamp(GreyRamp, (lineColor, lineWidth, fillColor))
332    
333                for i in [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]:
334                    props = framp.GetProperties(i)
335                    if lineColor: eq(props.GetLineColor(), lineColor)
336                    if lineWidth: eq(props.GetLineWidth(), lineWidth)
337                    if fillColor: eq(props.GetFill(), fillColor)
338    
339  if __name__ == "__main__":  if __name__ == "__main__":
340      unittest.main()      unittest.main()
341    

Legend:
Removed from v.1362  
changed lines
  Added in v.1436

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26