Ask Your Question
1

"mesh=" juypter vs. -notebook

asked 2016-11-29 17:42:58 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Perhaps I should send this to some devel or support group ?
Starting command line:

sage -notebook

Comes up and executes:

var('x,y')
plot3d(sin(x-y)*y*cos(x),(x,-3,3),(y,-3,3), mesh=True)

Correctly.

Whereas:

sage -n jupyter

Fails with miscellaneous assertion type errors. sagemath 7.3 in both cases.
A friend also point out the option "color='yellow' " also fails in jupyter.


Edit (slelievre): I confirm I can observe this also with Sage 7.4. Here is the error message I get:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-3-44b2387a145a> in <module>()
----> 1 plot3d(sin(x-y)*y*cos(x),(x,-Integer(3),Integer(3)),(y,-Integer(3),Integer(3)), mesh=True)

/opt/s/sage-7.4/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in __call__(self, result)
    244             self.start_displayhook()
    245             self.write_output_prompt()
--> 246             format_dict, md_dict = self.compute_format_data(result)
    247             self.update_user_ns(result)
    248             self.fill_exec_result(result)

/opt/s/sage-7.4/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in compute_format_data(self, result)
    148 
    149         """
--> 150         return self.shell.display_formatter.format(result)
    151 
    152     # This can be set to True by the write_output_prompt method in a subclass

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/formatter.pyc in format(self, obj, include, exclude)
    158         # First, use Sage rich output if there is any
    159         PLAIN_TEXT = u'text/plain'
--> 160         sage_format, sage_metadata = self.dm.displayhook(obj)
    161         assert PLAIN_TEXT in sage_format, 'plain text is always present'
    162         if sage_format.keys() != [PLAIN_TEXT]:

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/rich_output/display_manager.pyc in displayhook(self, obj)
    764         self._backend.set_underscore_variable(obj)
    765         plain_text, rich_output = self._rich_output_formatter(obj, dict())
--> 766         return self._backend.displayhook(plain_text, rich_output)
    767 
    768     def display_immediately(self, obj, **rich_repr_kwds):

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_ipython.pyc in displayhook(self, plain_text, rich_output)
    525             from sage.repl.display.jsmol_iframe import JSMolHtml
    526             jsmol = JSMolHtml(rich_output, height=500)
--> 527             return ({u'text/html':  jsmol.iframe(),
    528                      u'text/plain': plain_text.text.get_unicode(),
    529             }, {})            

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/jsmol_iframe.py in iframe(self)
    259             </iframe>
    260         """
--> 261         escaped_inner_html = self.inner_html().replace('"', '&quot;')
    262         iframe = IFRAME_TEMPLATE.format(
    263             script=self.js_script(),

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/jsmol_iframe.py in inner_html(self)
    235         """
    236         return INNER_HTML_TEMPLATE.format(
--> 237             script=self.js_script(),
    238             width=self._width,
    239             height=self._height,

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/jsmol_iframe.py in js_script(self)
    193         """
    194         script = [r"["]
--> 195         for line in self.script().splitlines():
    196             script += [r"  '{0}',".format(line)]
    197         script += [r"].join('\n');"]

/opt/s/sage-7.4/src/sage/misc/cachefunc.pyx in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (/opt/s/sage-7.4/src/build/cythonized/sage/misc/cachefunc.c:12716)()
   2399         if self.cache is None:
   2400             f = self.f
-> 2401             self.cache = f(self._instance)
   2402         return self.cache
   2403 

/opt/s/sage-7.4/local/lib/python2.7/site-packages/sage/repl/display/jsmol_iframe.py in script(self)
    156                     command, obj, meshfile = line.split(' ', 3)
    157                     assert command == 'pmesh'
--> 158                     assert meshfile.startswith('"') and meshfile.endswith('"\n')
    159                     meshfile = meshfile[1:-2]    # strip quotes
    160                     script += [

AssertionError:
edit retag flag offensive close merge delete

Comments

Ignoring some installation differences and using strace: the "sage -notebook" path is ".../repl/rich_output/" whereas "sage -n jupyter" , like above and on my installation, is ".../repl/display/" although I haven't run strace in this case and just looked at the debug output. If it would help, I can make some straces available in dropbox; they are tediously long though. Or some way to control the /repl/xxx routing/option ??

rrogers gravatar imagerrogers ( 2016-11-30 08:22:43 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-02-15 17:42:54 -0500

slelievre gravatar image

updated 2018-02-15 17:46:05 -0500

In a recent Sage, this seems to be working fine.

In the Sage REPL:

sage: version()
'SageMath version 8.2.beta4, Release Date: 2018-01-27'

sage: plot3d(lambda x, y: sin(x-y)*y*cos(x), (-3, 3), (-3, 3), mesh=True)
Launched jmol viewer for Graphics3d Object

In the Jupyter notebook, it launches jsmol instead, but the meshed plot3d displays fine.

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: 2016-11-29 17:42:58 -0500

Seen: 197 times

Last updated: Feb 15