Skip to content

Commit b2fbc96

Browse files
Fix broken iterator in python>=3.13.1,<3.13.4 #144 (#145)
- Patch ``PeriodSeries.to_timeseries()`` due to a regression with iterator behaviour in Python versions >=3.13.1, <3.13.4 #144 See python/cpython#127682 for more information about the issue.
1 parent 72cf254 commit b2fbc96

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎CHANGELOG.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
=========
33

4+
dev
5+
---
6+
7+
**Bugfixes**
8+
9+
- Patch ``PeriodSeries.to_timeseries()`` due to a regression with iterator behaviour in Python versions >=3.13.1, <3.13.4
10+
11+
412
0.14.5
513
------
614

‎energyquantified/data/periodseries.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,20 @@ def __init__(
573573
# Iterator stuff
574574
self.d = None
575575
self.p = None
576+
self._is_first_iter = True
576577

577578
def __iter__(self):
578579
# No periods available
579580
if not self.periods:
580581
return (p for p in self.periods)
581-
# Get first period
582-
self.d = self.begin
583-
self.p = self.periods.pop(0)
584582
return self
585583

586584
def __next__(self):
585+
if self._is_first_iter:
586+
# Get first period
587+
self.d = self.begin
588+
self.p = self.periods.pop(0)
589+
self._is_first_iter = False
587590
# Get dates and current period
588591
p = self.p
589592
d0 = self.d

0 commit comments

Comments
 (0)