Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
sage.features.sagemath.all_features: New
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Nov 11, 2021
1 parent 98b7db6 commit 0968f95
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions src/sage/features/sagemath.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __init__(self):
spkg="sagemath_symbolics")


def sage_features(logger=None):
def all_features():
"""
Return features corresponding to parts of the Sage library.
Expand All @@ -177,6 +177,36 @@ def sage_features(logger=None):
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 all_features
sage: list(all_features())
[Feature('sage.combinat'), ...]
"""
return [sage__combinat(),
sage__geometry__polyhedron(),
sage__graphs(),
sage__plot(),
sage__rings__number_field(),
sage__rings__real_double(),
sage__symbolic()]


def sage_features(logger=None):
"""
Return features corresponding to parts of the Sage library that are present.
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
Expand All @@ -186,13 +216,7 @@ def sage_features(logger=None):
Feature('sage.rings.number_field'),
Feature('sage.rings.real_double')]
"""
for feature in [sage__combinat(),
sage__geometry__polyhedron(),
sage__graphs(),
sage__plot(),
sage__rings__number_field(),
sage__rings__real_double(),
sage__symbolic()]:
for feature in all_features():
result = feature.is_present()
if logger:
logger.write(f'{result}, reason: {result.reason}\n')
Expand Down

0 comments on commit 0968f95

Please sign in to comment.