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 _checkProvenance(self, resp, item, version, user, eventType,
                         matches=None, fileInfo=None, resource='item'):
        if resp is None:
            resp = self._getProvenance(item, user, resource=resource)
        self.assertStatusOk(resp)
        itemProvenance = resp.json
        self.assertEqual(itemProvenance['resourceId'], str(item['_id']))
        provenance = itemProvenance['provenance']
        self.assertEqual(provenance['eventType'], eventType)
        self.assertEqual(provenance['version'], version)
        self.assertEqual(str(provenance['eventUser']), str(user['_id']))
        if matches:
            for key in matches:
                self.assertEqual(provenance[key], matches[key])
        if fileInfo:
            for key in fileInfo:
                if isinstance(fileInfo[key], dict):
                    for subkey in fileInfo[key]:
                        self.assertEqual(provenance['file'][0][key][subkey],
                                         fileInfo[key][subkey])
                else:
                    self.assertEqual(provenance['file'][0][key], fileInfo[key])