@contextmanager
    def vec_context(self, readonly=True):

        assert self.dtype == PETSc.ScalarType, \
            "Can't create Vec with type %s, must be %s" % (self.dtype, PETSc.ScalarType)
        acc = (lambda d: d.data_ro) if readonly else (lambda d: d.data)
        # Getting the Vec needs to ensure we've done all current computation.
        # If we only want readonly access then there's no need to
        # force the evaluation of reads from the Dat.
        self._force_evaluation(read=True, write=not readonly)
        if not hasattr(self, '_vec'):
            # Can't duplicate layout_vec of dataset, because we then
            # carry around extra unnecessary data.
            # But use getSizes to save an Allreduce in computing the
            # global size.
            size = self.dataset.layout_vec.getSizes()
            self._vec = PETSc.Vec().createWithArray(acc(self), size=size,
                                                    bsize=self.cdim)
        # PETSc Vecs have a state counter and cache norm computations
        # to return immediately if the state counter is unchanged.
        # Since we've updated the data behind their back, we need to
        # change that state counter.
        self._vec.stateIncrease()
        yield self._vec
        if not readonly:
            self.needs_halo_update = True
Return keychain_items information from osquery
dataset/ETHPy150Open OP2/PyOP2/pyop2/petsc_base.py/Dat.vec_context--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/osquery.py/keychain_items