forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sagemathgh-38810: Introduce negated optional tag
<!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> motivated by sagemath#38764 (comment) fixes sagemath#38764 (comment) example: ```sage sage: SloaneEncyclopedia[60843] # optional - sloane_database [1, 6, 21, 107, 47176870] sage: SloaneEncyclopedia[60843] # optional - !sloane_database Traceback (most recent call last): ... OSError: The Sloane Encyclopedia database must be installed. Use e.g. 'SloaneEncyclopedia.install()' to download and install it. ``` along the way, we - define `sloane_database` feature (I wonder why it was missing) - fix `SloaneEncyclopedia` with the code by @sheerluck: https://github.c om/sheerluck)sagemath#34655 (comment) 1418189098 - fix the problem of `solve()` for rubiks cube of silently choosing the gap algorithm even when an algorithm is explicitly specified. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38810 Reported by: Kwankyu Lee Reviewer(s):
- Loading branch information
Showing
7 changed files
with
171 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# sage_setup: distribution = sagemath-environment | ||
r""" | ||
Check for ``dot2tex`` | ||
""" | ||
|
||
# ***************************************************************************** | ||
# Copyright (C) 2024 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 PythonModule | ||
|
||
|
||
class dot2tex(PythonModule): | ||
r""" | ||
A :class:`sage.features.Feature` describing the presence of :ref:`dot2tex <spkg_dot2tex>`. | ||
dot2tex is provided by an optional package in the Sage distribution. | ||
EXAMPLES:: | ||
sage: from sage.features.dot2tex import dot2tex | ||
sage: dot2tex().is_present() # optional - dot2tex | ||
FeatureTestResult('dot2tex', True) | ||
""" | ||
def __init__(self): | ||
r""" | ||
TESTS:: | ||
sage: from sage.features.dot2tex import dot2tex | ||
sage: isinstance(dot2tex(), dot2tex) | ||
True | ||
""" | ||
PythonModule.__init__(self, 'dot2tex', spkg='dot2tex') | ||
|
||
|
||
def all_features(): | ||
return [dot2tex()] |
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,59 @@ | ||
# sage_setup: distribution = sagemath-environment | ||
r""" | ||
Feature for testing the presence of Sloane Online Encyclopedia of Integer Sequences | ||
""" | ||
|
||
# **************************************************************************** | ||
# Copyright (C) 2024 Kwankyu Lee <[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 | ||
# 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 | ||
|
||
|
||
class SloaneOEIS(Feature): | ||
r""" | ||
A :class:`~sage.features.Feature` which describes the presence of | ||
the Sloane Online Encyclopedia of Integer Sequences. | ||
EXAMPLES:: | ||
sage: from sage.features.sloane_database import SloaneOEIS | ||
sage: bool(SloaneOEIS().is_present()) # optional - sloane_database | ||
True | ||
""" | ||
def __init__(self): | ||
r""" | ||
TESTS:: | ||
sage: from sage.features.sloane_database import SloaneOEIS | ||
sage: isinstance(SloaneOEIS(), SloaneOEIS) | ||
True | ||
""" | ||
Feature.__init__(self, name='sloane_database', | ||
description='Sloane Online Encyclopedia of Integer Sequences') | ||
|
||
def _is_present(self): | ||
r""" | ||
Return whether the database is available. | ||
EXAMPLES:: | ||
sage: from sage.features.sloane_database import SloaneOEIS | ||
sage: bool(SloaneOEIS().is_present()) # optional - !sloane_database | ||
False | ||
""" | ||
try: | ||
from sage.databases.sloane import SloaneEncyclopedia | ||
except ImportError: | ||
return False | ||
return SloaneEncyclopedia.is_installed() | ||
|
||
|
||
def all_features(): | ||
return [SloaneOEIS()] |
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