-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-dimensional indexing (e.g. obj[:, None]
) is no longer supported.
#38
Comments
the same ,have you fix it ? |
@speed090 I took a look at it today and fixed the issue. From your python installation, change the following code in (whichever location/version) python3.11/site-packages/SpatialDE/base.py. FROM:def get_l_limits(X): Kernels def SE_kernel(X, l): def linear_kernel(X): def cosine_kernel(X, p): TO:def get_l_limits(X): Kernels def SE_kernel(X, l): def linear_kernel(X): def cosine_kernel(X, p): The changes I made in the functions first explicitly casts the input 'X' as a np.array. I also changed the indexing using 'None' type to 'np.newaxis'. |
Thanks @Scoott, this worked for me. Submitted it as a PR but this repo seems to be not actively maintained. |
I get the following error running the scanpy spatial transcriptomics tutorial with the following command:
Traceback:
ValueError Traceback (most recent call last)
File :3
File /opt/homebrew/lib/python3.11/site-packages/SpatialDE/base.py:420, in run(X, exp_tab, kernel_space)
411 ''' Perform SpatialDE test
412
413 X : matrix of spatial coordinates times observations
(...)
417 model can be specifiec using the kernel_space paramter.
418 '''
419 if kernel_space == None:
--> 420 l_min, l_max = get_l_limits(X)
421 kernel_space = {
422 'SE': np.logspace(np.log10(l_min), np.log10(l_max), 10),
423 'const': 0
424 }
426 logging.info('Performing DE test')
File /opt/homebrew/lib/python3.11/site-packages/SpatialDE/base.py:26, in get_l_limits(X)
24 def get_l_limits(X):
25 Xsq = np.sum(np.square(X), 1)
---> 26 R2 = -2. * np.dot(X, X.T) + (Xsq[:, None] + Xsq[None, :])
27 R2 = np.clip(R2, 0, np.inf)
28 R_vals = np.unique(R2.flatten())
File /opt/homebrew/lib/python3.11/site-packages/pandas/core/series.py:1072, in Series.getitem(self, key)
1069 key = np.asarray(key, dtype=bool)
1070 return self._get_rows_with_mask(key)
-> 1072 return self._get_with(key)
File /opt/homebrew/lib/python3.11/site-packages/pandas/core/series.py:1082, in Series._get_with(self, key)
1077 raise TypeError(
1078 "Indexing a Series with DataFrame is not "
1079 "supported, use the appropriate DataFrame column"
1080 )
1081 elif isinstance(key, tuple):
-> 1082 return self._get_values_tuple(key)
1084 elif not is_list_like(key):
1085 # e.g. scalars that aren't recognized by lib.is_scalar, GH#32684
1086 return self.loc[key]
File /opt/homebrew/lib/python3.11/site-packages/pandas/core/series.py:1122, in Series._get_values_tuple(self, key)
1117 if com.any_none(*key):
1118 # mpl compat if we look up e.g. ser[:, np.newaxis];
1119 # see tests.series.timeseries.test_mpl_compat_hack
1120 # the asarray is needed to avoid returning a 2D DatetimeArray
1121 result = np.asarray(self._values[key])
-> 1122 disallow_ndim_indexing(result)
1123 return result
1125 if not isinstance(self.index, MultiIndex):
File /opt/homebrew/lib/python3.11/site-packages/pandas/core/indexers/utils.py:341, in disallow_ndim_indexing(result)
333 """
334 Helper function to disallow multi-dimensional indexing on 1D Series/Index.
335
(...)
338 in GH#30588.
339 """
340 if np.ndim(result) > 1:
--> 341 raise ValueError(
342 "Multi-dimensional indexing (e.g.
obj[:, None]
) is no longer "343 "supported. Convert to a numpy array before indexing instead."
344 )
ValueError: Multi-dimensional indexing (e.g.
obj[:, None]
) is no longer supported. Convert to a numpy array before indexing instead.The text was updated successfully, but these errors were encountered: