Skip to content

Commit

Permalink
changed __getitem__ to use anndata's function
Browse files Browse the repository at this point in the history
  • Loading branch information
Intron7 authored Jan 18, 2023
1 parent 24b7494 commit 2e15090
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions rapids_singlecell/cunnData/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
#
# created by Severin Dicks (IBSM, Freiburg)
#
#

import cupy as cp
import cupyx as cpx
import anndata
from anndata._core.index import _normalize_indices

import numpy as np
import pandas as pd
import scipy
import math
from scipy import sparse
from typing import Any, Union, Optional, Mapping
from pandas.api.types import infer_dtype

import warnings
from natsort import natsorted

from scipy.sparse import issparse as issparse_cpu
from cupyx.scipy.sparse import issparse as issparse_gpu

from cuml.linear_model import LinearRegression


class Layer_Mapping(dict):
"""
Expand Down Expand Up @@ -205,18 +196,7 @@ def _sanitize(self):
df[key] = c

def __getitem__(self, index):
if type(index) == tuple:
obs_dx, var_dx = index
else:
obs_dx = index
var_dx = slice(None,None,None)

if isinstance(obs_dx,pd.Series):
obs_dx = obs_dx.values

if isinstance(var_dx,pd.Series):
var_dx = var_dx.values

obs_dx,var_dx = _normalize_indices(index, self.obs_names, self.var_names)
self.X = self.X[obs_dx,var_dx]
self._update_shape()
if self.layers:
Expand Down Expand Up @@ -283,4 +263,4 @@ def to_AnnData(self):
if self.varm:
for key, matrix in self.varm.items():
adata.varm[key] = matrix.copy()
return adata
return adata

0 comments on commit 2e15090

Please sign in to comment.