diff --git a/message_ix_models/util/scenarioinfo.py b/message_ix_models/util/scenarioinfo.py index 8025ae1c03..28caccd65b 100644 --- a/message_ix_models/util/scenarioinfo.py +++ b/message_ix_models/util/scenarioinfo.py @@ -132,22 +132,13 @@ def from_url(cls, url: str) -> "ScenarioInfo": def yv_ya(self): """:class:`pandas.DataFrame` with valid ``year_vtg``, ``year_act`` pairs.""" if self._yv_ya is None: - first = self.y0 - - # Product of all years - yv = ya = self.set["year"] - - # Predicate for filtering years - def _valid(elem): - yv, ya = elem - return first <= yv <= ya - # - Cartesian product of all yv and ya. - # - Filter only valid years. # - Convert to data frame. + # - Filter only valid years. self._yv_ya = pd.DataFrame( - filter(_valid, product(yv, ya)), columns=["year_vtg", "year_act"] - ) + product(self.set["year"], self.set["year"]), + columns=["year_vtg", "year_act"], + ).query("@self.y0 <= year_vtg <= year_act") return self._yv_ya