Minor suggestion for lmfit

16 views
Skip to first unread message

Laurence Lurio

unread,
Jul 28, 2025, 10:19:33 AMJul 28
to lmfi...@googlegroups.com

Hi Matt,

I was wondering if you'd consider a small change to how lmfit loads results from JSON. Currently, load_modelresult() requires a filename or file-like object. If it could also accept a raw JSON string, that would make it easier to store model results alongside other data in a single JSON file, and then re-read just the relevant portion as needed.

I assume one could work around this by writing the string to a temporary file and reading it back, but it seems like a cleaner solution would be to support strings directly — perhaps via an additional function like ModelResult.from_json_string() or an overload in load_modelresult().

Thanks for considering it!

Larry Lurio


Jeremy DeJournett

unread,
Jul 28, 2025, 11:18:22 AMJul 28
to lmfi...@googlegroups.com
Is there a reason you cannot wrap it in a StringIO?

--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lmfit-py/CAK4HuLE1sBHjj3NAR3EvrErmiKuJMyump0YFke-WLgPPCXf_%2Bg%40mail.gmail.com.

Matt Newville

unread,
Jul 28, 2025, 12:25:16 PMJul 28
to lmfi...@googlegroups.com
Hi Larry, Jeremy, 

I think having load_modelresult() accept a string or file-like object is a fine idea.  Will do.



--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lmfit-py/CAK4HuLE1sBHjj3NAR3EvrErmiKuJMyump0YFke-WLgPPCXf_%2Bg%40mail.gmail.com.


--
--Matt Newville <newville at cars.uchicago.edu630-327-7411
Reply all
Reply to author
Forward
0 new messages