Skip to content

Type shape methods #6767

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

Merged
merged 1 commit into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion xarray/backends/pydap_.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, array):
self.array = array

@property
def shape(self):
def shape(self) -> tuple[int, ...]:
return self.array.shape

@property
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/rasterio_.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def dtype(self):
return self._dtype

@property
def shape(self):
def shape(self) -> tuple[int, ...]:
return self._shape

def _get_indexer(self, key):
Expand Down
2 changes: 1 addition & 1 deletion xarray/coding/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def dtype(self):
return np.dtype("S" + str(self.array.shape[-1]))

@property
def shape(self):
def shape(self) -> tuple[int, ...]:
return self.array.shape[:-1]

def __repr__(self):
Expand Down
6 changes: 3 additions & 3 deletions xarray/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def _updated_key(self, new_key):
return OuterIndexer(full_key)

@property
def shape(self):
def shape(self) -> tuple[int, ...]:
shape = []
for size, k in zip(self.array.shape, self.key.tuple):
if isinstance(k, slice):
Expand Down Expand Up @@ -569,7 +569,7 @@ def __init__(self, array, key):
self.array = as_indexable(array)

@property
def shape(self):
def shape(self) -> tuple[int, ...]:
return np.broadcast(*self.key.tuple).shape

def __array__(self, dtype=None):
Expand Down Expand Up @@ -1392,7 +1392,7 @@ def __array__(self, dtype: DTypeLike = None) -> np.ndarray:
return np.asarray(array.values, dtype=dtype)

@property
def shape(self) -> tuple[int]:
def shape(self) -> tuple[int, ...]:
return (len(self.array),)

def _convert_scalar(self, item):
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def dtype(self: Any) -> np.dtype:
return self.array.dtype

@property
def shape(self: Any) -> tuple[int]:
def shape(self: Any) -> tuple[int, ...]:
return self.array.shape

def __getitem__(self: Any, key):
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def __array_function__(self, *args, **kwargs):
return NotImplemented

@property
def shape(self):
def shape(self) -> tuple[int, ...]:
return self.value.shape

@property
Expand Down