Skip to content

Preserve wrapped-normal subclasses in operations - #5403

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

Preserve wrapped-normal subclasses in operations#5403
FlorianPfaff merged 2 commits into
mainfrom
chatgpt/fix-wrapped-normal-subclass-preservation

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

Fix a subclass-erasure bug in WrappedNormalDistribution analogous to the subclass-preservation regressions already fixed for von Mises, vMF, Gaussian, SO(3), and grid distributions.

from_moment, shift, convolve, and the VM-based multiplication path constructed WrappedNormalDistribution directly (or converted back through the base class), 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 shift preserve the runtime type
  • make convolve preserve the left-hand runtime type
  • make multiply, multiply_vm_approximation, and multiply_vm preserve the left-hand runtime type
  • add focused subclass-preservation regressions

Regression covered

Before this patch, each of the following returned WrappedNormalDistribution instead of MyWrappedNormal:

class MyWrappedNormal(WrappedNormalDistribution):
    pass

left = MyWrappedNormal(0.3, 0.8)
right = WrappedNormalDistribution(0.4, 0.6)

left.shift(0.2)
left.convolve(right)
left.multiply(right)
MyWrappedNormal.from_moment(left.trigonometric_moment(1))

The numerical algorithms are unchanged; only result construction now preserves the requested/runtime subclass.

@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 23, 2026 07:31
@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 6.94s
✅ JSON prettier 7 0 0 0 0.76s
✅ JSON v8r 7 0 0 5.47s
✅ MARKDOWN markdownlint 68 0 0 0 2.14s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.41s
✅ PYTHON black 2013 27 0 0 67.25s
✅ PYTHON isort 2013 43 0 0 2.92s
✅ REPOSITORY betterleaks yes no no 1.31s
✅ REPOSITORY checkov yes no no 36.04s
✅ REPOSITORY git_diff yes no no 0.14s
✅ REPOSITORY secretlint yes no no 106.42s
✅ REPOSITORY syft yes no no 2.54s
✅ REPOSITORY trivy-sbom yes no no 2.97s
✅ YAML prettier 11 0 0 0 0.69s
✅ YAML v8r 11 0 0 17.54s
✅ YAML yamllint 11 0 0 1.02s

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 e3a4fc8 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