Implement SdCondSdGridDistribution for PyRecEst#1575
Merged
FlorianPfaff merged 2 commits intomainfrom Mar 31, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/1c6bef08-40d1-4a9d-9810-72aeaceca573 Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
FlorianPfaff
March 31, 2026 12:42
View session
Contributor
✅MegaLinter analysis: Success
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
|
Owner
|
@copilot Can you fix the linter errors by megalinter? |
…nts, add __all__ Agent-Logs-Url: https://github.com/FlorianPfaff/PyRecEst/sessions/d724643e-1252-4c50-b114-57aac876ac0f Co-authored-by: FlorianPfaff <6773539+FlorianPfaff@users.noreply.github.com>
auto-merge was automatically disabled
March 31, 2026 12:59
Head branch was pushed to by a user without write access
Contributor
Author
Fixed in 2efa63c. The MegaLinter failures were:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Ports the MATLAB
SdCondSdGridDistributionclass from libDirectional to Python. Represents a conditional distribution f(a|b) on Sd × Sd as a grid of values, wheregrid_values[i, j] = f(grid[i] | grid[j]).Conventions
grid:(n_points, d)— embedding-dimension coordinates (d=3 for S²)grid_values:(n_points, n_points)— conditional pdf valuesdim = 2 * d— Cartesian-product embedding dimension (libDirectional convention)New class:
SdCondSdGridDistribution__init__— validates inputs; warns/raises if column-wise normalization check fails. Fixes a latent bug in the MATLAB original where the "maybe wrong order" branch could never trigger.normalize()— no-op returningself(matches MATLAB behavior).multiply(other)— element-wise grid multiplication with grid-compatibility guard.marginalize_out(1|2)— sums over rows or columns, returns aHypersphericalGridDistribution.fix_dim(1|2, point)— conditions on an existing grid point, returns aHypersphericalGridDistribution.from_function(fun, n, ...)— static factory supporting both a flat paired-call convention and a caller-side Cartesian-product convention.Notes
get_grid_hypersphereimport is deferred insidefrom_functionto avoid a circular-import path throughpyrecest.sampling.dimargument tofrom_functionfollows the Cartesian-product embedding convention (6for S²×S²); internally converted to manifold dim viadim // 2 - 1.