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

Commit

Permalink
Add description to features
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Oct 15, 2021
1 parent eeaa722 commit c872d69
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/sage/databases/cremona.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ def CremonaDatabase(name=None,mini=None,set_global=None):
Verify that :trac:`12341` has been resolved::
sage: c = CremonaDatabase('should not exist',mini=True)
sage: c = CremonaDatabase('should not exist', mini=True)
Traceback (most recent call last):
...
FeatureNotPresentError: database_should_not_exist_ellcurve is not available.
Expand Down
13 changes: 11 additions & 2 deletions src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class Feature(TrivialUniqueRepresentation):
- ``spkg`` -- (string) name of the SPKG providing the feature
- ``description`` -- (string) optional; plain English description of the feature
- ``url`` -- a URL for the upstream package providing the feature
Overwrite :meth:`_is_present` to add feature checks.
Expand All @@ -115,7 +117,7 @@ class Feature(TrivialUniqueRepresentation):
sage: GapPackage("grape") is GapPackage("grape")
True
"""
def __init__(self, name, spkg=None, url=None):
def __init__(self, name, spkg=None, url=None, description=None):
r"""
TESTS::
Expand All @@ -127,6 +129,8 @@ def __init__(self, name, spkg=None, url=None):
self.name = name
self.spkg = spkg
self.url = url
self.description = description

self._cache_is_present = None
self._cache_resolution = None

Expand Down Expand Up @@ -209,8 +213,13 @@ def __repr__(self):
sage: from sage.features.gap import GapPackage
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)
"""
return 'Feature({name!r})'.format(name=self.name)
description = f'{self.name!r}: {self.description}' if self.description else f'{self.name!r}'
return f'Feature({description})'

def resolution(self):
r"""
Expand Down
11 changes: 7 additions & 4 deletions src/sage/features/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self):
StaticFile.__init__(self, "conway_polynomials",
filename='conway_polynomials.p',
search_path=search_path,
spkg='conway_polynomials')
spkg='conway_polynomials',
description="Frank Luebeck's database of Conway polynomials")


CREMONA_DATA_DIRS = set([CREMONA_MINI_DATA_DIR, CREMONA_LARGE_DATA_DIR])
Expand All @@ -59,7 +60,7 @@ class DatabaseCremona(StaticFile):
sage: DatabaseCremona('cremona_mini').is_present()
FeatureTestResult('database_cremona_mini_ellcurve', True)
sage: DatabaseCremona().is_present() # optional: database_cremona_ellcurve
FeatureTestResult("database_cremona_ellcurve", True)
FeatureTestResult('database_cremona_ellcurve', True)
"""
def __init__(self, name="cremona", spkg="database_cremona_ellcurve"):
r"""
Expand All @@ -73,7 +74,8 @@ def __init__(self, name="cremona", spkg="database_cremona_ellcurve"):
filename='{}.db'.format(name.replace(' ', '_')),
search_path=CREMONA_DATA_DIRS,
spkg=spkg,
url="https://github.com/JohnCremona/ecdata")
url="https://github.com/JohnCremona/ecdata",
description="Cremona's database of elliptic curves")


class DatabaseJones(StaticFile):
Expand All @@ -96,7 +98,8 @@ def __init__(self):
"""
StaticFile.__init__(self, "database_jones_numfield",
filename='jones/jones.sobj',
spkg="database_jones_numfield")
spkg="database_jones_numfield",
description="John Jones's tables of number fields")


class DatabaseKnotInfo(PythonModule):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/features/join_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class JoinFeature(Feature):
sage: F.is_present()
FeatureTestResult('xxyyyy', False)
"""
def __init__(self, name, features, spkg=None, url=None):
def __init__(self, name, features, spkg=None, url=None, description=None):
"""
TESTS:
Expand All @@ -46,7 +46,7 @@ def __init__(self, name, features, spkg=None, url=None):
raise ValueError('given features have more than one url; provide url argument')
elif len(urls) == 1:
url = next(iter(urls))
super().__init__(name, spkg=spkg, url=url)
super().__init__(name, spkg=spkg, url=url, description=description)
self._features = features

def _is_present(self):
Expand Down
3 changes: 2 additions & 1 deletion src/sage/features/latte.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ def __init__(self):
True
"""
JoinFeature.__init__(self, "latte_int",
(Latte_count(), Latte_integrate()))
(Latte_count(), Latte_integrate()),
description="LattE")

0 comments on commit c872d69

Please sign in to comment.