Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

import unittest 

 

import lsst.utils.tests 

import lsst.geom 

from lsst.afw.geom.testUtils import BoxGrid 

 

 

class BoxGridTestCase(lsst.utils.tests.TestCase): 

"""!Unit tests for BoxGrid""" 

 

def test3By4(self): 

"""!Test a 3x4 box divided into a 3x2 grid, such that each sub-box is 1x2 

""" 

for boxClass in (lsst.geom.Box2I, lsst.geom.Box2D): 

pointClass = type(boxClass().getMin()) 

extentClass = type(boxClass().getDimensions()) 

 

minPt = pointClass(-1, 3) 

extent = extentClass(3, 4) 

numColRow = (3, 2) 

outerBox = boxClass(minPt, extent) 

boxGrid = BoxGrid(box=outerBox, numColRow=numColRow) 

for box in boxGrid: 

self.assertEqual(box.getDimensions(), extentClass(1, 2)) 

for row in range(numColRow[1]): 

for col in range(numColRow[0]): 

box = boxGrid[col, row] 

predMin = outerBox.getMin() + extentClass(col*1, row*2) 

self.assertEqual(box.getMin(), predMin) 

 

def testIntUneven(self): 

"""!Test dividing an integer box into an uneven grid 

 

Divide a 5x4 box into 2x3 regions 

""" 

minPt = lsst.geom.Point2I(0, 0) 

extent = lsst.geom.Extent2I(5, 7) 

numColRow = (2, 3) 

outerBox = lsst.geom.Box2I(minPt, extent) 

boxGrid = BoxGrid(box=outerBox, numColRow=numColRow) 

desColStarts = (0, 2) 

desWidths = (2, 3) 

desRowStarts = (0, 2, 4) 

desHeights = (2, 2, 3) 

for row in range(numColRow[1]): 

desRowStart = desRowStarts[row] 

desHeight = desHeights[row] 

for col in range(numColRow[0]): 

desColStart = desColStarts[col] 

desWidth = desWidths[col] 

box = boxGrid[col, row] 

self.assertEqual(tuple(box.getMin()), 

(desColStart, desRowStart)) 

self.assertEqual(tuple(box.getDimensions()), 

(desWidth, desHeight)) 

 

 

class MemoryTester(lsst.utils.tests.MemoryTestCase): 

pass 

 

 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

66 ↛ 67line 66 didn't jump to line 67, because the condition on line 66 was never trueif __name__ == "__main__": 

lsst.utils.tests.init() 

unittest.main()