Skip to content

Commit cfca8f5

Browse files
committed
(fix): nbytes value
1 parent 6134d10 commit cfca8f5

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

xarray/core/formatting.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,7 @@ def summarize_variable(
336336
else:
337337
dims_str = ""
338338

339-
try:
340-
nbytes_str = f" {render_human_readable_nbytes(variable.nbytes)}"
341-
except TypeError:
342-
nbytes_str = " ?"
339+
nbytes_str = f" {render_human_readable_nbytes(variable.nbytes)}"
343340
front_str = f"{first_col}{dims_str}{variable.dtype}{nbytes_str} "
344341

345342
values_width = max_width - len(front_str)

xarray/core/indexing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,9 @@ def copy(self, deep: bool = True) -> Self:
19281928

19291929
@property
19301930
def nbytes(self) -> int:
1931-
return self.array.nbytes
1931+
if pd.api.types.is_extension_array_dtype(self.dtype):
1932+
return self.array.nbytes
1933+
return cast(np.dtype, self.dtype).itemsize * len(self.array)
19321934

19331935

19341936
class PandasMultiIndexingAdapter(PandasIndexingAdapter):

0 commit comments

Comments
 (0)