Skip to content

Commit

Permalink
Merge pull request #85 from boschresearch/deprecation-fixes
Browse files Browse the repository at this point in the history
Deprecation fixes
  • Loading branch information
johannes-mueller authored Jul 2, 2024
2 parents 3ac6cd4 + 8605896 commit 828e6ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/pylife/strength/failure_probability.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,8 @@ def pf_arbitrary_load(self, load_values, load_pdf):

strength_cdf = norm.cdf(load_values, loc=self.s_50, scale=self.s_std)

return np.trapz(load_pdf * strength_cdf, x = load_values)

# TODO: remove this once we drop python 3.8 support
trapezoid = np.trapezoid if hasattr(np, 'trapezoid') else np.trapz

return trapezoid(load_pdf * strength_cdf, x = load_values)
16 changes: 12 additions & 4 deletions src/pylife/strength/meanstress.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,18 @@ def _check_if_R_index(self, check_func):
if isinstance(self._obj.index, pd.IntervalIndex):
return check_func(self._obj.index)

all_but_R = filter(lambda n: n != 'R', map(lambda n: n or 0, self._obj.index.names))
return (self._obj.index.to_frame(index=False).groupby(list(all_but_R))
.apply(lambda g: check_func(g.set_index('R').index))
.any())
all_but_R = [n or 0 for n in self._obj.index.names if n != 'R']

# TODO: remove once we drop python 3.8 support
include_groups = {} if pd.__version__ < "2.2" else {'include_groups': False}

return (
self
._obj.index.to_frame(index=False)
.groupby(all_but_R)
.apply(lambda g: check_func(g.set_index('R').index), **include_groups)
.any()
)


class _SegmentTransformer:
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_combine_test_big_bin():
hist1 = pd.Series([1, 2], index=pd.IntervalIndex.from_tuples([(0.0, 0.5), (0.5, 1.0)]))
hist2 = pd.Series([4], index=pd.IntervalIndex.from_tuples([(0.0, 1.0)]))

result = hi.combine_histogram([hist1, hist2], method=sum)
result = hi.combine_histogram([hist1, hist2], method="sum")

expected = pd.Series(
[1, 4, 2],
Expand Down

0 comments on commit 828e6ec

Please sign in to comment.