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

Update to new conway-polynomials python package #36765

Merged
merged 13 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions build/pkgs/conway_polynomials/SPKG.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
conway_polynomials: Tables of Conway polynomials over finite fields
===================================================================
conway_polynomials: Python interface to Frank Lübeck's Conway polynomial database
=================================================================================

Description
-----------

Frank Lübeck's tables of Conway polynomials over finite fields.
This python module evolved from the old SageMath *conway_polynomials*
package once hosted at,

Upstream contact
http://files.sagemath.org/spkg/upstream/conway_polynomials/

It's still maintained by Sage developers, but having a pip-installable
interface to the data will make it easier to install SageMath via pip
or another package manager.


License
-------

GPL version 3 or later


Upstream Contact
----------------

http://www.math.rwth-aachen.de/~Frank.Luebeck/data/ConwayPol/
https://github.com/sagemath/conway-polynomials
9 changes: 5 additions & 4 deletions build/pkgs/conway_polynomials/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tarball=conway_polynomials-VERSION.tar.bz2
sha1=d4d89bda60ac54e73121f84635e774766e19a8b6
md5=a2725ba21f44554196781424d957f68a
cksum=1387933493
tarball=conway-polynomials-VERSION.tar.gz
sha1=a822baa014c68ab44f654d8a88b2ea81436a26ef
md5=779cfaad6fc4413fa5b4d5a17e5e9ceb
cksum=634397699
upstream_url=https://files.pythonhosted.org/packages/source/c/conway-polynomials/conway-polynomials-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/conway_polynomials/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| $(PYTHON)
| $(PYTHON_TOOLCHAIN) $(PYTHON)

----------
All lines of this file are ignored except the first.
1 change: 1 addition & 0 deletions build/pkgs/conway_polynomials/distros/gentoo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev-python/conway-polynomials
1 change: 1 addition & 0 deletions build/pkgs/conway_polynomials/install-requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conway-polynomials >=0.7
2 changes: 1 addition & 1 deletion build/pkgs/conway_polynomials/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5
0.7
3 changes: 3 additions & 0 deletions build/pkgs/conway_polynomials/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SAGE_SPKG_CONFIGURE([conway_polynomials], [
SAGE_PYTHON_PACKAGE_CHECK([conway_polynomials])
])
2 changes: 1 addition & 1 deletion build/pkgs/conway_polynomials/spkg-install.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exec python3 spkg-install.py
cd src && sdh_pip_install .
20 changes: 0 additions & 20 deletions build/pkgs/conway_polynomials/spkg-install.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/sage/databases/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
EXAMPLES::

sage: ConwayPolynomials()
Frank Luebeck's database of Conway polynomials
Frank Lübeck's database of Conway polynomials

sage: CremonaDatabase()
Cremona's database of elliptic curves with conductor...
Expand Down
24 changes: 7 additions & 17 deletions src/sage/databases/conway.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
r"""
Frank Luebeck's tables of Conway polynomials over finite fields
Frank Lübeck's tables of Conway polynomials over finite fields
"""
# ****************************************************************************
#
Expand All @@ -15,12 +15,6 @@
# https://www.gnu.org/licenses/
# ****************************************************************************
from collections.abc import Mapping
import pickle

from sage.features.databases import DatabaseConwayPolynomials

_conwaydict = None


class DictInMapping(Mapping):
def __init__(self, dict):
Expand Down Expand Up @@ -95,14 +89,10 @@ def __init__(self):

sage: c = ConwayPolynomials()
sage: c
Frank Luebeck's database of Conway polynomials
Frank Lübeck's database of Conway polynomials
"""
global _conwaydict
if _conwaydict is None:
_CONWAYDATA = DatabaseConwayPolynomials().absolute_filename()
with open(_CONWAYDATA, 'rb') as f:
_conwaydict = pickle.load(f)
self._store = _conwaydict
import conway_polynomials
self._store = conway_polynomials.database()

def __repr__(self):
"""
Expand All @@ -112,9 +102,9 @@ def __repr__(self):

sage: c = ConwayPolynomials()
sage: c.__repr__()
"Frank Luebeck's database of Conway polynomials"
"Frank Lübeck's database of Conway polynomials"
"""
return "Frank Luebeck's database of Conway polynomials"
return "Frank Lübeck's database of Conway polynomials"

def __getitem__(self, key):
"""
Expand Down Expand Up @@ -152,7 +142,7 @@ def __len__(self):

sage: c = ConwayPolynomials()
sage: len(c)
35352
35357
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh? What happened there?

Copy link
Member

Choose a reason for hiding this comment

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

I was asking myself the same question.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Inflation.

The old package came with preprocessed data that would have been harder to diff against the upstream list for changes. I think it was just a tiny bit out-of-date. Here's the diff:

103a104
> [2,110,[1,1,1,0,0,0,1,0,0,0,1,1,0,1,1,0,0,1,0,0,1,0,0,0,0,1,1,0,1,1,0,0,0,1,0,1,1,1,0,1,0,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,0,1,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]],
219a221
> [3,52,[2,0,1,1,1,2,0,1,2,0,0,0,1,0,2,0,2,2,2,1,2,0,2,1,0,0,2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]],
222a225,226
> [3,56,[2,2,0,0,0,1,0,2,0,0,0,0,2,1,1,0,0,1,2,2,2,2,0,2,2,1,2,2,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]],
> [3,57,[1,1,2,2,2,2,1,0,1,1,0,2,1,0,2,2,2,1,0,2,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]],
229a234
> [3,72,[2,2,0,2,1,1,1,2,1,0,2,1,2,1,0,1,0,2,1,1,0,2,1,2,1,2,0,2,0,1,1,1,2,2,1,0,2,2,1,1,0,0,1,2,0,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]],

Copy link
Member

Choose a reason for hiding this comment

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

I see. Does upstream update the list "often"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea. There's no change history on the site, but the new package ships the upstream file unmodified so at least we can git diff it in the future.

Copy link
Member

Choose a reason for hiding this comment

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

Shipping upstream file unmodified sounds very good to me. I think it is ready.

try:
return self._len
Expand Down
1 change: 0 additions & 1 deletion src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
SAGE_PKG_CONFIG_PATH = var("SAGE_PKG_CONFIG_PATH")

# installation directories for various packages
CONWAY_POLYNOMIALS_DATA_DIR = var("CONWAY_POLYNOMIALS_DATA_DIR", join(SAGE_SHARE, "conway_polynomials"))
GRAPHS_DATA_DIR = var("GRAPHS_DATA_DIR", join(SAGE_SHARE, "graphs"))
ELLCURVE_DATA_DIR = var("ELLCURVE_DATA_DIR", join(SAGE_SHARE, "ellcurves"))
POLYTOPE_DATA_DIR = var("POLYTOPE_DATA_DIR", join(SAGE_SHARE, "reflexive_polytopes"))
Expand Down
13 changes: 4 additions & 9 deletions src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ def __repr__(self):
sage: GapPackage("grape") # indirect doctest
Feature('gap_package_grape')

sage: from sage.features.databases import DatabaseConwayPolynomials
sage: DatabaseConwayPolynomials() # indirect doctest
Feature('conway_polynomials': Frank Luebeck's database of Conway polynomials)
"""
description = f'{self.name!r}: {self.description}' if self.description else f'{self.name!r}'
return f'Feature({description})'
Expand Down Expand Up @@ -342,11 +339,10 @@ def is_standard(self):

EXAMPLES::

sage: from sage.features.databases import DatabaseCremona, DatabaseConwayPolynomials
sage: from sage.features.databases import DatabaseCremona
sage: DatabaseCremona().is_standard()
False
sage: DatabaseConwayPolynomials().is_standard()
True

"""
if self.name.startswith('sage.'):
return True
Expand All @@ -358,11 +354,10 @@ def is_optional(self):

EXAMPLES::

sage: from sage.features.databases import DatabaseCremona, DatabaseConwayPolynomials
sage: from sage.features.databases import DatabaseCremona
sage: DatabaseCremona().is_optional()
True
sage: DatabaseConwayPolynomials().is_optional()
False

"""
return self._spkg_type() == 'optional'

Expand Down
36 changes: 1 addition & 35 deletions src/sage/features/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,10 @@

from . import StaticFile, PythonModule
from sage.env import (
CONWAY_POLYNOMIALS_DATA_DIR,
CREMONA_MINI_DATA_DIR, CREMONA_LARGE_DATA_DIR,
POLYTOPE_DATA_DIR)


class DatabaseConwayPolynomials(StaticFile):
Copy link
Contributor

@mkoeppe mkoeppe Nov 25, 2023

Choose a reason for hiding this comment

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

Normally I think we would say that this is API and should not be removed without deprecation. But I don't object to removing it

r"""
A :class:`~sage.features.Feature` which describes the presence of :ref:`Frank Luebeck's
database of Conway polynomials <spkg_conway_polynomials>`.

EXAMPLES::

sage: from sage.features.databases import DatabaseConwayPolynomials
sage: DatabaseConwayPolynomials().is_present()
FeatureTestResult('conway_polynomials', True)
"""

def __init__(self):
r"""
TESTS::

sage: from sage.features.databases import DatabaseConwayPolynomials
sage: isinstance(DatabaseConwayPolynomials(), DatabaseConwayPolynomials)
True
"""
if CONWAY_POLYNOMIALS_DATA_DIR:
search_path = [CONWAY_POLYNOMIALS_DATA_DIR]
else:
search_path = []
StaticFile.__init__(self, "conway_polynomials",
filename='conway_polynomials.p',
search_path=search_path,
spkg='conway_polynomials',
description="Frank Luebeck's database of Conway polynomials",
type='standard')


CREMONA_DATA_DIRS = set([CREMONA_MINI_DATA_DIR, CREMONA_LARGE_DATA_DIR])


Expand Down Expand Up @@ -197,8 +164,7 @@ def __init__(self, name='polytopes_db', dirname='Full3D'):


def all_features():
return [DatabaseConwayPolynomials(),
DatabaseCremona(), DatabaseCremona('cremona_mini'),
return [DatabaseCremona(), DatabaseCremona('cremona_mini'),
DatabaseJones(),
DatabaseKnotInfo(),
DatabaseCubicHecke(),
Expand Down
1 change: 1 addition & 0 deletions src/setup.cfg.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ install_requires =
SPKG_INSTALL_REQUIRES_sage_conf
SPKG_INSTALL_REQUIRES_six
dnl From build/pkgs/sagelib/dependencies
SPKG_INSTALL_REQUIRES_conway_polynomials
SPKG_INSTALL_REQUIRES_cypari
SPKG_INSTALL_REQUIRES_cysignals
SPKG_INSTALL_REQUIRES_cython
Expand Down