Version Checks (indicate both or one)
Issue Description
I get an AssertionError when passing groupby_time=True to n.statistics.revenue(...). Also tested for e.g. n.statistics.withdrawl(...). Probably all statistics functions are affected.
Full stack trade:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[14], line 1
----> 1 n.statistics.revenue(
2 groupby=["name", "bus", "carrier"], at_port=True, groupby_time=True
3 ).loc["Link", :, "RS00", ["gas-ccgt", "gas-conv", "lignite"]]
File ~/micromamba/envs/easteregg/lib/python3.12/site-packages/pypsa/statistics/expressions.py:249, in StatisticHandler.__call__(self, *args, **kwargs)
248 def __call__(self, *args: Any, **kwargs: Any) -> pd.DataFrame: # noqa: D102
--> 249 return self._bound_method(*args, **kwargs)
File ~/micromamba/envs/easteregg/lib/python3.12/site-packages/pypsa/common.py:529, in deprecated_kwargs.<locals>.deco.<locals>.wrapper(*args, **kwargs)
524 @functools.wraps(f)
525 def wrapper(*args: Any, **kwargs: Any) -> Any:
526 rename_deprecated_kwargs(
527 f.__name__, kwargs, aliases, deprecated_in, removed_in
528 )
--> 529 return f(*args, **kwargs)
File ~/micromamba/envs/easteregg/lib/python3.12/site-packages/pypsa/statistics/expressions.py:2366, in StatisticsAccessor.revenue(self, components, groupby_time, groupby_method, aggregate_across_components, groupby, at_port, carrier, bus_carrier, nice_names, drop_zero, round, direction)
2363 weights = n.snapshot_weightings.objective
2364 return self._aggregate_timeseries(revenue, weights, agg=groupby_time)
-> 2366 df = self._aggregate_components(
2367 func,
2368 components=components,
...
-> 1071 assert callable(self.func)
1073 series_gen = self.series_generator
1074 res_index = self.result_index
AssertionError:
Reproducible Example
# fails
n.statistics.revenue(groupby_time=True)
# works
n.statistics.revenue()
n.statistics.revenue(groupby_time=False)
Expected Behavior
Same as without passing groupby_time, i.e. the default output when calling n.statistics.revenue()
Installed Versions
Details
Replace this line.
Version Checks (indicate both or one)
I have confirmed this bug exists on the lastest release of PyPSA.
I have confirmed this bug exists on the current
masterbranch of PyPSA.Issue Description
I get an
AssertionErrorwhen passinggroupby_time=Trueton.statistics.revenue(...). Also tested for e.g.n.statistics.withdrawl(...). Probably allstatisticsfunctions are affected.Full stack trade:
Reproducible Example
Expected Behavior
Same as without passing
groupby_time, i.e. the default output when callingn.statistics.revenue()Installed Versions
Details
Replace this line.