예제 #1
0
# test the bbox all bounding functions
boxes = [rand_bbox() for i in range(20)]
xmin = min([box.xmin() for box in boxes])
xmax = max([box.xmax() for box in boxes])
ymin = min([box.ymin() for box in boxes])
ymax = max([box.ymax() for box in boxes])

box = bbox_all(boxes)
assert( closeto_seq( box.get_bounds(), (xmin, ymin, xmax-xmin, ymax-ymin)))




t1 = rand_transform()
oboundsx = t1.get_bbox1().intervalx().get_bounds()
oboundsy = t1.get_bbox1().intervaly().get_bounds()
t2 = copy_bbox_transform(t1)
t1.get_bbox1().intervalx().set_bounds(1,2)
t2.get_bbox2().intervaly().set_bounds(-1,12)
newboundsx = t2.get_bbox1().intervalx().get_bounds()
newboundsy = t2.get_bbox1().intervaly().get_bounds()
assert(oboundsx==newboundsx)
assert(oboundsy==newboundsy)


import math
polar = FuncXY(POLAR)
assert( closeto_seq( polar.map(math.pi,1), (-1,0)) )
assert( closeto_seq( polar.inverse(1,1), ( (math.pi/4), math.sqrt(2))) )
print 'all tests passed'
예제 #2
0
    transform_bbox(transform, unit_bbox()).get_bounds(), (-10, -10, 210, 50)))

# test the bbox all bounding functions
boxes = [rand_bbox() for i in range(20)]
xmin = min([box.xmin() for box in boxes])
xmax = max([box.xmax() for box in boxes])
ymin = min([box.ymin() for box in boxes])
ymax = max([box.ymax() for box in boxes])

box = bbox_all(boxes)
assert (closeto_seq(box.get_bounds(), (xmin, ymin, xmax - xmin, ymax - ymin)))

t1 = rand_transform()
oboundsx = t1.get_bbox1().intervalx().get_bounds()
oboundsy = t1.get_bbox1().intervaly().get_bounds()
t2 = copy_bbox_transform(t1)
t1.get_bbox1().intervalx().set_bounds(1, 2)
t2.get_bbox2().intervaly().set_bounds(-1, 12)
newboundsx = t2.get_bbox1().intervalx().get_bounds()
newboundsy = t2.get_bbox1().intervaly().get_bounds()
assert (oboundsx == newboundsx)
assert (oboundsy == newboundsy)

import math

polar = FuncXY(POLAR)
assert (closeto_seq(polar.map(math.pi, 1), (-1, 0)))
assert (closeto_seq(polar.inverse(1, 1), ((math.pi / 4), math.sqrt(2))))

# This unit test requires "nan", which numarray.ieeespecial
# exports.  (But we can keep using the numerix module.)