Ask Your Question
0

Problem with Cremona database (Update: wrong Boolean output in general)

asked 2017-06-08 04:59:32 +0100

Thrash gravatar image

updated 2018-10-08 00:42:09 +0100

tmonteil gravatar image

Hello, I'm struggling with the following problem, but don't have any idea how to fix it. At least the mini Cremona database is installed, I think. Could you please help me?

 sage: EllipticCurve("37b2")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-74529bf514dc> in <module>()
----> 1 EllipticCurve("37b2")

/usr/share/sage/source/sage/structure/factory.pyx in sage.structure.factory.UniqueFactory.__call__ (/build/sagemath/src/sage-7.6/src/src/build/cythonized/sage/structure/factory.c:1856)()
    360             False
    361         """
--> 362         key, kwds = self.create_key_and_extra_args(*args, **kwds)
    363         version = self.get_version(sage_version)
    364         return self.get_object(version, key, kwds)

/usr/lib/python2.7/site-packages/sage/schemes/elliptic_curves/constructor.pyc in create_key_and_extra_args(self, x, y, j, minimal_twist, **kwds)
    407             # Interpret x as a Cremona or LMFDB label.
    408             from sage.databases.cremona import CremonaDatabase
--> 409             x, data = CremonaDatabase().coefficients_and_data(x)
    410             # User-provided keywords may override database entries.
    411             data.update(kwds)

/usr/lib/python2.7/site-packages/sage/databases/cremona.pyc in CremonaDatabase(name, mini, set_global)
   1688             _db = MiniCremonaDatabase(name)
   1689         else:
-> 1690             _db = LargeCremonaDatabase(name)
   1691         return _db
   1692     if mini:

/usr/lib/python2.7/site-packages/sage/databases/cremona.pyc in __init__(self, name, read_only, build)
   1432         if not os.path.isfile(db_path):
   1433             raise ValueError("Desired database (='%s') does not "%self.name \
-> 1434                     + "exist")
   1435         SQLDatabase.__init__(self, db_path, read_only=read_only)
   1436         if self.get_skeleton() != _cremonaSkeleton:

ValueError: Desired database (='cremona') does not exist
edit retag flag offensive close merge delete

Comments

In my case, it works, on the box...

dan@k7:~$ uname -a
Linux k7 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

i am getting...

sage: version()
'SageMath version 7.5.1, Release Date: 2017-01-15'
sage: E = EllipticCurve( '37b2' )
sage: E
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 1873*x - 31833 over Rational Field
sage: E.discriminant()
37

And on the other laptop:

sage: version()
'SageMath version 7.6, Release Date: 2017-03-25'
sage: E = EllipticCurve( '37b2' )
sage: E
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 1873*x - 31833 over Rational Field

I'll look closer at the db_path in my case. Maybe inserting a print of it in the py file makes simpler to see if it is there...

dan_fulea gravatar imagedan_fulea ( 2017-06-08 11:38:58 +0100 )edit
1

I can not reproduce your problem either. Could you please give us some informations so that someone can try to reproduce your problem:

  • which version of Sage did you use ?
  • which OS ?
  • did you install Sage from the binaries, and which ones ?
  • did you compile Sage yourself ?
tmonteil gravatar imagetmonteil ( 2017-06-08 12:24:30 +0100 )edit
  • SageMath version 7.6, Release Date: 2017-03-25
  • Manjaro 17.0.1 Gellivara
  • from the official Arch repository (via pacman)
  • No, after installing I just started using it.
Thrash gravatar imageThrash ( 2017-06-08 14:38:05 +0100 )edit

OK, it is a distro issue, we do not have contact with archlinux packagers (while some Debian and Gentoo devs are on the sage-devel mailing-list), you should contact them directly.

tmonteil gravatar imagetmonteil ( 2017-06-08 14:48:24 +0100 )edit

Thanks! Is it an issue with Manjaro or with the official Arch package itself?

Thrash gravatar imageThrash ( 2017-06-08 15:28:14 +0100 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2017-06-09 20:53:43 +0100

dan_fulea gravatar image

updated 2017-06-09 21:09:38 +0100

I'll post it as an answer, no longer as a comment, since the truncation of comments was misleading for me. (And there is not too much place in the comments.) I think we are now close to a final answer.

First of all, i could reproduce the error in the following way.

After changing the code in

/usr/lib/python2.7/site-packages/sage/databases/cremona.py

so that i have at least a print,

def __init__(self, name, read_only=True, build=False):
    """
    Initialize the database.

    TESTS::

        sage: c = CremonaDatabase('cremona')    # optional - database_cremona_ellcurve
        sage: c.name                            # optional - database_cremona_ellcurve
        'cremona'
    """
    self.name = name
    name = name.replace(' ','_')
    db_path = os.path.join(SAGE_SHARE, 'cremona', name+'.db')
    print ( "self.name=%s SAGE_SHARE=%s db_path=%s"
            % ( self.name, SAGE_SHARE, db_path ) )    # !!! inserted print

and after asking for it...

sage: import traceback
sage: try:    c = CremonaDatabase('cremona') 
....: except: traceback.print_exc()
....:

was getting my print,

self.name=cremona SAGE_SHARE=/usr/share db_path=/usr/share/cremona/cremona.db

and the traceback information.

Traceback (most recent call last):
  File "<ipython-input-7-1da8056b7fa9>", line 1, in <module>
    try:    c = CremonaDatabase('cremona')
  File "/usr/lib/python2.7/site-packages/sage/databases/cremona.py", line 1695, in CremonaDatabase
    return LargeCremonaDatabase(name)
  File "/usr/lib/python2.7/site-packages/sage/databases/cremona.py", line 1435, in __init__
    + "exist")
ValueError: Desired database (='cremona') does not exist

The desired database is the cremona database, and there is no fallback scenario in this class to look for cremona_mini in case of failure.

In my install of sagemath this problem does not appear while asking for E = EllipticCurve( '37b2' ).

But at least it appeared after trying the above c = CremonaDatabase('cremona') .

As seen above, the code is explicitly searching for cremona.db in the right folder. On my machine there is only:

# ls -l /usr/share/cremona/
total 8196
-rw-r--r-- 1 root root 8392704 22. Okt 2016  cremona_mini.db

(Copying or linking the existing mini did not work for me to pass without a traceback, a _cremonaSkeleton mismatch shows in these both cases because the next check block...)

At any rate, this is the reason for the error, the cremona_mini.db is not enough. (For the specific installation on manjaro, which very probably also has only the cremona mini database in the asked folder.)

(Maybe purging, and reinstalling... This would be my first try in the second day. The more important question is why the code is routed to the above line of code in Your installation... )

edit flag offensive delete link more
0

answered 2017-06-10 19:56:09 +0100

Thrash gravatar image

updated 2017-06-12 19:58:10 +0100

For update see below

Thank you! I've found a partial solution which is more a bypass than a solution. One can set the mini database manually.

sage: CremonaDatabase?
Signature:      CremonaDatabase(name=None, mini=None, set_global=None)
Docstring:     
   Initializes the Cremona database with name "name". If "name" is
   "None" it instead initializes large Cremona database (named
   ‘cremona’), if available or default mini Cremona database (named
   ‘cremona mini’).

   If the Cremona database in question is in the format of the mini
   database, you must set "mini=True", otherwise it must be set to
   "False".

   If you would like other components of Sage to use this database,
   mark "set_global=True".
Init docstring: x.__init__(…) initializes x; see help(type(x)) for signature
File:           /usr/lib/python2.7/site-packages/sage/databases/cremona.py
Type:           function

Then I did this and it has been working since then:

sage: CremonaDatabase(name='cremona mini',set_global=True)
Cremona's database of elliptic curves with conductor at most 9999
sage: EllipticCurve("37b2")
Elliptic Curve defined by y^2 + y = x^3 + x^2 - 1873*x - 31833 over Rational Field

It seems that only the mini database is installed on my system (same ls output as yours). But by default, Sage wanted to load the large one, right? But that contradicts this sentence:

If name is None it instead initializes large Cremona database (named ‘cremona’), if available or default mini Cremona database (named ‘cremona mini’).

The code at lines 1675–1679 of the file cremona.py is the following:

if set_global and name is None:
    if is_package_installed('database_cremona_ellcurve'):
        name = 'cremona'
    else:
        name = 'cremona mini'

So far, the code fits with the doc description above, but running is_package_installed('database_cremona_ellcurve') results in True. Something must be wrong with the Boolean output value because it refers to the large database, I think. That would be logical. But either I don't have the large one installed on my system, or if so, then it is in a wrong directory.

However, my bypass method only works as long as I don't exit the Sage terminal. Each time I exit and log in again, I have to perform these steps again.

Update:

I know what the real problem is. That's not a problem with the Cremona database, but with this Boolean output which is always True.

sage: is_package_installed('abc')
True
sage: is_package_installed('abwadwe')
True
sage: is_package_installed('abwadweafer')
True

Could anyone with Arch please test this Boolean variable?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-06-08 04:59:32 +0100

Seen: 392 times

Last updated: Jun 12 '17