示例#1
0
def test_table():
    s = rst.table([['v1', 'i'], ['V', 'A'], [1,2e-3], [3,4e-3]], headerrows=2)
    assert_equal(s, """==== =======
v1   i      
V    A      
==== =======
   1   0.002
   3   0.004
==== =======""")
示例#2
0
def test_table():
    s = rst.table([['v1', 'i'], ['V', 'A'], [1, 2e-3], [3, 4e-3]],
                  headerrows=2)
    assert_equal(
        s, """==== =======
v1   i      
V    A      
==== =======
   1   0.002
   3   0.004
==== =======""")
示例#3
0
def astable(*waveforms):
    """Return a table of one or more waveforms with the same sweeps in text format

    Examples:
    
    >>> w1 = Waveform([range(2)], array([3,4]), ylabel='V1')
    >>> w2 = Waveform([range(2)], array([4,6]), ylabel='V2')
    >>> print astable(w1,w2)
    ====  ====  ====
    x0    V1    V2  
    ====  ====  ====
       0     3     4
       1     4     6
    ====  ====  ====

    """
    from pycircuit.utilities import rst

    xvalues, yvalues = [a.tolist() for a in to_xy_matrices(*waveforms)]

    xlabels = waveforms[0].xlabels
    ylabels = [w.ylabel for w in waveforms]
    xunits = waveforms[0].xunits
    yunits = [w.yunit for w in waveforms]

    hasunits = not reduce(operator.__and__, [yunit == '' for yunit in yunits])
    
    if hasunits:
        return rst.table(map(lambda x,y: list(x) + list(y), 
                                       [xlabels] + [xunits] + xvalues, 
                                       [ylabels] + [yunits] + yvalues), 
                              headerrows = 2)
    else:
        return rst.table(map(lambda x,y: list(x) + list(y), 
                                       [xlabels] + xvalues, 
                                       [ylabels] + yvalues))
示例#4
0
def astable(*waveforms):
    """Return a table of one or more waveforms with the same sweeps in text format

    Examples:
    
    >>> w1 = Waveform([range(2)], array([3,4]), ylabel='V1')
    >>> w2 = Waveform([range(2)], array([4,6]), ylabel='V2')
    >>> print astable(w1,w2)
    ====  ====  ====
    x0    V1    V2  
    ====  ====  ====
       0     3     4
       1     4     6
    ====  ====  ====

    """
    from pycircuit.utilities import rst

    xvalues, yvalues = [a.tolist() for a in to_xy_matrices(*waveforms)]

    xlabels = waveforms[0].xlabels
    ylabels = [w.ylabel for w in waveforms]
    xunits = waveforms[0].xunits
    yunits = [w.yunit for w in waveforms]

    hasunits = not reduce(operator.__and__, [yunit == '' for yunit in yunits])
    
    if hasunits:
        return rst.table(map(lambda x,y: list(x) + list(y), 
                                       [xlabels] + [xunits] + xvalues, 
                                       [ylabels] + [yunits] + yvalues), 
                              headerrows = 2)
    else:
        return rst.table(map(lambda x,y: list(x) + list(y), 
                                       [xlabels] + xvalues, 
                                       [ylabels] + yvalues))