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

Upgrade database_knotinfo to version 2024.2.1 #37014

Merged
merged 9 commits into from
Feb 13, 2024

Conversation

soehms
Copy link
Member

@soehms soehms commented Jan 5, 2024

The upgrade is necessary by two reasons:

  1. Since version 2023.10.1 knots with 13 crossings have been added to the database. The new data could not be used entirely, firstly because of missing adaptions on the Sage side and secondly because the HOMFLY-PT data has been incompatible on the KnotInfo side. The latter has been fixed in version 2024.1.1.
  2. The old table columns khovanov_polynomial and khovanov_polynomial_torsion have been removed from the database for knots. Since these have been kept in Sage 10.1 for optional usage this breaks compatiblity with 2024.1.1 completely.

This PR restores compatibility with the current content of the database in both cases.

Furthermore it adds KnotInfo and KnotInfoSeries to the global namespace, even in the case where only the demo part of the database is present. I made the former restriction because I unnecessarily feared this could affect the startup-time of Sage.

Finally I changed a couple of inline doctest tags # optional database_knotinfo to according block-scoped tags. Note, that this causes 2 doctest-warnings:

**********************************************************************
File "src/sage/knots/link.py", line 4070, in sage.knots.link.Link.get_knotinfo
Warning: Variable 'KnotInfo' referenced here was set only in doctest marked '# optional - database_knotinfo'
    K = KnotInfo.K10_25
**********************************************************************
File "src/sage/knots/link.py", line 4104, in sage.knots.link.Link.get_knotinfo
Warning: Variable 'KnotInfo' referenced here was set only in doctest marked '# optional - database_knotinfo'
    L.get_knotinfo(mirror_version=False) == KnotInfo.K0_1

But I think these warnings are baseless, since KnotInfo is in the global namespace. I guess this is a bug in doctest functionality.

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • 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

@tscrim
Copy link
Collaborator

tscrim commented Jan 5, 2024

I can review this when ready.

@soehms
Copy link
Member Author

soehms commented Jan 5, 2024

I can review this when ready.

Very kind! In the meantime I've made some cross-checks with the new data. HOMFLY, Jones and Conway polynomials match the results calculated by Sage. With respect to Khovanov homology I compared with the computations of Khoca (because of performance reasons) using the PyPI version I created 2021 (note that this is not stable software, see LLewark/khoca#3). This cross-check found four differences for reduced homology in characteristic 2:

sage: cmp_pd_13_poly_char2_red
[<KnotInfo.K13n_3663: '13n_3663'>,
 <KnotInfo.K13n_4587: '13n_4587'>,
 <KnotInfo.K13n_4639: '13n_4639'>,
 <KnotInfo.K13n_5016: '13n_5016'>]

I will report this to Chuck Livingston. But maybe you can check independently that everthing is o.K. on the Sage side.

@soehms soehms added this to the sage-10.3 milestone Jan 5, 2024
@soehms soehms marked this pull request as ready for review January 5, 2024 16:28
@soehms soehms changed the title Upgrade database_knotinfo to version 2024.1.1 Upgrade database_knotinfo to version 2024.2.1 Feb 4, 2024
@soehms
Copy link
Member Author

soehms commented Feb 4, 2024

I pushed the version of database_knotinfo to the current 2024.2.1 and made some further optional doctests in link.py block-scoped.

@soehms soehms requested a review from tscrim February 4, 2024 22:05
Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

I am worried that you are doing something slightly strange with the control logic given the error messages. Empty strings versus something more clear like None for invalid data seems better. If you think empty strings are best, then I think some more documentation is needed.

Also, I think we should deprecate the KhoHo attribute. Although could there be a use for having it to select which database to use?

src/sage/knots/knotinfo.py Outdated Show resolved Hide resolved
src/sage/knots/knotinfo.py Outdated Show resolved Hide resolved
src/sage/knots/knotinfo.py Outdated Show resolved Hide resolved
src/sage/knots/knotinfo.py Outdated Show resolved Hide resolved
@soehms
Copy link
Member Author

soehms commented Feb 5, 2024

I am worried that you are doing something slightly strange with the control logic given the error messages. Empty strings versus something more clear like None for invalid data seems better. If you think empty strings are best, then I think some more documentation is needed.

I'm not sure I understand your concern! The empty strings are used in the database when no value is specified for a knot or link. Such cases have increased in the new data for knots with 13 crossings, as not all properties can be easily calculated (as with the braid_index). Raising a ValueError for these could be confusing for the user of the interface since he didn't pass a value to the method. Or do you want to change empty strings to None already in the Python wrapper for the Excel sheets?

Also, I think we should deprecate the KhoHo attribute. Although could there be a use for having it to select which database to use?

The "KhoHo" attribute results in an IndexError if the database is installed with version "2024.1.1" or newer. I could catch the IndexError, ignore the attribute, and display a deprecation warning indicating a database version downgrade. If a compatible version is installed, I would show a different deprecation warning and continue using the attribute. Are you suggesting that?

Co-authored-by: Travis Scrimshaw <clfrngrown@aol.com>
@tscrim
Copy link
Collaborator

tscrim commented Feb 6, 2024

I am worried that you are doing something slightly strange with the control logic given the error messages. Empty strings versus something more clear like None for invalid data seems better. If you think empty strings are best, then I think some more documentation is needed.

I'm not sure I understand your concern! The empty strings are used in the database when no value is specified for a knot or link. Such cases have increased in the new data for knots with 13 crossings, as not all properties can be easily calculated (as with the braid_index). Raising a ValueError for these could be confusing for the user of the interface since he didn't pass a value to the method. Or do you want to change empty strings to None already in the Python wrapper for the Excel sheets?

Okay, I understand, I didn't realize empty strings were used for unknown values in the database. It's a little strange that this isn't converted to, e.g., a None earlier, but now I understand what your code is checking for. It might be good to put a code comment about this.

Also, I think we should deprecate the KhoHo attribute. Although could there be a use for having it to select which database to use?

The "KhoHo" attribute results in an IndexError if the database is installed with version "2024.1.1" or newer. I could catch the IndexError, ignore the attribute, and display a deprecation warning indicating a database version downgrade. If a compatible version is installed, I would show a different deprecation warning and continue using the attribute. Are you suggesting that?

I would give a deprecation message (and then ignore the parameter) if the user passes it (for example; their code explicitly was passing the argument before the Sage update). That way we break less code and follow standard Sage practices.

I also wasn't sure if the parameter was still useful or not in the upgraded version (as you said, it is not).

@soehms
Copy link
Member Author

soehms commented Feb 6, 2024

.... It might be good to put a code comment about this.
.....
I would give a deprecation message (and then ignore the parameter) if the user passes it (for example; their code explicitly was passing the argument before the Sage update). That way we break less code and follow standard Sage practices.

Both tasks I've done in the current commit.

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Thank you. One last little thing, then you can set a positive review, change the error messages to start with a lowercase letter (as we follow Python's convention).

@soehms
Copy link
Member Author

soehms commented Feb 7, 2024

Thank you. One last little thing, then you can set a positive review, change the error messages to start with a lowercase letter (as we follow Python's convention).

Thanks, as well!

Copy link

github-actions bot commented Feb 7, 2024

Documentation preview for this PR (built with commit a36841b; changes) is ready! 🎉

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 7, 2024
    
<!-- ^^^^^
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 sagemath#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 sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

The upgrade is necessary by two reasons:

1. Since version [2023.10.1](https://github.com/soehms/database_knotinfo
/releases/tag/2023.10.1) knots with 13 crossings have been added to the
database. The new data could not be used entirely, firstly because of
missing adaptions on the Sage side and secondly because the HOMFLY-PT
data has been incompatible on the KnotInfo side. The latter has been
fixed in version 2024.1.1.
2. The old table columns `khovanov_polynomial` and
`khovanov_polynomial_torsion` have been removed from the database for
knots. Since these have been kept in Sage 10.1 for optional usage this
breaks compatiblity with [2024.1.1](https://github.com/soehms/database_k
notinfo/releases/tag/2024.1.1) completely.

This PR restores compatibility with the current content of the database
in both cases.

Furthermore it adds `KnotInfo` and `KnotInfoSeries` to the global
namespace, even in the case where only the demo part of the database is
present. I made the former restriction because I unnecessarily feared
this could affect the startup-time of Sage.

Finally I changed a couple of inline doctest tags `# optional
database_knotinfo` to according block-scoped tags. Note, that this
causes 2 doctest-warnings:


```
**********************************************************************
File "src/sage/knots/link.py", line 4070, in
sage.knots.link.Link.get_knotinfo
Warning: Variable 'KnotInfo' referenced here was set only in doctest
marked '# optional - database_knotinfo'
    K = KnotInfo.K10_25
**********************************************************************
File "src/sage/knots/link.py", line 4104, in
sage.knots.link.Link.get_knotinfo
Warning: Variable 'KnotInfo' referenced here was set only in doctest
marked '# optional - database_knotinfo'
    L.get_knotinfo(mirror_version=False) == KnotInfo.K0_1
```

But I think these warnings are baseless, since `KnotInfo` is in the
global namespace. I guess this is a bug in doctest functionality.


### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.

### ⌛ Dependencies

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

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37014
Reported by: Sebastian Oehms
Reviewer(s): Sebastian Oehms, Travis Scrimshaw
@vbraun vbraun merged commit 96cb484 into sagemath:develop Feb 13, 2024
16 of 43 checks passed
@soehms soehms deleted the upgrade_database_knotinfo_2024.1.1 branch February 14, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants