33import numpy as np
44import pandas as pd
55import scipy .sparse as sp
6- import torch
76
87modALinput = Union [sp .csr_matrix , pd .DataFrame , np .ndarray , list ]
98
@@ -26,8 +25,6 @@ def data_vstack(blocks: Sequence[modALinput]) -> modALinput:
2625 return np .concatenate (blocks )
2726 elif isinstance (blocks [0 ], list ):
2827 return np .concatenate (blocks ).tolist ()
29- elif torch .is_tensor (blocks [0 ]):
30- return torch .cat (blocks )
3128
3229 raise TypeError ('%s datatype is not supported' % type (blocks [0 ]))
3330
@@ -50,8 +47,6 @@ def data_hstack(blocks: Sequence[modALinput]) -> modALinput:
5047 return np .hstack (blocks )
5148 elif isinstance (blocks [0 ], list ):
5249 return np .hstack (blocks ).tolist ()
53- elif torch .is_tensor (blocks [0 ]):
54- return torch .cat (blocks , dim = 1 )
5550
5651 TypeError ('%s datatype is not supported' % type (blocks [0 ]))
5752
@@ -65,8 +60,6 @@ def add_row(X: modALinput, row: modALinput):
6560 row] """
6661 if isinstance (X , np .ndarray ):
6762 return np .vstack ((X , row ))
68- elif torch .is_tensor (X ):
69- return torch .cat ((X , row ))
7063 elif isinstance (X , list ):
7164 return np .vstack ((X , row )).tolist ()
7265
@@ -107,8 +100,6 @@ def retrieve_rows(X: modALinput,
107100 return X_return
108101 elif isinstance (X , np .ndarray ):
109102 return X [I ]
110- elif torch .is_tensor (X ):
111- return X [I ]
112103
113104 raise TypeError ('%s datatype is not supported' % type (X ))
114105
@@ -128,9 +119,6 @@ def drop_rows(X: modALinput,
128119 return np .delete (X , I , axis = 0 )
129120 elif isinstance (X , list ):
130121 return np .delete (X , I , axis = 0 ).tolist ()
131- elif torch .is_tensor (X ):
132- return X [[True if row not in I else False
133- for row in range (X .size (0 ))]]
134122
135123 raise TypeError ('%s datatype is not supported' % type (X ))
136124
@@ -149,8 +137,8 @@ def enumerate_data(X: modALinput):
149137 return enumerate (X .tocsr ())
150138 elif isinstance (X , pd .DataFrame ):
151139 return X .iterrows ()
152- elif isinstance (X , np .ndarray ) or isinstance (X , list ) or torch . is_tensor ( X ) :
153- # numpy arrays, torch tensors and lists can readily be enumerated
140+ elif isinstance (X , np .ndarray ) or isinstance (X , list ):
141+ # numpy arrays and lists can readily be enumerated
154142 return enumerate (X )
155143
156144 raise TypeError ('%s datatype is not supported' % type (X ))
@@ -165,7 +153,5 @@ def data_shape(X: modALinput):
165153 return X .shape
166154 elif isinstance (X , list ):
167155 return np .array (X ).shape
168- elif torch .is_tensor (X ):
169- return tuple (X .size ())
170156
171157 raise TypeError ('%s datatype is not supported' % type (X ))
0 commit comments