def asarray(t, fill=np.nan): ts = tshape(t) if ts == None: t = astuple(t) ts = tshape(t) if ts == None: raise RuntimeError('Attempt to convert an unsafe tuple to array') if len(ts[1]) > 1: return np.array(t, np.object) ragged = type(ts[0][-1]) == tuple if not ragged: a = np.array(t) else: s = ts[0][:-1] + (ts[0][-1][-1],) ty = ts[1][0] q = ty(1.0) aty = np.array([q]).dtype a = np.ones(s, aty) * fill for co, v in rtcoords(t): a[co] = v return a
def a2t(doc): for k in doc.keys(-1, None, True, False): v = doc[k] if classify(v) == "#": doc[k] = astuple(v)