pace-neutrons / pace-python

Python module of the PACE inelastic neutron data analysis suite of programs.
GNU General Public License v3.0
3 stars 4 forks source link

Bugs!!!! #2

Closed mducle closed 3 years ago

mducle commented 3 years ago

MatlabProxyObject has doubled properties and methods! (culprit could be __dir__()) - sort it out!!! - Use list(set(...))?

Instead of print to get inline images use getframe and imwrite...?

Better handling of numeric type conversions: kk = kk.set_fun(disp2sqwfun, [euobj.horace_disp, [scalefac], intrinsic_fwhm]); where scalefac is integer in Python

mducle commented 3 years ago

The following would change to using getframe / imwrite but it does not solve the problem which is that set(0, 'DefaultFigureVisible', 'off') doesn't seem to have the desired effect.

diff --git a/pace_python/IPythonMagics.py b/pace_python/IPythonMagics.py
index 17a2cb3..0040834 100644
--- a/pace_python/IPythonMagics.py
+++ b/pace_python/IPythonMagics.py
@@ -47,8 +47,7 @@ def showPlot(self=None, result=None):
     with TemporaryDirectory() as tmpdir:
         try:
             interface.call('eval',
-                ["arrayfun(@(h, i) print(h, sprintf('{}/%i', i), '-d{}', '-r{}'),get(0, 'children'), (1:{})')"
-                                   .format('/'.join(tmpdir.split(os.sep)), format, resolution, nfig)],
+                [f"arrayfun(@(h, i) imwrite(frame2im(getframe(h)), sprintf(\"{'/'.join(tmpdir.split(os.sep))}/%i.{format}\", i), 'XResolution', {resolution}, 'YResolution', {resolution}), get(0, 'children'), (1:{nfig})')"],
                 nargout=0)
             interface.call('eval', ["arrayfun(@(h) close(h), get(0, 'children'))"], nargout=0)
             for fname in sorted(os.listdir(tmpdir)):