def _parsevals(self, value): if isinstance(value, Table): return value._dmatx.astype(self.dtype) if isinstance(value, np.ndarray): return value.astype(self.dtype) if not iterable(value): return value value = ll(value) if not iterable(value[0]): return np.asarray(value, dtype = self.dtype) value = np.asarray(value if isinstance(value, np.ndarray) and value.ndim == 2 else smap(value, ll), dtype = self.dtype) return value
def _parsevals(self, value): if isinstance(value, StructuredArray): return [value._arrs[n].copy() for n in self._arrs.keys()] if not iterable(value): return value value = ll(value) if not iterable(value[0]): return np.asarray(value) value = smap(value, lambda x: np.asarray(ll(x))) if not len(set(smap(value, len))) == 1: raise ValueError('input arrays not in the same size') return value
def _parsevals(value, arrayonly=False): if isinstance(value, NamedIndex): val = value._names elif iterable(value): val = np.asarray(ll(value), dtype=object) if checkany(val, lambda x: not isstring(x)): raise TypeError('index names must be string') else: if arrayonly: raise TypeError('index names must be an array') if not isstring(value): raise TypeError('index name must be a string') val = value return val
def __init__(self, items: Optional[Union[Iterable, Mapping, np.ndarray, StructuredArray]] = None, **kwargs: Iterable): if isinstance(items, StructuredArray): self._arrs, self._length = items._arrs.copy(), items._length return vals = [(k, items[k]) for k in items.dtype.names] if isinstance(items, np.ndarray) and available(items.dtype.names) else \ items.items() if ismapping(items) else \ items if iterable(items) else \ kwargs.items() if missing(items) else None if missing(vals): raise TypeError('unknow data type') self._arrs = OrderedDict() self._length = None for k, v in vals: self[k] = v
def library(*args: Union[str, Iterable[str]], mute: bool = True) -> None: if len(args) == 1 and iterable(args[0]): args = args[0] with warnings.catch_warnings(): if mute: warnings.filterwarnings('ignore') for pkg in args: rpkg.importr(pkg, suppress_messages=mute)