Skip to content

Commit

Permalink
[ENH] simplify coercion in BaseDistribution._log_pdf and _pdf def…
Browse files Browse the repository at this point in the history
…ault (#293)

Minor change that simplifies coercion in `BaseDistribution._log_pdf` and
`_pdf` default.
  • Loading branch information
fkiraly authored May 4, 2024
1 parent b7ae747 commit a12fa35
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions skpro/distributions/base/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ def _pdf(self, x):
)
warn(self._method_error_msg("pdf", fill_in=approx_method))

if self.ndim > 0 and not isinstance(x, pd.DataFrame):
x = pd.DataFrame(x, index=self.index, columns=self.columns)
x = self._coerce_to_self_index_df(x, flatten=False)
res = self.log_pdf(x=x)
if isinstance(res, pd.DataFrame):
res = res.values
Expand Down Expand Up @@ -597,8 +596,7 @@ def _log_pdf(self, x):
)
warn(self._method_error_msg("log_pdf", fill_in=approx_method))

if self.ndim > 0 and not isinstance(x, pd.DataFrame):
x = pd.DataFrame(x, index=self.index, columns=self.columns)
x = self._coerce_to_self_index_df(x, flatten=False)
res = self.pdf(x=x)
if isinstance(res, pd.DataFrame):
res = res.values
Expand Down

0 comments on commit a12fa35

Please sign in to comment.