Skip to content

Preserve von Mises subclasses in factories and operations - #5397

Merged
FlorianPfaff merged 2 commits into
mainfrom
chatgpt/fix-von-mises-subclass-preservation
Aug 23, 2026
Merged

Preserve von Mises subclasses in factories and operations#5397
FlorianPfaff merged 2 commits into
mainfrom
chatgpt/fix-von-mises-subclass-preservation

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

Fix a subclass-erasure bug in VonMisesDistribution analogous to the recently fixed vMF/Gaussian cases.

from_moment, multiply, and convolve constructed VonMisesDistribution directly, so calling these APIs through a subclass silently returned the base class and discarded subclass behavior/state.

Changes

  • make from_moment a classmethod and construct via cls
  • make multiply preserve the left-hand runtime type
  • make convolve preserve the left-hand runtime type
  • add focused regressions for regular and uniform moment/convolution results

Regression covered

Before this patch:

class MyVonMises(VonMisesDistribution):
    pass

x = MyVonMises(0.2, 1.5)
assert isinstance(x.multiply(VonMisesDistribution(1.1, 0.7)), MyVonMises)  # failed
assert isinstance(x.convolve(VonMisesDistribution(1.1, 0.7)), MyVonMises)  # failed
assert isinstance(MyVonMises.from_moment(x.trigonometric_moment(1)), MyVonMises)  # failed

The patch makes these operations consistent with the repository's subclass-preserving distribution APIs.

@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 22, 2026 20:42
@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 7.89s
✅ JSON prettier 7 0 0 0 0.84s
✅ JSON v8r 7 0 0 5.7s
✅ MARKDOWN markdownlint 68 0 0 0 2.22s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.45s
✅ PYTHON black 2010 23 0 0 70.45s
✅ PYTHON isort 2010 39 0 0 3.05s
✅ REPOSITORY betterleaks yes no no 1.27s
✅ REPOSITORY checkov yes no no 38.98s
✅ REPOSITORY git_diff yes no no 0.2s
✅ REPOSITORY secretlint yes no no 121.17s
✅ REPOSITORY syft yes no no 3.85s
✅ REPOSITORY trivy-sbom yes no no 3.19s
✅ YAML prettier 11 0 0 0 0.7s
✅ YAML v8r 11 0 0 18.8s
✅ YAML yamllint 11 0 0 1.13s

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: MAKEFILE_CHECKMAKE. See Removed linters to find their replacements.

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.0.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff
FlorianPfaff merged commit 7326018 into main Aug 23, 2026
15 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant