コード例 #1
0
def test_get_column() :
    nt = NTuple('A', 'B')
    for x in range(100) :
        nt.fill('A', x)
        nt.fill('B', x*100)
        nt.write()
    A = nt.column('A')
    ntl.assert_true(A == range(100))
    B = nt.column('B')
    ntl.assert_true(B == [ x*100 for x in range(100)])
コード例 #2
0
def test_get_with_cross_cut() :
    nt = NTuple('A', 'B')
    for x in range(100) :
        nt.fill('A', x)
        nt.fill('B', x*100)
        nt.write()
    col = nt.column('B',lambda x : x.A > 50 and x.B < 8500 )
    ntl.assert_true(col == [x*100 for x in xrange(51, 85)])
コード例 #3
0
def test_get_with_cut() :
    nt = NTuple('A', 'B')
    for x in range(100) :
        nt.fill('A', x)
        nt.fill('B', x*100)
        nt.write()
    col = nt.column('A',lambda x : x.A > 50 )
    ntl.assert_true(col == range(51, 100))
コード例 #4
0
import math
from random import gauss
from pyhistuples.pyntuple.ntuple import NTuple
from matplotlib import pyplot

mu_p = 15.
mu_pt = 5.
sigma_p = 10.
sigma_pt = 5.

nt = NTuple('x', 'p', 'pt')

for x in xrange(10000) :
    nt.fill('x',x)
    nt.fill('p', gauss(mu_p, sigma_p))
    nt.fill('pt', gauss(mu_pt, sigma_pt))
    nt.write()

x = nt.column('x', lambda row : row.p > 5. and row.pt > 1.)