Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f51f29a
34185: initial version
soehms Jul 15, 2022
3071dbc
34185: correction according to review
soehms Jul 18, 2022
faacd11
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Jul 24, 2022
b4b562c
34185: take care of joined features
soehms Jul 25, 2022
ddd7ada
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Aug 3, 2022
70abb3f
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Aug 4, 2022
442fca6
Merge branch 'join_feature_texfile_with_pdflatex_34282' into hide_fea…
soehms Aug 5, 2022
f39836a
Merge branch 'circular_import_matrix_space_34283' into hide_features_…
soehms Aug 5, 2022
0ec6d46
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Aug 7, 2022
f463ac7
Merge branch 'join_feature_texfile_with_pdflatex_34282' into hide_fea…
soehms Aug 9, 2022
ebbd4a4
Merge branch 'circular_import_matrix_space_34283' into hide_features_…
soehms Aug 9, 2022
6912c1c
34185: fix doctest failure + pep8 fixes
soehms Aug 9, 2022
2e11970
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Sep 3, 2022
d676f79
Merge branch 'u/soehms/join_feature_texfile_with_pdflatex_34282' of t…
soehms Sep 6, 2022
187bdcf
34185: fix typos
soehms Sep 6, 2022
2a582f4
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Sep 30, 2022
f69396c
Merge branch 'u/soehms/hide_features_34185' of https://github.com/sag…
soehms May 22, 2023
b695c04
34185: fix RST issues
soehms May 22, 2023
c3da4d8
34185 / 35668: fixes according to review
soehms May 25, 2023
6dff841
Merge branch 'sagemath:develop' into hide_features_34185
soehms May 25, 2023
72d9da7
Merge branch 'develop' into hide_features_34185
soehms May 30, 2023
7d58d67
Merge branch 'develop' into hide_features_34185
soehms Jun 11, 2023
560228c
Merge branch 'sagemath:develop' into hide_features_34185
soehms Jun 11, 2023
d0ccd37
Merge branch 'hide_features_34185' of github.com:soehms/sage into hid…
soehms Jun 19, 2023
97eaac9
35668: pycodestyle fix
soehms Jun 19, 2023
3103888
Merge branch 'hide_features_34185' into feature_standard_optional_static
mkoeppe Jun 23, 2023
1fcdde3
sage.features: Declare type='standard' explicitly, check against SPKG…
mkoeppe Jun 23, 2023
fd8a32d
Terminology change
mkoeppe Jun 24, 2023
ad202ba
Add 'type=standard' in more places
mkoeppe Jun 24, 2023
62ad2a3
Add 'type=standard' in more places that use pplpy
mkoeppe Jun 25, 2023
98a8664
src/sage/features/cddlib.py: Add type='standard'
mkoeppe Jun 25, 2023
4eddb7c
src/sage/misc/package.py: Do not fail if SAGE_PKGS is not set
mkoeppe Jun 25, 2023
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
Prev Previous commit
Next Next commit
34185: take care of joined features
  • Loading branch information
soehms committed Jul 25, 2022
commit b4b562c56206b83fb23f259e6cba4f75304b43b9
16 changes: 13 additions & 3 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ def run(self):
sage: with open(filename, 'w') as f:
....: f.write(test_hide)
....: f.close()
402
729
sage: DF = DocTestDefaults(hide='buckygen,all')
sage: DC = DocTestController(DF, [filename])
sage: DC.run()
Expand All @@ -1360,7 +1360,7 @@ def run(self):
Features to be detected: ...
Doctesting 1 file.
sage -t ....py
[2 tests, ... s]
[4 tests, ... s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand All @@ -1378,7 +1378,7 @@ def run(self):
Features to be detected: ...
Doctesting 1 file.
sage -t ....py
[2 tests, ... s]
[4 tests, ... s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -1438,6 +1438,9 @@ def run(self):
if f.is_present():
f.hide()
self.options.hidden_features.add(f)
for g in f.joined_features():
if g.name in self.options.optional:
self.options.optional.discard(g.name)

for o in self.options.disabled_optional:
try:
Expand Down Expand Up @@ -1561,5 +1564,12 @@ def stringify(x):
...
sage: len(list(graphs.fusenes(2))) # optional benzene
1
sage: from sage.matrix.matrix_space import get_matrix_class
sage: get_matrix_class(GF(25,'x'), 4, 4, False, 'meataxe')
Failed lazy import:
sage.matrix.matrix_gfpn_dense is not available.
...
sage: get_matrix_class(GF(25,'x'), 4, 4, False, 'meataxe') # optional meataxe
<class 'sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense'>
{}
""".format('r"""', '"""')
22 changes: 22 additions & 0 deletions src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,28 @@ def resolution(self):
self._cache_resolution = "\n".join(lines)
return self._cache_resolution

def joined_features(self):
r"""
Return a list of features joined with ``self``.

OUTPUT:

A (possibly empty) list of instances of :class:`Feature`.

EXAMPLES::

sage: from sage.features.graphviz import Graphviz
sage: Graphviz().joined_features()
[Feature('dot'), Feature('neato'), Feature('twopi')]
sage: from sage.features.interfaces import Mathematica
sage: Mathematica().joined_features()
[]
"""
from sage.features.join_feature import JoinFeature
if isinstance(self, JoinFeature):
return self._features
return []

def is_standard(self):
r"""
Return whether this feature corresponds to a standard SPKG.
Expand Down
47 changes: 47 additions & 0 deletions src/sage/features/join_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,50 @@ def is_functional(self):
if not test:
return test
return FeatureTestResult(self, True)

def hide(self):
r"""
Hide this feature and all its joined features.

EXAMPLES:

sage: from sage.features.sagemath import sage__groups
sage: f = sage__groups()
sage: f.hide()
sage: f._features[0].is_present()
FeatureTestResult('sage.groups.perm_gps.permgroup', False)

sage: f.require()
Traceback (most recent call last):
...
FeatureNotPresentError: sage.groups is not available.
Feature `sage.groups` is hidden.
Use method `unhide` to make it available again.
"""
for f in self._features:
f.hide()
super(JoinFeature, self).hide()

def unhide(self):
r"""
Hide this feature and all its joined features.

EXAMPLES:

sage: from sage.features.sagemath import sage__groups
sage: f = sage__groups()
sage: f.hide()
sage: f.is_present()
FeatureTestResult('sage.groups', False)
sage: f._features[0].is_present()
FeatureTestResult('sage.groups.perm_gps.permgroup', False)

sage: f.unhide()
sage: f.is_present() # optional sage.groups
FeatureTestResult('sage.groups', True)
sage: f._features[0].is_present() # optional sage.groups
FeatureTestResult('sage.groups.perm_gps.permgroup', True)
"""
for f in self._features:
f.unhide()
super(JoinFeature, self).unhide()
7 changes: 6 additions & 1 deletion src/sage/misc/lazy_import.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,18 @@ cdef class LazyImport():
if finish_startup_called:
warn(f"Option ``at_startup=True`` for lazy import {self._name} not needed anymore")

feature = self._feature
try:
self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name)
except ImportError as e:
if self._feature:
if feature:
raise FeatureNotPresentError(self._feature, reason=f'Importing {self._name} failed: {e}')
raise

if feature:
# for the case that the feature is hidden
feature.require()

name = self._as_name
if self._deprecation is not None:
from sage.misc.superseded import deprecation_cython as deprecation
Expand Down