repo stringclasses 1 value | instance_id stringclasses 1 value | base_commit stringclasses 1 value | patch stringclasses 1 value | test_patch stringclasses 1 value | problem_statement stringclasses 1 value | hints_text stringclasses 1 value | created_at stringclasses 1 value | version stringclasses 1 value | FAIL_TO_PASS stringclasses 1 value | PASS_TO_PASS stringclasses 1 value | environment_setup_commit stringclasses 1 value | difficulty stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
astropy/astropy | astropy__astropy-12907 | d16bfe05a744909de4b27f5875fe0d4ed41ce607 | diff --git a/astropy/modeling/separable.py b/astropy/modeling/separable.py
--- a/astropy/modeling/separable.py
+++ b/astropy/modeling/separable.py
@@ -242,7 +242,7 @@ def _cstack(left, right):
cright = _coord_matrix(right, 'right', noutp)
else:
cright = np.zeros((noutp, right.shape[1]))
- cright[-right.shape[0]:, -right.shape[1]:] = 1
+ cright[-right.shape[0]:, -right.shape[1]:] = right
return np.hstack([cleft, cright])
| diff --git a/astropy/modeling/tests/test_separable.py b/astropy/modeling/tests/test_separable.py
--- a/astropy/modeling/tests/test_separable.py
+++ b/astropy/modeling/tests/test_separable.py
@@ -28,6 +28,13 @@
p1 = models.Polynomial1D(1, name='p1')
+cm_4d_expected = (np.array([False, False, True, True]),
+ np.array([[True, True, False, False],
+ [True, True, False, False],
+ [False, False, True, False],
+ [False, False, False, True]]))
+
+
compound_models = {
'cm1': (map3 & sh1 | rot & sh1 | sh1 & sh2 & sh1,
(np.array([False, False, True]),
@@ -52,7 +59,17 @@
'cm7': (map2 | p2 & sh1,
(np.array([False, True]),
np.array([[True, False], [False, True]]))
- )
+ ),
+ 'cm8': (rot & (sh1 & sh2), cm_4d_expected),
+ 'cm9': (rot & sh1 & sh2, cm_4d_expected),
+ 'cm10': ((rot & sh1) & sh2, cm_4d_expected),
+ 'cm11': (rot & sh1 & (scl1 & scl2),
+ (np.array([False, False, True, True, True]),
+ np.array([[True, True, False, False, False],
+ [True, True, False, False, False],
+ [False, False, True, False, False],
+ [False, False, False, True, False],
+ [False, False, False, False, True]]))),
}
| Modeling's `separability_matrix` does not compute separability correctly for nested CompoundModels
Consider the following model:
```python
from astropy.modeling import models as m
from astropy.modeling.separable import separability_matrix
cm = m.Linear1D(10) & m.Linear1D(5)
```
It's separability matrix as you might expect is a diagonal:
```python
>>> separability_matrix(cm)
array([[ True, False],
[False, True]])
```
If I make the model more complex:
```python
>>> separability_matrix(m.Pix2Sky_TAN() & m.Linear1D(10) & m.Linear1D(5))
array([[ True, True, False, False],
[ True, True, False, False],
[False, False, True, False],
[False, False, False, True]])
```
The output matrix is again, as expected, the outputs and inputs to the linear models are separable and independent of each other.
If however, I nest these compound models:
```python
>>> separability_matrix(m.Pix2Sky_TAN() & cm)
array([[ True, True, False, False],
[ True, True, False, False],
[False, False, True, True],
[False, False, True, True]])
```
Suddenly the inputs and outputs are no longer separable?
This feels like a bug to me, but I might be missing something?
| 2022-03-03T15:14:54Z | 4.3 | ["astropy/modeling/tests/test_separable.py::test_separable[compound_model6-result6]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model9-result9]"] | ["astropy/modeling/tests/test_separable.py::test_coord_matrix", "astropy/modeling/tests/test_separable.py::test_cdot", "astropy/modeling/tests/test_separable.py::test_cstack", "astropy/modeling/tests/test_separable.py::test_arith_oper", "astropy/modeling/tests/test_separable.py::test_separable[compound_model0-result0]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model1-result1]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model2-result2]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model3-result3]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model4-result4]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model5-result5]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model7-result7]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model8-result8]", "astropy/modeling/tests/test_separable.py::test_custom_model_separable"] | 298ccb478e6bf092953bca67a3d29dc6c35f6752 | 15 min - 1 hour |
README.md exists but content is empty.
- Downloads last month
- 12