def __getitem__(self, slc): # no slicing in parallel if pet_count() > 1: raise SerialMethod # format and copy slc = get_formatted_slice(slc, self.rank) ret = self.copy() # coords, mask and area ret._coords = [[ get_none_or_ssslice( get_none_or_slice(get_none_or_slice(self.coords, stagger), coorddim), slc, stagger, self.rank) for coorddim in range(self.rank) ] for stagger in range(2**self.rank)] ret._mask = [ get_none_or_slice(get_none_or_slice(self.mask, stagger), slc) for stagger in range(2**self.rank) ] ret._area = [ get_none_or_slice(get_none_or_slice(self.area, stagger), slc) for stagger in range(2**self.rank) ] # upper bounds are "sliced" by taking the shape of the coords ret._upper_bounds = [ get_none_or_bound(get_none_or_slice(ret.coords, stagger), 0) for stagger in range(2**self.rank) ] # lower bounds do not need to be sliced yet because slicing is not yet enabled in parallel return ret
def __getitem__(self, slc): # initialize slc_ls slc_ls = slc # check that this is actually a slicing operation and not just regular item retrieval if not isinstance(slc, str): # parallel slicing is not yet enabled (collective operation) if pet_count() > 1: raise SerialMethod # re-initialize slc_ls slc_ls = get_formatted_slice(slc, self.rank) # slice at will try: ret = super(LocStream, self).__getitem__(slc_ls) except TypeError: ret = self.copy() # upper bounds and size ret._upper_bounds = len(list(range(slc_ls.stop - slc_ls.start))) ret._size = ret.upper_bounds - ret.lower_bounds # keys for x in ret.keys(): ret[x] = super(LocStream, self).__getitem__(x)[slc_ls] return ret
def __getitem__(self, slc): if pet_count() > 1: raise SerialMethod slc = get_formatted_slice(slc, self.rank) ret = self.copy() # TODO: cannot get element coordinates, so the slice has them set to None ret._coords = [[get_none_or_slice(get_none_or_slice(get_none_or_slice(self.coords, 0), coorddim), slc) for coorddim in range(self.parametric_dim)], [None for x in range(self.parametric_dim)]] # size is "sliced" by taking the shape of the coords ret._size = [get_none_or_bound_list(get_none_or_slice(ret.coords, stagger), 0) for stagger in range(2)] ret._size_owned = ret.size return ret