Example #1
0
    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
Example #2
0
    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