Skip to content

Commit d65fc0a

Browse files
author
Jesse Grabowski
committed
Fix iterator, add to_dict method to CoordsInfo
1 parent 7f32a48 commit d65fc0a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pymc_extras/statespace/core/properties.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ def __contains__(self, key: object) -> bool:
6161
return key in self._index
6262

6363
def __iter__(self) -> Iterator[str]:
64-
return iter(self._index)
64+
return iter(self.items)
6565

6666
def __len__(self) -> int:
67-
return len(self._index)
67+
return len(self.items)
6868

6969
def __str__(self) -> str:
7070
return f"{self.key_field}s: {list(self._index.keys())}"
@@ -146,6 +146,9 @@ def default_coords_from_model(cls, model: Component | PyMCStateSpace) -> Self:
146146
coords = [Coord(dimension=dim, labels=labels) for dim, labels in dim_to_labels]
147147
return cls(coords)
148148

149+
def to_dict(self):
150+
return {coord.dimension: coord.labels for coord in self.items if len(coord.labels) > 0}
151+
149152

150153
@dataclass(frozen=True)
151154
class State(Property):

0 commit comments

Comments
 (0)