Skip to content

Commit

Permalink
Trac #25665: Don't use installed_packages() for threejs URL
Browse files Browse the repository at this point in the history
Since Sage 8.3.beta3, running the command
{{{
show(sphere(), viewer='threejs', online=True)
}}}
in a Jupyter notebook displays nothing. It was fine in Sage <=
8.3.beta2.
Note that the option `online=True` is required by tools like
http://nbviewer.jupyter.org/ and [https://cocalc.com CoCalc].

It seems that the issue is due to the following change introduced in
#25040 (which has been merged in Sage 8.3.beta3):
{{{
sage: installed_packages()['threejs']
'r80.p0'
}}}
while in Sage <= 8.3.beta2, one has
{{{
sage: installed_packages()['threejs']
'r80'
}}}
Indeed the value of `installed_packages()['threejs']` is used to form
the url in lines 749-750 of
`src/sage/repl/rich_output/display_manager.py`

URL: https://trac.sagemath.org/25665
Reported by: egourgoulhon
Ticket author(s): Frédéric Chapoton
Reviewer(s): Eric Gourgoulhon
  • Loading branch information
Release Manager authored and vbraun committed Jul 4, 2018
2 parents 28aa801 + 867e1ff commit 07c3add
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/sage/repl/rich_output/display_manager.py
Expand Up @@ -24,14 +24,14 @@
The Sage display manager using the doctest backend
"""

#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2015 Volker Braun <vbraun.name@gmail.com>
#
# 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.
# http://www.gnu.org/licenses/
#*****************************************************************************
# ****************************************************************************


import warnings
Expand All @@ -57,6 +57,7 @@ class DisplayException(Exception):
"""
pass


class OutputTypeException(DisplayException):
"""
Wrong Output container.
Expand All @@ -78,6 +79,7 @@ class OutputTypeException(DisplayException):
"""
pass


class RichReprWarning(UserWarning):
"""
Warning that is throws if a call to ``_rich_repr_`` fails.
Expand Down Expand Up @@ -540,7 +542,7 @@ def _preferred_text_formatter(self, obj, plain_text=None, **kwds):
if type(plain_text) is not OutputPlainText:
raise OutputTypeException('backend returned wrong output type, require PlainText')
return plain_text
out = self._backend.plain_text_formatter(obj, **kwds)
out = self._backend.plain_text_formatter(obj, **kwds)
if type(out) is not OutputPlainText:
raise OutputTypeException('backend returned wrong output type, require PlainText')
return out
Expand Down Expand Up @@ -744,7 +746,7 @@ def threejs_scripts(self, online):
"""
if online:
from sage.misc.package import installed_packages
version = installed_packages()['threejs']
version = installed_packages()['threejs'].split('.')[0]
return """
<script src="https://cdn.rawgit.com/mrdoob/three.js/{0}/build/three.min.js"></script>
<script src="https://cdn.rawgit.com/mrdoob/three.js/{0}/examples/js/controls/OrbitControls.js"></script>
Expand Down Expand Up @@ -834,6 +836,4 @@ def display_immediately(self, obj, **rich_repr_kwds):
self._backend.display_immediately(plain_text, rich_output)




get_display_manager = DisplayManager.get_instance

0 comments on commit 07c3add

Please sign in to comment.