You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Tutorial_Reference_mappying.ipynb, the following lines raise an error
forkinidx_list:
iffaiss_imported:
idx=labels[k]
else:
idx, sim=get_similar_vectors(test_emebd[k][np.newaxis, ...], ref_cell_embeddings, k)
pred=mode(ref_embed_adata.obs[cell_type_key][idx], axis=0) # I made this change. scipy.stats.mode no longer accepts non-numeric valuespreds.append(pred[0][0])
TypeError Traceback (most recent call last)
/tmp/ipykernel_21913/2423575529.py in ?()
17 if faiss_imported:
18 idx = labels[k]
19 else:
20 idx, sim = get_similar_vectors(test_emebd[k][np.newaxis, ...], ref_cell_embeddings, k)
---> 21 pred = (ref_embed_adata.obs[cell_type_key][idx], axis=0) # I made this change. scipy.stats.mode no longer accepts non-numeric values
22 preds.append(pred[0][0])
23 # preds.append(stat_mode(np.array(ref_embed_adata.obs[cell_type_key][idx])))
24
/usr/local/lib/python3.10/dist-packages/scipy/stats/_axis_nan_policy.py in ?(failed resolving arguments)
519 # behavior of those would break backward compatibility.
520
521 if sentinel:
522 samples = _remove_sentinel(samples, paired, sentinel)
--> 523 res = hypotest_fun_out(*samples, **kwds)
524 res = result_to_tuple(res)
525 res = _add_reduced_axes(res, reduced_axes, keepdims)
526 return tuple_to_result(*res)
/usr/local/lib/python3.10/dist-packages/scipy/stats/_stats_py.py in ?(a, axis, nan_policy, keepdims)
507 message = ("Argument a is not recognized as numeric. "
508 "Support for input that cannot be coerced to a numeric "
509 "array was deprecated in SciPy 1.9.0 and removed in SciPy "
510 "1.11.0. Please consider np.unique.")
--> 511 raise TypeError(message)
512
513 if a.size == 0:
514 NaN = _get_nan(a)
TypeError: Argument a is not recognized as numeric. Support for input that cannot be coerced to a numeric array was deprecated in SciPy 1.9.0 and removed in SciPy 1.11.0. Please consider np.unique.mode
My current workaround:
fromstatisticsimportmodeasstat_modeforkinidx_list:
iffaiss_imported:
idx=labels[k]
else:
idx, sim=get_similar_vectors(test_emebd[k][np.newaxis, ...], ref_cell_embeddings, k)
# pred = mode(ref_embed_adata.obs[cell_type_key][idx], axis=0) # I made this change. scipy.stats.mode no longer accepts non-numeric values# preds.append(pred[0][0])preds.append(stat_mode(np.array(ref_embed_adata.obs[cell_type_key][idx])))
Just want to confirm if this is workaround is appropriate. Thanks!
The text was updated successfully, but these errors were encountered:
Thank you @xinyu-dev ! and yes, looks like it is related to scipy version changes. The workaround looks good to me. I am also going to update a fix right now. Going to use the pandas built-in value counts, it can be faster supposedly
In Tutorial_Reference_mappying.ipynb, the following lines raise an error
TypeError Traceback (most recent call last)
/tmp/ipykernel_21913/2423575529.py in ?()
17 if faiss_imported:
18 idx = labels[k]
19 else:
20 idx, sim = get_similar_vectors(test_emebd[k][np.newaxis, ...], ref_cell_embeddings, k)
---> 21 pred = (ref_embed_adata.obs[cell_type_key][idx], axis=0) # I made this change. scipy.stats.mode no longer accepts non-numeric values
22 preds.append(pred[0][0])
23 # preds.append(stat_mode(np.array(ref_embed_adata.obs[cell_type_key][idx])))
24
/usr/local/lib/python3.10/dist-packages/scipy/stats/_axis_nan_policy.py in ?(failed resolving arguments)
519 # behavior of those would break backward compatibility.
520
521 if sentinel:
522 samples = _remove_sentinel(samples, paired, sentinel)
--> 523 res = hypotest_fun_out(*samples, **kwds)
524 res = result_to_tuple(res)
525 res = _add_reduced_axes(res, reduced_axes, keepdims)
526 return tuple_to_result(*res)
/usr/local/lib/python3.10/dist-packages/scipy/stats/_stats_py.py in ?(a, axis, nan_policy, keepdims)
507 message = ("Argument
a
is not recognized as numeric. "508 "Support for input that cannot be coerced to a numeric "
509 "array was deprecated in SciPy 1.9.0 and removed in SciPy "
510 "1.11.0. Please consider
np.unique
.")--> 511 raise TypeError(message)
512
513 if a.size == 0:
514 NaN = _get_nan(a)
TypeError: Argument
a
is not recognized as numeric. Support for input that cannot be coerced to a numeric array was deprecated in SciPy 1.9.0 and removed in SciPy 1.11.0. Please considernp.unique
.modeMy current workaround:
Just want to confirm if this is workaround is appropriate. Thanks!
The text was updated successfully, but these errors were encountered: