anndata
anndata copied to clipboard
Large float converted to inf during adata creation
When adding large numbers to X I get adata with inf value:
y=np.array(2.07547187e+114).reshape(1,1)
y
Out[72]: array([[2.07547187e+114]])
sc.AnnData(y)
Out[73]: AnnData object with n_obs × n_vars = 1 × 1
sc.AnnData(y).X
Out[74]: array([[inf]], dtype=float32)
sc.AnnData(y).X[0,0]==np.inf
Out[76]: True
Thanks for the report.
I think you'll be able to get around this by passing:
sc.AnnData(y, dtype=y.dtype)
for the next version, but this down casting won't happen anymore in 0.9.
I'm not sure if there's a great way to error for this specific case, as .astype(..., casting="safe")
will error in many more cases.
Do you have a specific use case here? E.g. did this occur during an analysis?
I'm trying to figure out how bad this is.
I was generating random data for testing - thus the extremely large numbers. never happened during analysis, at least not that I would know of.
This issue has been automatically marked as stale because it has not had recent activity. Please add a comment if you want to keep the issue open. Thank you for your contributions!
Fixed since 0.9.0!