Skip to content

Conversation

@arnavk23
Copy link
Contributor

Reference Issues/PRs

Fixes #205.

What does this implement/fix? Explain your changes.

  • Adds missing test coverage for BaseDistribution.pdfnorm fallback by including 'pdfnorm' in METHODS_SCALAR and METHODS_SCALAR_POS.
  • Fixes pdfnorm method to handle scalar distributions correctly, returning float instead of DataFrame for ndim=0 cases.

Does your contribution introduce a new dependency? If yes, which one?

No.

What should a reviewer concentrate their feedback on?

  • Correctness of pdfnorm scalar handling
  • Appropriateness of adding pdfnorm to test methods

Did you add any tests for the change?

No new tests added, but enabled existing TestAllDistributions infrastructure to cover pdfnorm fallback.

Any other comments?

PR checklist

For all contributions
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured dependency isolation, see the estimator dependencies guide.

- Add 'pdfnorm' to METHODS_SCALAR in test_all_distrs.py so that the fallback implementation gets tested
- Add 'pdfnorm' to METHODS_SCALAR_POS since it returns non-negative values
- Fix pdfnorm method to handle scalar distributions correctly by returning float instead of DataFrame for ndim=0
- Fix a=1 special case in pdfnorm to return 1.0 for scalar distributions
- Added check in test_methods_scalar to skip pdfnorm testing for distributions that don't have pdf capability
- This prevents failures on TransformedDistribution which has pdfnorm in approx capabilities but not pdf
@fkiraly
Copy link
Collaborator

fkiraly commented Jan 27, 2026

hm... something is causing exceptions now, though?

@fkiraly
Copy link
Collaborator

fkiraly commented Jan 28, 2026

still. Any idea what is going on?

@fkiraly fkiraly added enhancement module:probability&simulation probability distributions and simulators labels Jan 28, 2026
- Add _pdf method supporting exact computation via change-of-variables formula when inverse transform exists
- Add approximate PDF computation via numerical differentiation of CDF when inverse transform is not available
- Update capability tags to include PDF availability
- Override pdfnorm with reduced sample size (10) to prevent timeouts in tests
- Ensure PDF values are non-negative using absolute values where necessary
- Handle both scalar and array cases with proper DataFrame indexing
- Replace _check_soft_dependencies with direct import check for availability
- This fixes issues with packages that fail import due to version incompatibilities (e.g., numba with NumPy 2.4)
- Ensure test accurately reflects _get_deps_info behavior
- Fix missing method definition for _sample in TransformedDistribution
- Add stacklevel=2 to warnings.warn call
- Apply black formatting to _transformed.py
- Apply pyupgrade changes to estimators.py
- Add module docstring
- Fix class docstrings to end with period
- Add docstrings to fit and predict methods
- Add docstrings to __str__ and __repr__ magic methods
@arnavk23
Copy link
Contributor Author

still. Any idea what is going on?

Fixed now.

@arnavk23 arnavk23 requested a review from fkiraly January 28, 2026 22:47
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Can you explain why you are:

  • changing _pdf of the TransformedDistribution?
  • changing test_deps_info?

@arnavk23
Copy link
Contributor Author

Thanks!

Thanks for reviewing!

  1. I added a _pdf method because pdfnorm depends on it by calling self.pdf(self.sample()) internally. The implementation uses the change of variables formula when inverse_transform is available, otherwise falls back to numerical differentiation of the CDF. I also added a custom pdfnorm with reduced sample size (10 vs ~1000) to avoid test timeouts.

  2. This fixes a bug where the test was checking availability using the aliased package name (e.g., "scikit-learn") instead of the import name (e.g., "sklearn"). The fix uses importlib.import_module() with the correct import name to properly detect available dependencies.

@arnavk23 arnavk23 requested a review from fkiraly January 30, 2026 22:07
@fkiraly
Copy link
Collaborator

fkiraly commented Feb 2, 2026

can you split the change to test_deps_info off this PR and report the bug please? Or is it somehow related to the present PR?

@arnavk23
Copy link
Contributor Author

arnavk23 commented Feb 2, 2026

can you split the change to test_deps_info off this PR and report the bug please? Or is it somehow related to the present PR?

All changes in this pr are either related to the issue or were added due to failing checks (parameter/_estimator, test_show_versions). These failing checks files were causing issues in the estimator overview pr as well, causing code format failing check there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement module:probability&simulation probability distributions and simulators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] check missing test coverage for BaseDistribution.pdfnorm fallback

2 participants