Пример #1
0
# test positive bounding box
x = arange(-1.0001, 1.0, 0.01)
bpos = Bound1D(.1, 1, isPos=True)
bpos.update(x)
assert (bpos.min() > 0)
bpos.is_positive(False)
bpos.update(x)
assert (bpos.min() == -1.0001)

print 'passed positive bounding box tests ...'

# testing transforms
i1 = Bound1D(0, 1)
i2 = Bound1D(-6, 6)
identityTrans = Transform()
linearTrans = Transform(i1, i2)
logTrans = Transform(Bound1D(0.1, 1), i2, funcs=(log10, pow10))

scalar = 1
tup = 1, 2, 3
a = arange(0.0, 2.0, 0.1)

assert (identityTrans.positions(scalar) == scalar)
assert (identityTrans.positions(tup) == tup)
assert (identityTrans.positions(a) == a)
assert (identityTrans.scale(scalar) == scalar)
assert (identityTrans.scale(tup) == tup)
assert (identityTrans.scale(a) == a)

assert (linearTrans.positions(1) == 6)
Пример #2
0
    set(gca(), '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)

    height = 72  # height of one EEG in pixels
    # transform data to axes coord (0,1)
    transy = Transform(Bound1D(-.05, .05), Bound1D(-.2, .2))
    for i in range(numRows):
        thisLine = Line2D(ax.dpi,
                          ax.bbox,
                          t,
                          data[:, i] - data[0, i],
                          transx=ax.xaxis.transData,
                          transy=transy)
        offset = (i + 1) / (numRows + 1)
        thisLine.set_vertical_offset(offset, ax.yaxis.transAxis)

        ax.add_line(thisLine)
        ticklocs.append(offset)

    set(gca(), 'xlim', [0, 10])
    set(gca(), 'xticks', arange(10))