Skip to content

Commit

Permalink
Pandas now produces a FutureWarning for frequency descriptor 'H'.
Browse files Browse the repository at this point in the history
Use 'h' instead.

* nemo/context.py: Use 'h' for hourly frequency ('H' is deprecated).
* nemo/nem.py, nemo/sim.py: Likewise.
* tests/test_context.py, tests/test_sim.py: Likewise.
  • Loading branch information
bje- committed Jan 25, 2024
1 parent ef17ffa commit 2bde735
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nemo/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __str__(self):
# constant). Group by the deltas.
date_range = pd.date_range(self.unserved.index[0],
periods=len(self.unserved.index),
freq='H')
freq='h')
deltas = self.unserved.groupby(self.unserved.index - date_range)
unserved_events = [k for k, g in deltas]
string += 'Number of unserved energy events: '
Expand Down
2 changes: 1 addition & 1 deletion nemo/nem.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
'demand data must start at midnight'

# Calculate hourly demand, averaging half-hours n and n+1.
hourly_regional_demand = demand.resample('H', closed='right').mean()
hourly_regional_demand = demand.resample('h', closed='right').mean()

# Now put the demand into polygon resolution according to the load
# apportioning figures given in each region's polygons field.
Expand Down
2 changes: 1 addition & 1 deletion nemo/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def run(context, starthour=None, endhour=None):
starthour = context.demand.index.min()
if endhour is None:
endhour = context.demand.index.max()
date_range = pd.date_range(starthour, endhour, freq='H')
date_range = pd.date_range(starthour, endhour, freq='h')

_sim(context, date_range)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_str_with_unserved(self):
# Dummy lambda functions for testing
self.context.surplus_energy = lambda: 300
self.context.unserved_percent = lambda: 0.5
rng = pd.date_range(start='2022-01-01', end='2022-01-02', freq='H')
rng = pd.date_range(start='2022-01-01', end='2022-01-02', freq='h')
self.context.unserved = pd.Series(index=rng, data=range(len(rng)))
output = str(self.context)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TestSim(unittest.TestCase):
def setUp(self):
"""Test harness setup."""
self.context = Context()
self.date_range = pd.date_range('2010-01-01', '2010-01-02', freq='H')
self.date_range = pd.date_range('2010-01-01', '2010-01-02', freq='h')
self.generation = np.zeros((len(self.date_range),
len(self.context.generators)))
self.spill = np.zeros((len(self.date_range),
Expand Down

0 comments on commit 2bde735

Please sign in to comment.