def test_views():
    X = np.array(X_list)
    adata = ad.AnnData(X, obs=obs_dict, var=var_dict, uns=uns_dict, dtype="int32")

    assert adata[:, 0].is_view
    assert adata[:, 0].X.tolist() == np.reshape([1, 4, 7], (3, 1)).tolist()

    adata[:2, 0].X = [0, 0]

    assert adata[:, 0].X.tolist() == np.reshape([0, 0, 7], (3, 1)).tolist()

    adata_subset = adata[:2, [0, 1]]

    assert adata_subset.is_view
    # now transition to actual object
    adata_subset.obs["foo"] = range(2)
    assert not adata_subset.is_view

    assert adata_subset.obs["foo"].tolist() == list(range(2))
def execute_rpc(self, audit_name, rpc_code, response_queue, args, kwargs):
        """
        Honor a remote procedure call request from a plugin.

        :param audit_name: Name of the audit requesting the call.
        :type audit_name: str

        :param rpc_code: RPC code.
        :type rpc_code: int

        :param response_queue: Response queue identity.
        :type response_queue: str

        :param args: Positional arguments to the call.
        :type args: tuple

        :param kwargs: Keyword arguments to the call.
        :type kwargs: dict
        """
        try:

            # Get the implementor for the RPC code.
            # Raise NotImplementedError if it's not defined.
            try:
                target, blocking = self.__rpcMap[rpc_code]
            except KeyError:
                raise NotImplementedError(
                    "RPC code not implemented: %r" % rpc_code)

            # If it's a blocking call...
            if blocking:

                # Run the implementor in a new thread.
                thread = Thread(
                    target = self._execute_rpc_implementor_background,
                    args = (
                        Config._context,
                        audit_name,
                        target,
                        response_queue,
                        args, kwargs),
                )
                thread.daemon = True
                thread.start()

            # If it's a non-blocking call...
            else:

                # Call the implementor directly.
                self.execute_rpc_implementor(
                    audit_name, target, response_queue, args, kwargs)

        # Catch exceptions and send them back.
        except Exception:
            if response_queue:
                error = self.prepare_exception(*sys.exc_info())
                try:
                    self.orchestrator.messageManager.send(
                        response_queue, (False, error))
                except IOError:
                    import warnings
                    warnings.warn("RPC caller died!")
                    pass