-
-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #32614: Features and optional tags for sage modules provided by …
…separate distributions ... so that we can start writing `# optional - sage.symbolic` and similar. We use it in #32432 ('''sagemath-polyhedra''') to skip doctests that depend on `sage.graphs`, `sage.combinat`, `sage.rings.number_field` etc. URL: https://trac.sagemath.org/32614 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): John Palmieri, Travis Scrimshaw
- Loading branch information
Showing
8 changed files
with
136 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from . import PythonModule | ||
from .join_feature import JoinFeature | ||
|
||
|
||
class Mcqd(JoinFeature): | ||
|
||
def __init__(self): | ||
# Currently part of sagemath_standard, conditionally built. | ||
# Will be changed to spkg='sagemath_mcqd' later | ||
JoinFeature.__init__(self, 'mcqd', | ||
[PythonModule('sage.graphs.mcqd', spkg='mcqd')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from . import PythonModule | ||
from .join_feature import JoinFeature | ||
|
||
|
||
class Meataxe(JoinFeature): | ||
|
||
def __init__(self): | ||
# Currently part of sagemath_standard, conditionally built. | ||
# Will be changed to spkg='sagemath_meataxe' later | ||
JoinFeature.__init__(self, 'meataxe', | ||
[PythonModule('sage.matrix.matrix_gfpn_dense', spkg='meataxe')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
r""" | ||
Check for SageMath Python modules | ||
""" | ||
from . import PythonModule | ||
from .join_feature import JoinFeature | ||
|
||
|
||
class sage__combinat(JoinFeature): | ||
|
||
def __init__(self): | ||
# sage.combinat will be a namespace package. | ||
# Testing whether sage.combinat itself can be imported is meaningless. | ||
# Hence, we test a Python module within the package. | ||
JoinFeature.__init__(self, 'sage.combinat', | ||
[PythonModule('sage.combinat.combinations')]) | ||
|
||
|
||
class sage__graphs(JoinFeature): | ||
|
||
def __init__(self): | ||
JoinFeature.__init__(self, 'sage.graphs', | ||
[PythonModule('sage.graphs.graph')]) | ||
|
||
|
||
class sage__plot(JoinFeature): | ||
|
||
def __init__(self): | ||
JoinFeature.__init__(self, 'sage.plot', | ||
[PythonModule('sage.plot.plot')]) | ||
|
||
|
||
class sage__rings__number_field(JoinFeature): | ||
|
||
def __init__(self): | ||
JoinFeature.__init__(self, 'sage.rings.number_field', | ||
[PythonModule('sage.rings.number_field.number_field_element')]) | ||
|
||
|
||
class sage__rings__real_double(PythonModule): | ||
|
||
def __init__(self): | ||
PythonModule.__init__(self, 'sage.rings.real_double') | ||
|
||
|
||
class sage__symbolic(JoinFeature): | ||
|
||
def __init__(self): | ||
JoinFeature.__init__(self, 'sage.symbolic', | ||
[PythonModule('sage.symbolic.expression')], | ||
spkg="sagemath_symbolics") | ||
|
||
|
||
def sage_features(): | ||
""" | ||
Return features corresponding to parts of the Sage library. | ||
These tags are named after Python packages/modules (e.g., :mod:`~sage.symbolic`), | ||
not distribution packages (``sagemath-symbolics``). | ||
This design is motivated by a separation of concerns: The author of a module that depends | ||
on some functionality provided by a Python module usually already knows the | ||
name of the Python module, so we do not want to force the author to also | ||
know about the distribution package that provides the Python module. | ||
Instead, we associate distribution packages to Python modules in | ||
:mod:`sage.features.sagemath` via the ``spkg`` parameter of :class:`Feature`. | ||
EXAMPLES:: | ||
sage: from sage.features.sagemath import sage_features | ||
sage: list(sage_features()) # random | ||
[Feature('sage.graphs'), | ||
Feature('sage.plot'), | ||
Feature('sage.rings.number_field'), | ||
Feature('sage.rings.real_double')] | ||
""" | ||
for feature in [sage__combinat(), | ||
sage__graphs(), | ||
sage__plot(), | ||
sage__rings__number_field(), | ||
sage__rings__real_double(), | ||
sage__symbolic()]: | ||
if feature.is_present(): | ||
yield feature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from . import PythonModule | ||
from .join_feature import JoinFeature | ||
|
||
|
||
class Tdlib(JoinFeature): | ||
|
||
def __init__(self): | ||
# Currently part of sagemath_standard, conditionally built. | ||
# Will be changed to spkg='sagemath_tdlib' later | ||
JoinFeature.__init__(self, 'tdlib', | ||
[PythonModule('sage.graphs.graph_decompositions.tdlib', spkg='tdlib')]) |