Closed alessio-greco closed 4 years ago
Indeed dump
also returns the value, in addition to saving to file. It's a bit redundant in many cases, but I think it's easy to just not use it.
The value was available anyway so it seemed it might be useful to return in some cases. Probably not so much in compressed cases, but in the interest of consistency...
I didn't really consider interactive use, mostly scripts... I guess in interactive use it would show up as output, which might be annoying?
A "return_string" flag that make dump return the string might be useful when one wants both "dump" and "dumps" at the same time, but generally i guess one would use dumps for the string,
At times, the string value may be pretty heavy (in general) and long (for interactive use)
In the current implementation, the string is being constructed anyway (dump
calls dumps
) so it doesn't cost much extra to return it.
(A streaming version would be interesting, but this library is a wrapper around the standard json library, so that seems a long shot...)
Using
json.dump(shap_values, "shap_values-json.gz",compression=9)
returnsIt still saves the data, but is this the normal behaviour?