Skip to content

Commit

Permalink
Filter FutureWarning to accommodate python-3.8
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Mueller <[email protected]>
  • Loading branch information
johannes-mueller committed Oct 10, 2024
1 parent 50db0fc commit de1d2ee
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/pylife/stress/collective/load_collective.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
__author__ = "Johannes Mueller"
__maintainer__ = __author__

from .abstract_load_collective import AbstractLoadCollective
from .load_histogram import LoadHistogram
import warnings

import pandas as pd
import numpy as np

from pylife import PylifeSignal

from .abstract_load_collective import AbstractLoadCollective
from .load_histogram import LoadHistogram


@pd.api.extensions.register_dataframe_accessor('load_collective')
class LoadCollective(PylifeSignal, AbstractLoadCollective):
"""A Load collective.
Expand Down Expand Up @@ -364,12 +367,15 @@ def make_histogram(group):
if axis is None:
return LoadHistogram(make_histogram(range_mean))

result = pd.Series(
range_mean.groupby(self._levels_from_axis(axis))
.apply(make_histogram)
.stack(['range', 'mean'], future_stack=True),
name="cycles",
)
# TODO: Warning filter can be dropped as soon as python-3.8 support is dropped
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
result = pd.Series(
range_mean.groupby(self._levels_from_axis(axis))
.apply(make_histogram)
.stack(['range', 'mean']),
name="cycles",
)

return LoadHistogram(result)

Expand Down

0 comments on commit de1d2ee

Please sign in to comment.