Skip to content

Commit

Permalink
gh-35230: sage.rings.function_field: Modularization fixes
Browse files Browse the repository at this point in the history
    
<!-- ^^^^^
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"
-->
### 📚 Description
- We split out `.derivations` (which uses modules) from `.maps` (which
doesn't).
- We separate the implementation of rational function fields (which do
not need Singular for Gröbner basis calculations) from the
implementation of more complicated function fields (which do).
- We move some imports into methods.

This is for modularization purposes:
- Part of #29705



<!-- Describe your changes here in detail -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If it resolves an open issue, please link to the issue here. For
example "Closes #1337" -->

### 📝 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! -->

- [x] I have made sure that the title is self-explanatory and the
description concisely explains the PR.
- [ ] I have linked an issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies
<!-- List all open pull requests that this PR logically depends on -->
<!--
- #xyz: short description why this is a dependency
- #abc: ...
-->
- Depends on #35237 (for the feature `sage.libs.singular`)
- Depends on #35119 (to preempt merge conflicts)
    
URL: #35230
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee, Matthias Köppe
  • Loading branch information
Release Manager committed Mar 31, 2023
2 parents 3b8f20e + db2f8dd commit c1a0323
Show file tree
Hide file tree
Showing 76 changed files with 13,401 additions and 12,509 deletions.
9 changes: 9 additions & 0 deletions src/doc/en/developer/packaging_sage_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,15 @@ doctests that depend on :class:`sage.symbolic.ring.SymbolicRing` for integration
testing. Hence, these doctests are marked ``# optional -
sage.symbolic``.

When defining new features for the purpose of doctest annotations, it may be a good
idea to hide implementation details from feature names. For example, all doctests that
use finite fields have to depend on PARI. However, we have defined a feature
:mod:`sage.rings.finite_rings` (which implies the presence of :mod:`sage.libs.pari`).
Annotating the doctests ``# optional - sage.rings.finite_rings`` expresses the
dependency in a clearer way than using ``# optional - sage.libs.pari``, and it
will be a smaller maintenance burden when implementation details change.


Testing the distribution in virtual environments with tox
---------------------------------------------------------

Expand Down
14 changes: 14 additions & 0 deletions src/doc/en/reference/function_fields/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,27 @@ algebraic closure of `\QQ`.
:maxdepth: 1

sage/rings/function_field/function_field
sage/rings/function_field/function_field_rational
sage/rings/function_field/function_field_polymod
sage/rings/function_field/element
sage/rings/function_field/element_rational
sage/rings/function_field/element_polymod
sage/rings/function_field/order
sage/rings/function_field/order_rational
sage/rings/function_field/order_basis
sage/rings/function_field/order_polymod
sage/rings/function_field/ideal
sage/rings/function_field/ideal_rational
sage/rings/function_field/ideal_polymod
sage/rings/function_field/place
sage/rings/function_field/place_rational
sage/rings/function_field/place_polymod
sage/rings/function_field/divisor
sage/rings/function_field/differential
sage/rings/function_field/valuation_ring
sage/rings/function_field/derivations
sage/rings/function_field/derivations_rational
sage/rings/function_field/derivations_polymod
sage/rings/function_field/maps
sage/rings/function_field/extensions
sage/rings/function_field/constructor
Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/reference/valuations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ More Details
sage/rings/valuation/mapped_valuation
sage/rings/valuation/scaled_valuation

sage/rings/function_field/function_field_valuation
sage/rings/function_field/valuation
sage/rings/padics/padic_valuation

.. include:: ../footer.txt
8 changes: 4 additions & 4 deletions src/sage/categories/function_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def _call_(self, x):
EXAMPLES::
sage: C = FunctionFields()
sage: K.<x>=FunctionField(QQ)
sage: K.<x> = FunctionField(QQ)
sage: C(K)
Rational function field in x over Rational Field
sage: Ky.<y> = K[]
sage: L = K.extension(y^2-x)
sage: C(L)
sage: L = K.extension(y^2 - x) # optional - sage.rings.function_field
sage: C(L) # optional - sage.rings.function_field
Function field in y defined by y^2 - x
sage: C(L.equation_order())
sage: C(L.equation_order()) # optional - sage.rings.function_field
Function field in y defined by y^2 - x
"""
try:
Expand Down
13 changes: 13 additions & 0 deletions src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@
As can be seen above, features try to produce helpful error messages.
"""

# *****************************************************************************
# Copyright (C) 2016 Julian Rüth
# 2018 Jeroen Demeyer
# 2018 Timo Kaufmann
# 2019-2022 Matthias Koeppe
# 2021 Kwankyu Lee
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

from __future__ import annotations

import os
Expand Down
9 changes: 9 additions & 0 deletions src/sage/features/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Enumeration of all defined features
"""

# *****************************************************************************
# Copyright (C) 2021 Matthias Koeppe
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

def all_features():
r"""
Return an iterable of all features.
Expand Down
13 changes: 12 additions & 1 deletion src/sage/features/bliss.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# -*- coding: utf-8 -*-
r"""
Features for testing the presence of ``bliss``
"""

# *****************************************************************************
# Copyright (C) 2016 Julian Rüth
# 2018 Jeroen Demeyer
# 2021 Matthias Koeppe
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

from . import CythonFeature, PythonModule
from .join_feature import JoinFeature

Expand Down
10 changes: 10 additions & 0 deletions src/sage/features/cddlib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
r"""
Feature for testing the presence of ``cddlib``
"""

# *****************************************************************************
# Copyright (C) 2022 Matthias Koeppe
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

from . import Executable


Expand Down
12 changes: 12 additions & 0 deletions src/sage/features/csdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
Feature for testing the presence of ``csdp``
"""

# *****************************************************************************
# Copyright (C) 2016 Julian Rüth
# 2018 Jeroen Demeyer
# 2019 David Coudert
# 2021 Matthias Koeppe
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

import os
import re
import subprocess
Expand Down
10 changes: 9 additions & 1 deletion src/sage/features/cython.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# -*- coding: utf-8 -*-
r"""
Features for testing the presence of ``cython``
"""

# *****************************************************************************
# Copyright (C) 2021 Matthias Koeppe
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

from . import CythonFeature


Expand Down
15 changes: 14 additions & 1 deletion src/sage/features/databases.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# -*- coding: utf-8 -*-
r"""
Features for testing the presence of various databases
"""

# *****************************************************************************
# Copyright (C) 2016 Julian Rüth
# 2018-2019 Jeroen Demeyer
# 2018 Timo Kaufmann
# 2020-2022 Matthias Koeppe
# 2020-2022 Sebastian Oehms
# 2021 Kwankyu Lee
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************


from . import StaticFile, PythonModule
from sage.env import (
Expand Down
1 change: 0 additions & 1 deletion src/sage/features/dvipng.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Feature for testing the presence of ``dvipng``
"""
Expand Down
3 changes: 1 addition & 2 deletions src/sage/features/ffmpeg.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
r"""
Feature for testing the presence of ``ffmpeg``
"""
# ****************************************************************************
# Copyright (C) 2018 Sebastien Labbe <[email protected]>
# Copyright (C) 2018-2022 Sebastien Labbe <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
44 changes: 42 additions & 2 deletions src/sage/features/gap.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# -*- coding: utf-8 -*-
r"""
Features for testing the presence of GAP packages
"""
# *****************************************************************************
# Copyright (C) 2016 Julian Rüth
# 2018 Jeroen Demeyer
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

from . import Feature, FeatureTestResult
from . import Feature, FeatureTestResult, PythonModule
from .join_feature import JoinFeature


class GapPackage(Feature):
Expand Down Expand Up @@ -48,3 +57,34 @@ def _is_present(self):
else:
return FeatureTestResult(self, False,
reason="`{command}` evaluated to `{presence}` in GAP.".format(command=command, presence=presence))


class sage__libs__gap(JoinFeature):
r"""
A :class:`sage.features.Feature` describing the presence of :mod:`sage.libs.gap`
(the library interface to GAP) and :mod:`sage.interfaces.gap` (the pexpect
interface to GAP). By design, we do not distinguish between these two, in order
to facilitate the conversion of code from the pexpect interface to the library
interface.
EXAMPLES::
sage: from sage.features.gap import sage__libs__gap
sage: sage__libs__gap().is_present() # optional - sage.libs.gap
FeatureTestResult('sage.libs.gap', True)
"""
def __init__(self):
r"""
TESTS::
sage: from sage.features.gap import sage__libs__gap
sage: isinstance(sage__libs__gap(), sage__libs__gap)
True
"""
JoinFeature.__init__(self, 'sage.libs.gap',
[PythonModule('sage.libs.gap.libgap'),
PythonModule('sage.interfaces.gap')])


def all_features():
return [sage__libs__gap()]
9 changes: 9 additions & 0 deletions src/sage/features/gfan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Features for testing the presence of ``gfan``
"""

# *****************************************************************************
# Copyright (C) 2022 Matthias Koeppe
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

from . import Executable


Expand Down
14 changes: 13 additions & 1 deletion src/sage/features/graph_generators.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# -*- coding: utf-8 -*-
r"""
Features for testing the presence of various graph generator programs
"""

# *****************************************************************************
# Copyright (C) 2016 Julian Rüth
# 2018 Jeroen Demeyer
# 2019 Frédéric Chapoton
# 2021 Matthias Koeppe
# 2021 Kwankyu Lee
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
# *****************************************************************************

import os
import subprocess

Expand Down
4 changes: 3 additions & 1 deletion src/sage/features/graphviz.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# -*- coding: utf-8 -*-
r"""
Features for testing the presence of ``graphviz``
"""

# ****************************************************************************
# Copyright (C) 2018 Sebastien Labbe <[email protected]>
# 2021 Matthias Koeppe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************

from . import Executable
from .join_feature import JoinFeature

Expand Down
11 changes: 11 additions & 0 deletions src/sage/features/igraph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
r"""
Check for igraph
"""

# ****************************************************************************
# Copyright (C) 2021 Matthias Koeppe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************

from . import PythonModule
from .join_feature import JoinFeature

Expand Down
4 changes: 2 additions & 2 deletions src/sage/features/imagemagick.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Feature for testing the presence of ``imagemagick``
Expand All @@ -7,8 +6,9 @@
``identify``, ``composite``, ``montage``, ``compare``, etc. could be also
checked in this module.
"""

# ****************************************************************************
# Copyright (C) 2018 Sebastien Labbe <[email protected]>
# Copyright (C) 2018-2022 Sebastien Labbe <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
11 changes: 11 additions & 0 deletions src/sage/features/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
r"""
Features for testing whether interpreter interfaces are functional
"""

# ****************************************************************************
# Copyright (C) 2021 Matthias Koeppe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************

import importlib

from . import Feature, FeatureTestResult, PythonModule
Expand Down
Loading

0 comments on commit c1a0323

Please sign in to comment.