mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
34 lines
1.6 KiB
Diff
34 lines
1.6 KiB
Diff
From: Assistant <assistant@anthropic.com>
|
|
Date: Thu, 7 Jan 2025 14:35:00 +0000
|
|
Subject: [PATCH] Fix separability_matrix for nested CompoundModels
|
|
|
|
This patch fixes issue #12907 where separability_matrix does not compute
|
|
separability correctly for nested CompoundModels.
|
|
|
|
The bug was in the _cdot function in astropy/modeling/separable.py.
|
|
When processing nested CompoundModels, _cdot would receive a CompoundModel
|
|
as input but tried to call _coord_matrix on it, which expects simple Models
|
|
and accesses the .separable property that doesn't exist for CompoundModels.
|
|
|
|
The fix checks if the input is a CompoundModel and calls _separable on it
|
|
to get its separability matrix, rather than trying to use _coord_matrix.
|
|
|
|
diff --git a/astropy/modeling/separable.py b/astropy/modeling/separable.py
|
|
index e180603eac..b871ff6623 100644
|
|
--- a/astropy/modeling/separable.py
|
|
+++ b/astropy/modeling/separable.py
|
|
@@ -266,7 +266,13 @@ def _cdot(left, right):
|
|
Return ``n_inputs``, ``n_outputs`` for a model or coord_matrix.
|
|
"""
|
|
if isinstance(input, Model):
|
|
- coords = _coord_matrix(input, position, input.n_outputs)
|
|
+ # Check if it's a CompoundModel and handle it differently
|
|
+ if isinstance(input, CompoundModel):
|
|
+ # For CompoundModels, use _separable to get the separability matrix
|
|
+ coords = _separable(input)
|
|
+ else:
|
|
+ # For simple Models, use _coord_matrix as before
|
|
+ coords = _coord_matrix(input, position, input.n_outputs)
|
|
else:
|
|
coords = input
|
|
return coords
|