Esempio n. 1
0
def underride(a:tvstruct, b:pydict) -> tvstruct:
    answer = tvstruct(a)
    for k, v in b.items():
        if k not in answer:
            answer[k] = v
        # answer._setdefault(k, v)      # this doesn't respect insertion order!!
    return answer
Esempio n. 2
0
def select(a: agg, fn1) -> agg:
    fs = a._names()
    cols = [c for c in a._values()
            ]  #a >> values >> std.each >> anon(lambda c: c)
    # collate the offsets that fn1 answers true
    os = []
    for o in range(cols[0].shape[0]):
        r = tvstruct(zip(fs, [c[o] for c in cols]))
        if fn1(r): os.append(o)
    # create new cols from the old cols and the offsets
    newCols = [c[os] for c in cols]
    return agg(zip(fs, newCols))
Esempio n. 3
0
def test():
    fred = tvstruct(pystr**(pystr * pyint), [[1, 2]])
    fred.a = 1
    fred.b = 2
    print(fred['a'])
    fred['a'] = 5
    fred._fred = 1
    fred = fred | pystr**(pystr * pyint)
    print(fred._fred)
    print(repr(fred))
    print(str(fred))
    for k, v in fred._nvs():
        print(k, v)
Esempio n. 4
0
def override(a:tvstruct, b:pydict) -> tvstruct:
    answer = tvstruct(a)
    answer._update(b)
    return answer
Esempio n. 5
0
def override(a:tvstruct, b:tvstruct) -> tvstruct:
    answer = tvstruct(a)
    answer._update(b._nvs())
    return answer
Esempio n. 6
0
def sort(x: tvstruct) -> tvstruct:
    return tvstruct(sorted(x._nvs(), key=None, reverse=False))
Esempio n. 7
0
def select(pm: (T1**T2)[tvstruct][T3], f2) -> (T1**T2)[tvstruct][T3]:
    filteredKVs = []
    for k, v in pm._v._nvs():
        if f2(k, v): filteredKVs.append((k, v))
    return tvstruct(pm._t, filteredKVs)
Esempio n. 8
0
def select(pm: tvstruct, f2) -> tvstruct:
    filteredKVs = []
    for k, v in pm._nvs():
        if f2(k, v): filteredKVs.append((k, v))
    return tvstruct(pm._t, filteredKVs)
Esempio n. 9
0
def _makePmf(*args, **kwargs):
    return _normalisedInPlace(tvstruct(*args, **kwargs))
Esempio n. 10
0
def pair(a, b):
    return tvstruct(tPair[tvstruct], a=a, b=b)