Ejemplo n.º 1
0
def closeto(x,y):
    return abs(asarray(x)-asarray(y))<1e-10

def closeto_seq(xs,ys):
    return alltrue([closeto(x,y) for x,y in zip(xs, ys)])

def closeto_bbox(b1, b2):
    xmin1, xmax1 = b1.intervalx().get_bounds()
    ymin1, ymax1 = b1.intervaly().get_bounds()
    xmin2, xmax2 = b2.intervalx().get_bounds()
    ymin2, ymax2 = b2.intervaly().get_bounds()

    pairs = ( (xmin1, xmin2), (xmax1, xmax2), (ymin1, ymin2), (ymax1, ymax2))
    return alltrue([closeto(x,y) for x,y in pairs])
    
ll = Point( Value(10),  Value(10) )
ur = Point( Value(200), Value(40) )

bbox = Bbox(ll, ur)

assert(bbox.xmin()==10)
assert(bbox.width()==190)
assert(bbox.height()==30)

ll.x().set(12.0)
assert(bbox.xmin()==12)
assert(bbox.width()==188)
assert(bbox.height()==30)


a  = Value(10)
Ejemplo n.º 2
0
def closeto_seq(xs, ys):
    return alltrue([closeto(x, y) for x, y in zip(xs, ys)])


def closeto_bbox(b1, b2):
    xmin1, xmax1 = b1.intervalx().get_bounds()
    ymin1, ymax1 = b1.intervaly().get_bounds()
    xmin2, xmax2 = b2.intervalx().get_bounds()
    ymin2, ymax2 = b2.intervaly().get_bounds()

    pairs = ((xmin1, xmin2), (xmax1, xmax2), (ymin1, ymin2), (ymax1, ymax2))
    return alltrue([closeto(x, y) for x, y in pairs])


ll = Point(Value(10), Value(10))
ur = Point(Value(200), Value(40))

bbox = Bbox(ll, ur)

assert (bbox.xmin() == 10)
assert (bbox.width() == 190)
assert (bbox.height() == 30)

ll.x().set(12.0)
assert (bbox.xmin() == 12)
assert (bbox.width() == 188)
assert (bbox.height() == 30)

a = Value(10)
b = Value(0)
Ejemplo n.º 3
0
def rand_point():
    xy = rand(2)
    return Point(Value(xy[0]), Value(xy[1]))
Ejemplo n.º 4
0
    hist(im, 100)
    xticks([-1, -.5, 0, .5, 1])
    yticks([])
    xlabel('intensity')
    ylabel('MRI density')

if 1:  # plot the EEG
    # load the data
    numSamples, numRows = 800, 4
    data = fromstring(file('data/eeg.dat', 'rb').read(), float)
    data.shape = numSamples, numRows
    t = arange(numSamples) / float(numSamples) * 10.0
    ticklocs = []
    ax = subplot(212)

    boxin = Bbox(Point(ax.viewLim.ll().x(), Value(-20)),
                 Point(ax.viewLim.ur().x(), Value(20)))

    height = ax.bbox.ur().y() - ax.bbox.ll().y()
    boxout = Bbox(Point(ax.bbox.ll().x(),
                        Value(-1) * height),
                  Point(ax.bbox.ur().x(),
                        Value(1) * height))

    transOffset = get_bbox_transform(
        unit_bbox(),
        Bbox(Point(Value(0),
                   ax.bbox.ll().y()), Point(Value(1),
                                            ax.bbox.ur().y())))

    for i in range(numRows):
Ejemplo n.º 5
0
lineprops = dict(linewidth=1, color='black', linestyle='-')
fig = figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])

# The normal matplotlib transformation is the view lim bounding box
# (ax.viewLim) to the axes bounding box (ax.bbox).  Where are going to
# define a new transform by defining a new input bounding box. See the
# matplotlib.transforms module helkp for more information on
# transforms

# This bounding reuses the x data of the viewLim for the xscale -10 to
# 10 on the y scale.  -10 to 10 means that a signal with a min/max
# amplitude of 10 will span the entire vertical extent of the axes
scale = 10
boxin = Bbox(Point(ax.viewLim.ll().x(), Value(-scale)),
             Point(ax.viewLim.ur().x(), Value(scale)))

# height is a lazy value
height = ax.bbox.ur().y() - ax.bbox.ll().y()

boxout = Bbox(Point(ax.bbox.ll().x(),
                    Value(-0.5) * height),
              Point(ax.bbox.ur().x(),
                    Value(0.5) * height))

# matplotlib transforms can accepts an offset, which is defined as a
# point and another transform to map that point to display.  This
# transform maps x as identity and maps the 0-1 y interval to the
# vertical extent of the yaxis.  This will be used to offset the lines
# and ticks vertically
Ejemplo n.º 6
0
def rand_point():
    return Point( rand_val(), rand_val() )
Ejemplo n.º 7
0
def closeto_seq(xs, ys):
    return alltrue([closeto(x, y) for x, y in zip(xs, ys)])


def closeto_bbox(b1, b2):
    xmin1, xmax1 = b1.intervalx().get_bounds()
    ymin1, ymax1 = b1.intervaly().get_bounds()
    xmin2, xmax2 = b2.intervalx().get_bounds()
    ymin2, ymax2 = b2.intervaly().get_bounds()

    pairs = ((xmin1, xmin2), (xmax1, xmax2), (ymin1, ymin2), (ymax1, ymax2))
    return alltrue([closeto(x, y) for x, y in pairs])


ll = Point(Value(10), Value(10))
ur = Point(Value(200), Value(40))

bbox = Bbox(ll, ur)

assert (bbox.xmin() == 10)
assert (bbox.width() == 190)
assert (bbox.height() == 30)

ll.x().set(12.0)
assert (bbox.xmin() == 12)
assert (bbox.width() == 188)
assert (bbox.height() == 30)

a = Value(10)
b = Value(0)
Ejemplo n.º 8
0
# Timing tests -- print time per plot
TIME_PY  = 1
TIME_EXT = 1


#################
# Test Parameters
#################

# Bounding box to use in testing
ll_x = 320
ll_y = 240
ur_x = 640
ur_y = 480
BBOX = Bbox(Point(Value(ll_x), Value(ll_y)),
            Point(Value(ur_x), Value(ur_y)))

# Number of iterations for timing
NITERS = 25


###############################################################################


#
# Testing framework
#

def time_loop(function, args):
    i = 0