Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sagelib work with singular>=4.3.2.p15 (future 4.4) #37492

Merged
merged 8 commits into from
May 2, 2024

Conversation

antonio-rojas
Copy link
Contributor

Two major breaking changes:

  • The rp ordering is renamed to ip
  • hilb now returns a bigintvec object (which isn't even exposed in the C++ API, seems to be an instance of bigintmat)

This branch builds and works fine with 4.3.2.p15, but I have no idea how to make it work with both old and new singular, suggestions welcome.

@antonio-rojas
Copy link
Contributor Author

cc @tornaria @kiwifb

@tornaria
Copy link
Contributor

This is working fine for me and I'm releasing sagemath 10.3 on void linux with this patch and singular 4.3.2.p16 (with flint 3.1.2)

@mkoeppe
Copy link
Member

mkoeppe commented Mar 21, 2024

best to remove "WIP:" from the title if it's ready

@antonio-rojas
Copy link
Contributor Author

best to remove "WIP:" from the title if it's ready

I don't think this is ready unless we want to break support for older singular.

@mkoeppe
Copy link
Member

mkoeppe commented Mar 21, 2024

Then probably "positive review" should be replaced by "needs work"

src/sage/libs/singular/singular.pyx Outdated Show resolved Hide resolved
src/sage/libs/singular/singular.pxd Outdated Show resolved Hide resolved
@antonio-rojas antonio-rojas changed the title WIP: make sagelib work with singular>=4.3.2.p15 (future 4.4) make sagelib work with singular>=4.3.2.p15 (future 4.4) Mar 31, 2024
@antonio-rojas
Copy link
Contributor Author

First attempt at making this work with older singular

polynomial ring, over a field, global ordering
// coefficients: ZZ/127
// number of vars : 3
// block 1 : ordering rp
// block 1 : ordering ip

This comment was marked as outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered this, but do we really want to skip testing that the correct ordering is used here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need a mechanism to support backward compatibility. Sprinkling examples with regular expressions to fix stuff like this is quite ugly in terms of documentation.

Similar problems we have right now with gap 4.13 (#37616, see also #37590 (comment)) and all over the place with results that have to be sorted to compare, etc.

For numerical noise there's the # tol tag which affects how the output of a doctest is compared. For order, I think a tag # random_order may be preferable to having to sort in the example. What could we do for this case?

An alternative is to add code in SingularElement._repr_() so the output of old singular is changed into the output of new singular (i.e. replace ordering rp with ordering ip). But this seems a bit hacky...

@@ -244,6 +244,7 @@ cdef extern from "singular/Singular/libsingular.h":
ringorder_lp
ringorder_dp
ringorder_rp
ringorder_ip

This comment was marked as resolved.

singular_name_mapping = {
'lex' : 'lp',
'invlex' : 'rp',
'invlex' : invlex_singular_name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be the only place we need a different code for different versions of singular.

polynomial ring, over a field, global ordering
// coefficients: ZZ/2[a]/(a^8+a^4+a^3+a^2+1)
// number of vars : 10
// block 1 : ordering rp
// block 1 : ordering ip

This comment was marked as outdated.

Comment on lines 69 to 73
from sage.interfaces.singular import singular_version_number
if int(singular_version_number()[0:3]) < 432 or (int(singular_version_number()[0:3]) == 432 and int(singular_version_number()[3:]) < 15):
order_dict["rp"] = ringorder_rp
else:
order_dict["ip"] = ringorder_ip
Copy link
Contributor

@tornaria tornaria Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unnecessary if we keep using ringorder_rp for the time being.

EDIT: wrong.. still need "rp" or "ip" 🤔

EDIT 2: Could just add both as in

"rp" : ringorder_rp,  # this is deprecated
"ip" : ringorder_ip,

As a matter of fact, ringorder_rp is an alias for ringorder_ip in old and in new singular. The only thing changed now is the name "rp" was changed to "ip".

@tornaria
Copy link
Contributor

tornaria commented Apr 6, 2024

@antonio-rojas

antonio-rojas/sage@singular-4.4...tornaria:sage:singular

This is my attempt to support singular 4.3.2p10 and before. This is built on top of your first commit here, but I dropped the others.

  1. add a doctest for bigintvec coercion (you implemented this but there's no test that will use this code)
  2. fix the "arity" renumbering by printing the symbol instead of a number (seems nicer)
  3. fix the compatibility for 4.3.2p10 by adding some #define and (only for "old" singular) patching the mapping tables so we use rp on singular side and patch output so it prints ordering ip even when using old singular (this solves your concern about testing the ordering).

I've tested with 4.3.2p10 (old) and 4.3.2p16 (new).

If you like the approach, feel free to take my commits into your PR, rebase at will. I don't make a PR to your PR since I am dropping some of your commits.

Note that I left out the stuff about noexcept; since #37667 will be merged in beta2, it seems easier to wait and fix it when rebasing on top of beta2.

@tornaria
Copy link
Contributor

tornaria commented Apr 8, 2024

@antonio-rojas I've rebased my branch develop...tornaria:sage:singular on top of 10.4.beta2.

I adjusted the noexcept conflict in your commit, and my commits rebase cleanly.

Copy link

github-actions bot commented Apr 9, 2024

Documentation preview for this PR (built with commit d999b20; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@mkoeppe
Copy link
Member

mkoeppe commented Apr 11, 2024

I've tested this with:

The tests include a mixture of platforms where Singular is built from the SPKG or taken from the system.
All works well.
Thanks for preparing this!

@antonio-rojas
Copy link
Contributor Author

I modified the ordering string replacement to happen only in doctests. Otherwis it can be confusing to get a different output for Singular code when run from inside Sage.

@mkoeppe
Copy link
Member

mkoeppe commented Apr 24, 2024

Tested again with #37570 (and some other upgrades) with the full CI Linux in https://github.com/mkoeppe/sage/actions/runs/8761823524, looking good.

@mkoeppe
Copy link
Member

mkoeppe commented Apr 24, 2024

Is there anything else to do here? From my side, this would be a positive review.

@antonio-rojas
Copy link
Contributor Author

Is there anything else to do here? From my side, this would be a positive review.

Not that I'm aware of

@kiwifb
Copy link
Member

kiwifb commented Apr 24, 2024

I have been including it in the latest beta release for sage-on-gentoo and everything looks fine.

@vbraun
Copy link
Member

vbraun commented Apr 24, 2024

merge conflict

antonio-rojas and others added 8 commits April 27, 2024 18:17
Co-authored-by: Gonzalo Tornaría <tornaria@cmat.edu.uy>
Function `hilb` now returns a `bigintvec` object and the coercion to a
sage vector was implemented in the previous commit.

Here we add a doctest for this coercion.
This makes the output independent of changes in the version of singular
Add two fallback compatibility `#define`s:
 - `ringorder_ip`
 - `BIGINTVEC_CMD`

Also for old singular:
 - patch the term_order mappings to send `rp` to singular instead of `ip`
 - patch the display of a ring so it prints `ip` instead of `rp`
@antonio-rojas
Copy link
Contributor Author

Rebased over beta 4

vbraun pushed a commit to vbraun/sage that referenced this pull request Apr 28, 2024
…4.4)

    
Two major breaking changes:

- The `rp` ordering is renamed to `ip`
- `hilb` now returns a `bigintvec` object (which isn't even exposed in
the C++ API, seems to be an instance of `bigintmat`)

This branch builds and works fine with 4.3.2.p15, but I have no idea how
to make it work with both old and new singular, suggestions welcome.
    
URL: sagemath#37492
Reported by: Antonio Rojas
Reviewer(s): Antonio Rojas, Gonzalo Tornaría, Matthias Köppe
@vbraun vbraun merged commit 721fc79 into sagemath:develop May 2, 2024
11 of 13 checks passed
@mkoeppe mkoeppe added this to the sage-10.4 milestone May 2, 2024
vbraun pushed a commit to vbraun/sage that referenced this pull request May 4, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Includes
- [x] Singular/Singular#1205

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

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

### ⌛ Dependencies

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

- Depends on sagemath#37492
    
URL: sagemath#37570
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request May 9, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Includes
- [x] Singular/Singular#1205

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

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

### ⌛ Dependencies

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

- Depends on sagemath#37492
    
URL: sagemath#37570
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request May 11, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Includes
- [x] Singular/Singular#1205

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

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

### ⌛ Dependencies

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

- Depends on sagemath#37492
    
URL: sagemath#37570
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request May 12, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Includes
- [x] Singular/Singular#1205

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

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

### ⌛ Dependencies

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

- Depends on sagemath#37492
    
URL: sagemath#37570
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request May 12, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Includes
- [x] Singular/Singular#1205

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

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

### ⌛ Dependencies

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

- Depends on sagemath#37492
    
URL: sagemath#37570
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
@antonio-rojas antonio-rojas deleted the singular-4.4 branch May 25, 2024 18:49
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.

None yet

5 participants