Skip to content

Commit

Permalink
added warning for non-dtype transform in copy
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf committed Oct 29, 2018
1 parent a8dfef5 commit 989f13e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions anndata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,14 @@ def to_df(self):
def copy(self, filename=None):
"""Full copy, optionally on disk."""
if not self.isbacked:
if self._X is not None and self._X.dtype.name != 'float32':
logger.warn(
'Up to anndata 0.6.11, `.copy()` cast a '
'non-\'float32\' data matrix X to \'float32\'. '
'Now, your matrix of dtype \'{}\' maintains this dtype during copy. '
'This might change low-variance components in PCA etc. '
'To reproduce the previous behavior, set `adata.X = adata.X.astype(\'float32\')`. '
.format(self._X.dtype.name))
return AnnData(self._X.copy() if self._X is not None else None,
self._obs.copy(),
self._var.copy(),
Expand Down

0 comments on commit 989f13e

Please sign in to comment.