Kappa-Dev / KappaTools

Tool suite for kappa models. Documentation and binaries can be found in the release section. Try it online at
http://kappalanguage.org/
GNU Lesser General Public License v3.0
108 stars 40 forks source link

abbreviated time print in snapshots #662

Closed hmedina closed 1 year ago

hmedina commented 1 year ago

Kappa formatted snapshots contain a print-out of the time, but is an abbreviated version. Is there a way of obtaining snapshots with the full time print-out? Ideally, something I can test against what is printed to the trace file (after serialization, both representations are strings).

feret commented 1 year ago

Dear @hmedina

I have put a proposition of fix in the branch fulltimestampinsnapshots. Could you check that this is implementing what you are asking ?

If so, how to proceed ?

I am open, let me know.

hmedina commented 1 year ago

Hi Jérôme! Yes, I think that works (but now I KaTIE has to update its printer...)

I believe the current behavior is to only print 4 decimals. I think expanding to print the full string representation is a negligible cost (only about 9 extra characters from what I'm seeing on my snapshots, which are 14K characters long), and so should be the default behavior.

That said, if brevity is desired on other use-cases (test suite?), perhaps a user-defined parameter, something like: %def: "snapshot-time-precision" int

Though at that point, I wonder if one could just specify a format via C-like strings (used also in Python): T=23.123456 %def: "snapshot-time-format" {f.4} -> "T0" "23.1235" %def: "snapshot-time-format" {e.2} -> "T0" "2.31e1"

feret commented 1 year ago

OK I merge then. If someone prefers more compact pretty-printing I will implement the parameterization. Before it was using the %g format (of C), now it is using the json float writing operator.

feret commented 1 year ago

Yes, it we add a parameter, C-like strings would be a good move.