mantidproject / mslice

Source code for Mantid MSlice
http://mantidproject.github.io/mslice
1 stars 2 forks source link

Command line interface not working properly #933

Closed SilkeSchomann closed 11 months ago

SilkeSchomann commented 12 months ago

Describe the bug Error messages appear when using the command line interface of MSlice.

To Reproduce Run the example script from https://developer.mantidproject.org/Testing/DirectInelastic/MSliceTestGuide.html#the-command-line-interface

MialLewis commented 12 months ago

I see: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

This issue is the same as: https://stackoverflow.com/questions/37400974/error-unicode-error-unicodeescape-codec-cant-decode-bytes-in-position-2-3.

It's essentially due to the backslashes in the string causing \u in \users to be interpreted as the start of a Unicode code point . It can be fixed by doing:

import mslice.cli as mc
ws = mc.Load("C:\\Users\wym92549\Downloads\mslice data\MAR21335_Ei60meV.nxs")

or

import mslice.cli as mc
ws = mc.Load(r"C:\Users\wym92549\Downloads\mslice data\MAR21335_Ei60meV.nxs")
MialLewis commented 12 months ago

Hopefully this change won't effect too many legacy scripts. Our generate script functionality uses / as the separator so is not effected.

EDIT: I've just seen another issue, and it appears it sometimes uses backslash in generated scripts.

SilkeSchomann commented 12 months ago

The problem occurs in this line mc.PlotCut(wsq), not in Load.

SilkeSchomann commented 12 months ago

TypeError: cannot unpack non-iterable NoneType object File "", line 10, in File "C:\Users\eoc57742\AppData\Local\mambaforge\envs\mantidtest\Library\scripts\ExternalInterfaces\mslice\cli_mslice_commands.py", line 282, in PlotCut cli_cut_plotter_presenter.plot_cut_from_workspace(workspace, intensity_range=intensity_range, File "C:\Users\eoc57742\AppData\Local\mambaforge\envs\mantidtest\Library\scripts\ExternalInterfaces\mslice\presenters\cut_plotter_presenter.py", line 155, in plot_cut_from_workspace lines = plot_cut_impl(workspace, intensity_range=intensity_range, plot_over=plot_over) File "C:\Users\eoc57742\AppData\Local\mambaforge\envs\mantidtest\Library\scripts\ExternalInterfaces\mslice\plotting\globalfiguremanager.py", line 574, in wrapper return_value = function(*args, kwargs) File "C:\Users\eoc57742\AppData\Local\mambaforge\envs\mantidtest\Library\scripts\ExternalInterfaces\mslice\views\cut_plotter.py", line 42, in plot_cut_impl ax.errorbar(workspace, 'o-', label=legend, picker=PICKER_TOL_PTS, File "C:\Users\eoc57742\AppData\Local\mambaforge\envs\mantidtest\Library\scripts\ExternalInterfaces\mslice\cli__init__.py", line 28, in errorbar return errorbar(self, *args, *kwargs) File "C:\Users\eoc57742\AppData\Local\mambaforge\envs\mantidtest\Library\scripts\ExternalInterfaces\mslice\plotting\globalfiguremanager.py", line 574, in wrapper return_value = function(args, kwargs) File "C:\Users\eoc57742\AppData\Local\mambaforge\envs\mantidtest\Library\scripts\ExternalInterfaces\mslice\cli\plotfunctions.py", line 40, in errorbar intensity_min, intensity_max = kwargs.pop('intensity_range', (None, None))