Skip to content

Commit

Permalink
gh-37354: Allow submodule construction of a free module over a ring
Browse files Browse the repository at this point in the history
    
This fails
```sage
sage: R.<x,y> = QQ[]
sage: S = R.quotient([x*y])
sage: M = FreeModule(S, 2)
sage: M.zero_submodule()
...
TypeError: ambient (=Ambient free module of rank 2 over Quotient of
Multivariate Polynomial Ring in x, y over Rational Field by the ideal
(x*y)) must be ambient or a quotient
```

We fix this by removing unnecessary restriction on modules over rings.

<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #37354
Reported by: Kwankyu Lee
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Feb 21, 2024
2 parents 686f7e9 + 300c3a3 commit 2180122
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/sage/modules/submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# ****************************************************************************

from sage.modules.free_module import (
FreeModule_ambient_domain,
FreeModule_ambient,
Module_free_ambient,
basis_seq,
)
Expand Down Expand Up @@ -98,8 +98,19 @@ def __init__(self, ambient, gens, check=True, already_echelonized=False):
sage: N = M.submodule([vector([x - y, z]), vector([y * z, x * z])])
sage: N.is_submodule(M)
True
::
sage: R.<x,y> = QQ[]
sage: S = R.quotient([x*y])
sage: M = FreeModule(S, 2)
sage: M.zero_submodule()
Submodule of Ambient free module of rank 2 over Quotient of Multivariate Polynomial Ring in x, y
over Rational Field by the ideal (x*y)
Generated by the rows of the matrix:
[]
"""
if not isinstance(ambient, (FreeModule_ambient_domain, QuotientModule_free_ambient)):
if not isinstance(ambient, (FreeModule_ambient, QuotientModule_free_ambient)):
raise TypeError("ambient (=%s) must be ambient or a quotient" % ambient)
R = ambient.base_ring()
degree = ambient.degree()
Expand Down

0 comments on commit 2180122

Please sign in to comment.