From 9173fb6d6031b5c343c479b70c6a18306e79df90 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Mon, 19 Feb 2024 15:17:42 -0600 Subject: [PATCH] DictOfNamedArrays: better repr, keys --- pytato/array.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pytato/array.py b/pytato/array.py index 2771d835e..b3523964f 100644 --- a/pytato/array.py +++ b/pytato/array.py @@ -164,7 +164,7 @@ import operator import attrs from typing import ( - Optional, Callable, ClassVar, Dict, Any, Mapping, Tuple, Union, + KeysView, Optional, Callable, ClassVar, Dict, Any, Mapping, Tuple, Union, Protocol, Sequence, cast, TYPE_CHECKING, List, Iterator, TypeVar, FrozenSet, Collection) @@ -817,7 +817,12 @@ def __iter__(self) -> Iterator[str]: return iter(self._data) def __repr__(self) -> str: - return "DictOfNamedArrays(" + str(self._data) + ")" + return "DictOfNamedArrays(" + repr(self._data) + ")" + + # Note: items() and values() are not implemented here, they go through + # the __iter__()/__getitem__() above. + def keys(self) -> KeysView[str]: + return self._data.keys() # }}}