Example #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'
Example #2
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(-1,math.pi), (1,0)) )
assert( closeto_seq( polar.inverse(1,1), (math.sqrt(2), math.pi/4)))
print 'all tests passed'
Example #3
0
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.)
try:
    from numarray.ieeespecial import nan
    have_nan = True
except ImportError:
    have_nan = False

if have_nan:
    y1 = array([2, nan, 1, 2, 3, 4])
    y2 = array([nan, nan, 1, 2, 3, 4])

    x1 = arange(len(y1))
Example #4
0
assert (closeto_seq(
    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(-1, math.pi), (1, 0)))
assert (closeto_seq(polar.inverse(1, 1), (math.sqrt(2), math.pi / 4)))
print 'all tests passed'