Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/anndata/_core/anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def _init_as_actual( # noqa: PLR0912, PLR0913, PLR0915
msg = "`shape` needs to be `None` if `X` is not `None`."
raise ValueError(msg)
# data matrix and shape
n_obs, n_vars = X.shape
n_obs, n_vars = X.shape[:2]
source = "X"
else:
n_obs, n_vars = (
Expand Down Expand Up @@ -603,13 +603,13 @@ def X(self, value: _XDataType | None) -> None:
msg = "The ability to set X with a scalar value will be removed in the future. Initializing as an `np.array` with the shape of the current view."
warn(msg, FutureWarning)
value = np.full(self.shape, fill_value=value)
if hasattr(value, "shape") and value.shape != self.shape:
if hasattr(value, "shape") and value.shape[:2] != self.shape:
msg = "Automatic reshaping when setting X will be removed in the future."
warn(msg, FutureWarning)
value = value.reshape(self.shape)
can_set_direct_if_not_none = (
value is None
or (hasattr(value, "shape") and (self.shape == value.shape))
or (hasattr(value, "shape") and (self.shape == value.shape[:2]))
or (self.n_vars == 1 and self.n_obs == len(value))
or (self.n_obs == 1 and self.n_vars == len(value))
)
Expand Down
Loading