Skip to content

Preserve custom distribution subclasses in conversion factories - #5357

Draft
FlorianPfaff wants to merge 6 commits into
mainfrom
agent/fix-custom-conversion-subclasses
Draft

Preserve custom distribution subclasses in conversion factories#5357
FlorianPfaff wants to merge 6 commits into
mainfrom
agent/fix-custom-conversion-subclasses

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

Fix five custom-distribution conversion factories so the target-centric convert_distribution(source, TargetSubclass) API returns the requested subclass instead of silently constructing the base representation.

Affected targets:

  • CustomLinearDistribution
  • CustomHypercylindricalDistribution
  • CustomHypersphericalDistribution
  • CustomHyperhemisphericalDistribution
  • CustomHemisphericalDistribution

Root cause

convert_distribution resolves TargetSubclass.from_distribution(...). These inherited factories were staticmethods and explicitly constructed their base class, so subclass-based extensions lost their concrete target type. This is the same factory-contract issue fixed for several Dirac/grid targets in #5347, but the custom-distribution factories were still affected.

Fix

  • convert the five factories to classmethods
  • construct results through cls(...)
  • preserve the existing normalization/scaling branches and all density mathematics
  • add regression coverage through the public convert_distribution gateway for all five target families

Validation

  • branch is based directly on current main at baac3b1736bb8e81eafc1e3f69e10104636103b9
  • final comparison: 6 files changed, 6 commits ahead, 0 behind
  • exact patched production files and the new regression test syntax-compile successfully locally
  • a full local pytest run is unavailable in this execution environment because PyRecEst is not installed and external cloning is unavailable; GitHub Actions is the authoritative repository-wide validation

@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.57s
✅ JSON prettier 7 0 0 0 0.66s
✅ JSON v8r 7 0 0 4.09s
✅ MARKDOWN markdownlint 68 0 0 0 2.64s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.72s
✅ PYTHON black 1989 15 0 0 64.7s
✅ PYTHON isort 1989 27 0 0 2.87s
✅ REPOSITORY betterleaks yes no no 1.71s
✅ REPOSITORY checkov yes no no 33.31s
✅ REPOSITORY git_diff yes no no 0.14s
✅ REPOSITORY secretlint yes no no 104.78s
✅ REPOSITORY syft yes no no 2.7s
✅ REPOSITORY trivy-sbom yes no no 2.5s
✅ YAML prettier 11 0 0 0 0.69s
✅ YAML v8r 11 0 0 17.28s
✅ YAML yamllint 11 0 0 1.0s

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

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