Skip to content

Commit 61d0fcc

Browse files
author
Release Manager
committed
sagemathgh-39012: Remove SAGE_DB from public interface <!-- ^ 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". --> The `SAGE_DB` variable was never used (as far as I can see). So we remove it (as part of the process of migrating the databases to separate python packages). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] 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#39012 Reported by: Tobias Diez Reviewer(s): Michael Orlitzky
2 parents 93b7829 + 4af9d0e commit 61d0fcc

File tree

4 files changed

+30
-21
lines changed

4 files changed

+30
-21
lines changed

src/sage/graphs/isgci.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -852,13 +852,8 @@ def update_db(self):
852852
853853
This method downloads the ISGCI database from the website
854854
`GraphClasses.org <http://www.graphclasses.org/>`_. It then extracts the
855-
zip file and parses its XML content.
856-
857-
Depending on the credentials of the user running Sage when this command
858-
is run, one attempt is made at saving the result in Sage's directory so
859-
that all users can benefit from it. If the credentials are not
860-
sufficient, the XML file are saved instead in the user's directory (in
861-
the SAGE_DB folder).
855+
zip file and parses its XML content. The XML file is saved in the directory
856+
controlled by the :class:`DatabaseGraphs` class (usually, ``$HOME/.sage/db``).
862857
863858
EXAMPLES::
864859

src/sage/misc/all.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
exists, forall, is_iterator,
1010
random_sublist,
1111
pad_zeros,
12-
SAGE_DB,
13-
newton_method_sizes, compose,
12+
newton_method_sizes, compose,
1413
nest)
1514

1615
from sage.misc.banner import version

src/sage/misc/misc.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050
from sage.env import DOT_SAGE, HOSTNAME
5151
from sage.misc.lazy_import import lazy_import
5252

53-
lazy_import("sage.combinat.subset", ["powerset", "subsets", "uniq"],
54-
deprecation=35564)
53+
lazy_import("sage.combinat.subset", ["powerset", "subsets", "uniq"], deprecation=35564)
5554

56-
lazy_import("sage.misc.timing", ["cputime", "GlobalCputime", "walltime"],
57-
deprecation=35816)
55+
lazy_import(
56+
"sage.misc.timing", ["cputime", "GlobalCputime", "walltime"], deprecation=35816
57+
)
5858

5959
LOCAL_IDENTIFIER = '%s.%s' % (HOSTNAME, os.getpid())
6060

@@ -169,9 +169,6 @@ def try_read(obj, splitlines=False):
169169
return data
170170

171171

172-
SAGE_DB = os.path.join(DOT_SAGE, 'db')
173-
os.makedirs(SAGE_DB, exist_ok=True)
174-
175172
try:
176173
# Create the matplotlib config directory.
177174
os.makedirs(os.environ["MPLCONFIGDIR"], exist_ok=True)
@@ -351,6 +348,7 @@ def nest(f, n, x):
351348
x
352349
"""
353350
from sage.rings.integer import Integer
351+
354352
n = Integer(n)
355353

356354
if n < 0:
@@ -365,6 +363,7 @@ def nest(f, n, x):
365363
# The A \ b operator
366364
#################################################################
367365

366+
368367
class BackslashOperator:
369368
r"""
370369
Implement Matlab-style backslash operator for solving systems::
@@ -389,6 +388,7 @@ class BackslashOperator:
389388
sage: preparse("A^3 \\ b")
390389
'A**Integer(3) * BackslashOperator() * b'
391390
"""
391+
392392
def __rmul__(self, left):
393393
"""
394394
EXAMPLES::
@@ -412,6 +412,7 @@ def __rmul__(self, left):
412412
True
413413
"""
414414
from sage.misc.superseded import deprecation
415+
415416
deprecation(36394, 'the backslash operator has been deprecated')
416417
self.left = left
417418
return self
@@ -443,6 +444,7 @@ def __mul__(self, right):
443444
(0.0, 0.5, 1.0, 1.5, 2.0)
444445
"""
445446
from sage.misc.superseded import deprecation
447+
446448
deprecation(36394, 'the backslash operator has been deprecated')
447449
return self.left._backslash_(right)
448450

@@ -531,6 +533,7 @@ def random_sublist(X, s):
531533
True
532534
"""
533535
import sage.misc.prandom as random
536+
534537
return [a for a in X if random.random() <= s]
535538

536539

@@ -603,6 +606,7 @@ def some_tuples(elements, repeat, bound, max_samples=None):
603606
"""
604607
if max_samples is None:
605608
from itertools import islice, product
609+
606610
P = elements if repeat is None else product(elements, repeat=repeat)
607611
return islice(P, int(bound))
608612
else:
@@ -612,6 +616,7 @@ def some_tuples(elements, repeat, bound, max_samples=None):
612616
N = n if repeat is None else n**repeat
613617
if N <= max_samples:
614618
from itertools import product
619+
615620
return elements if repeat is None else product(elements, repeat=repeat)
616621
return _some_tuples_sampling(elements, repeat, max_samples, n)
617622

@@ -638,6 +643,7 @@ def _some_tuples_sampling(elements, repeat, max_samples, n):
638643
"""
639644
from sage.rings.integer import Integer
640645
import sage.misc.prandom as random
646+
641647
N = n if repeat is None else n**repeat
642648
# We sample on range(N) and create tuples manually since we don't want to create the list of all possible tuples in memory
643649
for a in random.sample(range(N), max_samples):
@@ -651,6 +657,7 @@ def _some_tuples_sampling(elements, repeat, max_samples, n):
651657
# Misc.
652658
#################################################################
653659

660+
654661
def exists(S, P):
655662
"""
656663
If S contains an element x such that P(x) is ``True``, this function
@@ -836,8 +843,8 @@ def in_quote():
836843
# which is the case if the previous character isn't
837844
# a backslash, or it is but both previous characters
838845
# are backslashes.
839-
if line[i - 1: i] != '\\' or line[i - 2: i] == '\\\\':
840-
if line[i: i + 3] in ['"""', "'''"]:
846+
if line[i - 1 : i] != '\\' or line[i - 2 : i] == '\\\\':
847+
if line[i : i + 3] in ['"""', "'''"]:
841848
if not in_quote():
842849
in_triple_quote = True
843850
elif in_triple_quote:
@@ -899,6 +906,7 @@ def get_main_globals():
899906
module.
900907
"""
901908
import sys
909+
902910
depth = 0
903911
while True:
904912
G = sys._getframe(depth).f_globals
@@ -957,8 +965,9 @@ def inject_variable(name, value, warn=True):
957965
# also from functions in various modules.
958966
G = get_main_globals()
959967
if name in G and warn:
960-
warnings.warn("redefining global value `%s`" % name,
961-
RuntimeWarning, stacklevel=2)
968+
warnings.warn(
969+
"redefining global value `%s`" % name, RuntimeWarning, stacklevel=2
970+
)
962971
G[name] = value
963972

964973

@@ -1013,12 +1022,14 @@ def run_once(func):
10131022
sage: foo(False)
10141023
sage: foo(True)
10151024
"""
1025+
10161026
@functools.wraps(func)
10171027
def wrapper(*args, **kwargs):
10181028
if not wrapper.has_run:
10191029
result = func(*args, **kwargs)
10201030
wrapper.has_run = True
10211031
return result
1032+
10221033
wrapper.has_run = False
10231034
return wrapper
10241035

src/sage/misc/persist.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ comp = zlib
4444
comp_other = bz2
4545

4646
from sage.misc.sage_unittest import TestSuite
47-
47+
from sage.misc.superseded import deprecation
4848

4949
# We define two global dictionaries `already_pickled` and
5050
# `already_unpickled`, which are intended to help you to implement
@@ -1230,6 +1230,8 @@ def db(name):
12301230
12311231
The database directory is ``$HOME/.sage/db``.
12321232
"""
1233+
deprecation(39012, "Directly use pickle/unpickle instead of db/db_save.")
1234+
12331235
from sage.misc.misc import SAGE_DB
12341236
return load('%s/%s' % (SAGE_DB, name))
12351237
@@ -1240,6 +1242,8 @@ def db_save(x, name=None):
12401242
12411243
The database directory is ``$HOME/.sage/db``.
12421244
"""
1245+
deprecation(39012, "Directly use pickle/unpickle instead of db/db_save.")
1246+
12431247
try:
12441248
x.db(name)
12451249
except AttributeError:

0 commit comments

Comments
 (0)