xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
MIT License
138 stars 68 forks source link

Error Loading Pre-edge Fit Result #540

Open LJRH opened 2 days ago

LJRH commented 2 days ago

Version: Larix Larch 0.9.81 (RHEL 7.9) Module: larix / pre_edge() Dataset: HERFD-XANES Fe K-edge

Description: Clicking the 'Load Fit Result' to load a previously generated model does not work. Error given is:

image

Traceback (most recent call last):
  File "/dls/science/users/<me>/.conda/envs/xraylarch/lib/python3.12/site-packages/larch/wxxas/prepeak_panel.py", line 1341, in onLoadFitResult
    rfile = FileOpen(self, "Load Saved Pre-edge Model",
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dls/science/users/<me>/.conda/envs/xraylarch/lib/python3.12/site-packages/larch/wxlib/__init__.py", line 72, in FileOpen
    result = wxu.FileOpen(parent, message, **kws)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dls/science/users/<me>/.conda/envs/xraylarch/lib/python3.12/site-packages/wxutils/dialogs.py", line 46, in FileOpen
    dlg = wx.FileDialog(parent, message=message, wildcard=wildcard,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: FileDialog(): argument 'defaultFile' has unexpected type 'NoneType'

I tried following the error back through the code, but it wasn't entirely obvious where the issue was. It would be good to be able to load models from datasets from older versions of larix/xasviewer.

Best Wishes, Luke

LJRH commented 1 day ago

Downgraded to version 0.9.80, where the 'Load Fit Result' is still working.

newville commented 1 day ago

@LJRH Thanks -- ack. I'll fix that. Sorry for the trouble.

maurov commented 1 day ago

@newville I have also observed this misbehavior for 0.9.81 under Linux.

Furthermore, I cannot load a session file saved with 0.9.81. When reading back the session file, Larch sees the session file like as an ASCII file.

This doesn't happen under Windows, nor for 0.9.80 under Linux/Windows

I have no idea from where it comes from. If you know how to fix it, it would be great news.

Thanks, Mauro

On Thu, Nov 21, 2024, 4:16 PM Matt Newville @.***> wrote:

@LJRH https://github.com/LJRH Thanks -- ack. I'll fix that. Sorry for the trouble.

— Reply to this email directly, view it on GitHub https://github.com/xraypy/xraylarch/issues/540#issuecomment-2491508305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEFEDWKGO7EECQZDPWHGBT2BX2NLAVCNFSM6AAAAABSFADADKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJRGUYDQMZQGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

newville commented 10 hours ago

@LJRH @maurov I think I have this fixed in the master branch (and also #541). I can save and reload Session files (on macOS). I'll try on Linux and Windows later today.

Also: sorry for the trouble. I've been trying to "normalize" my codes to be more consistent and have fewer copied bit of code, and also to better use pathlib.Path.... and this has introduced some bugs -- and GUIs are hard to test (and Larch does not have nearly enough testing anyway).

FWIW, I think we should aim for next version (and switch to date-based version tags) around Dec 1, merging #536, making sure #532 and related issues on load/save are fixed, and doing a lot of testing of the loading/saving data steps.