Skip to content

Fix subclass-preserving distribution conversion factories - #5347

Merged
FlorianPfaff merged 3 commits into
mainfrom
agent/fix-dirac-factory-subclasses
Aug 18, 2026
Merged

Fix subclass-preserving distribution conversion factories#5347
FlorianPfaff merged 3 commits into
mainfrom
agent/fix-dirac-factory-subclasses

Conversation

@FlorianPfaff

@FlorianPfaff FlorianPfaff commented Aug 18, 2026

Copy link
Copy Markdown
Owner

What changed

  • Convert LinearDiracDistribution.from_distribution, CircularDiracDistribution.from_distribution, SE2DiracDistribution.from_distribution, and SE3DiracDistribution.from_distribution from static factories to class factories.
  • Convert CircularGridDistribution.from_distribution and CircularGridDistribution.from_function to class factories as well.
  • Construct cls(...) instead of hard-coding the base distribution type.
  • Route particle-count validation through cls for the Euclidean/SE factories.
  • Add regression coverage through the public convert_distribution gateway for subclasses of all five affected target families.

Root cause

convert_distribution(source, TargetSubclass, ...) resolves TargetSubclass.from_distribution. Several inherited factories were static methods that explicitly constructed the base class, so the conversion silently returned the wrong concrete type even though the requested target was the subclass. CircularGridDistribution.from_distribution also delegated to a static from_function that hard-coded CircularGridDistribution, so simply inheriting the factory could not preserve an extension class.

Impact

Subclass-based extensions of these core Dirac and circular-grid representations now retain their requested concrete type during representation conversion. Ordinary base-class conversions keep the same behavior and signatures.

Validation

  • tests/distributions/test_dirac_factory_subclass_preservation.py now contains five gateway regressions, including circular-grid conversion from a von Mises source.
  • The branch is based on current main (fc15bed910b324cd0619a2f2b71abc887bc09747).
  • Full backend/test-matrix validation is delegated to GitHub Actions because the current execution environment cannot clone GitHub dependencies locally.

@FlorianPfaff
FlorianPfaff force-pushed the agent/fix-dirac-factory-subclasses branch from 3f1c3b5 to 2da1983 Compare August 18, 2026 17:34
@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 8.2s
✅ JSON prettier 7 0 0 0 0.8s
✅ JSON v8r 7 0 0 3.97s
✅ MARKDOWN markdownlint 68 0 0 0 1.9s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.45s
✅ PYTHON black 1984 12 0 0 58.06s
✅ PYTHON isort 1984 22 0 0 2.84s
✅ REPOSITORY betterleaks yes no no 1.06s
✅ REPOSITORY checkov yes no no 35.82s
✅ REPOSITORY git_diff yes no no 0.13s
✅ REPOSITORY secretlint yes no no 99.54s
✅ REPOSITORY syft yes no no 2.96s
✅ REPOSITORY trivy-sbom yes no no 2.07s
✅ YAML prettier 11 0 0 0 0.78s
✅ YAML v8r 11 0 0 14.21s
✅ YAML yamllint 11 0 0 0.94s

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 changed the title Fix subclass-preserving Dirac conversion factories Fix subclass-preserving distribution conversion factories Aug 18, 2026
@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 18, 2026 19:17
@FlorianPfaff
FlorianPfaff merged commit 5739dc0 into main Aug 18, 2026
14 of 24 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