def __getitem__(self, key): trans1d = self.trans1d ndmin = self.ndmin objs = [] scalars = [] arraytypes = [] scalartypes = [] if isinstance(key, str): raise NotImplementedError if not isinstance(key, tuple): key = (key,) for i, k in enumerate(key): scalar = False if isinstance(k, slice): raise NotImplementedError elif isinstance(k, str): if i != 0: raise ValueError( 'special directives must be the first entry.') raise NotImplementedError elif type(k) in numpy.ScalarType: newobj = from_data.array(k, ndmin=ndmin) scalars.append(i) scalar = True scalartypes.append(newobj.dtype) else: newobj = from_data.array(k, copy=False, ndmin=ndmin) if ndmin > 1: ndim = from_data.array(k, copy=False).ndim if trans1d != -1 and ndim < ndmin: newobj = self._output_obj(newobj, ndim, ndmin, trans1d) objs.append(newobj) if not scalar and isinstance(newobj, core.ndarray): arraytypes.append(newobj.dtype) final_dtype = numpy.find_common_type(arraytypes, scalartypes) if final_dtype is not None: for k in scalars: objs[k] = objs[k].astype(final_dtype) return join.concatenate(tuple(objs), axis=self.axis)
def __getitem__(self, key): trans1d = self.trans1d ndmin = self.ndmin objs = [] scalars = [] arraytypes = [] scalartypes = [] if isinstance(key, six.string_types): raise NotImplementedError if not isinstance(key, tuple): key = (key,) for i, k in enumerate(key): scalar = False if isinstance(k, slice): raise NotImplementedError elif isinstance(k, six.string_types): if i != 0: raise ValueError( 'special directives must be the first entry.') raise NotImplementedError elif type(k) in numpy.ScalarType: newobj = from_data.array(k, ndmin=ndmin) scalars.append(i) scalar = True scalartypes.append(newobj.dtype) else: newobj = from_data.array(k, copy=False, ndmin=ndmin) if ndmin > 1: ndim = from_data.array(k, copy=False).ndim if trans1d != -1 and ndim < ndmin: newobj = self._output_obj(newobj, ndim, ndmin, trans1d) objs.append(newobj) if not scalar and isinstance(newobj, core.ndarray): arraytypes.append(newobj.dtype) final_dtype = numpy.find_common_type(arraytypes, scalartypes) if final_dtype is not None: for k in scalars: objs[k] = objs[k].astype(final_dtype) return join.concatenate(tuple(objs), axis=self.axis)
def _get_memory_ptrs(x): if x.dtype.kind != 'c': return _get_memory_ptrs_kernel(x) return join.concatenate( [_get_memory_ptrs_kernel(x.real), _get_memory_ptrs_kernel(x.imag)])