Ticket #8422 (closed: wontfix)

Opened 7 years ago

Last modified 5 years ago

IPython doc pop-up doesn't work correctly with default enum values

Reported by: Arturs Bekasovs Owned by: Russell Taylor
Priority: major Milestone: Release 3.1
Component: Python Keywords:
Cc: Blocked By:
Blocking: Tester: Owen Arnold

Description

Python function plotMD has the following argument with its default value:

def plotMD([..], normalization = mantid.api.MDNormalization.VolumeNormalization, [..]):

mantid.api.MDNormalization is exported from C++ in the following way:

boost::python::enum_<Mantid::API::MDNormalization>("MDNormalization")
          .value("NoNormalization", Mantid::API::NoNormalization)
          .value("VolumeNormalization", Mantid::API::VolumeNormalization)
          .value("NumEventsNormalization", Mantid::API::NumEventsNormalization);

However, this thing doesn't seem to work correctly with IPython. When we type "plotMD(" instead of usual documentation pop-up, we get the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/IPython/qt/console/frontend_widget.py", line 775, in _document_contents_change
    self._call_tip()
  File "/usr/local/lib/python2.7/dist-packages/IPython/qt/console/frontend_widget.py", line 686, in _call_tip
    msg_id = self.kernel_client.object_info(name)
  File "/usr/local/lib/python2.7/dist-packages/IPython/kernel/inprocess/channels.py", line 116, in object_info
    self._dispatch_to_kernel(msg)
  File "/usr/local/lib/python2.7/dist-packages/IPython/kernel/inprocess/channels.py", line 146, in _dispatch_to_kernel
    idents, reply_msg = self.client.session.recv(stream, copy=False)
  File "/usr/local/lib/python2.7/dist-packages/IPython/kernel/zmq/session.py", line 696, in recv
    raise e
simplejson.decoder.JSONDecodeError: Expecting object: line 1 column 273 (char 273)

There is a work-around which seems to solve the problem:

DEFAULT_MD_NORMALIZATION = int(mantid.api.MDNormalization.VolumeNormalization)
def plotMD([..], normalization = DEFAULT_MD_NORMALIZATION, [..]):

Doing the same without explicit int() conversion doesn't do the trick.

Change History

comment:1 Changed 7 years ago by Russell Taylor

  • Status changed from new to verify
  • Resolution set to wontfix

I see that this specific problem was fixed in #4166. The error itself is deep within the IPython code (actually the exception is generated in zmq, which is a dependency of IPython) and I don't think there's anything we can do at our level other than fix issues we find in the manner given above (and I'm not aware of any other places that need fixing).

I've reported this back to the IPython people in case they want to look into it.

comment:2 Changed 7 years ago by Russell Taylor

This error has now been solved in IPython. We'll pick that up if we ever upgrade.

comment:3 Changed 7 years ago by Owen Arnold

  • Status changed from verify to verifying
  • Tester set to Owen Arnold

comment:4 Changed 7 years ago by Owen Arnold

  • Status changed from verifying to closed

comment:5 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 9266

Note: See TracTickets for help on using tickets.