AureumChaos / LEAP

A general purpose Library for Evolutionary Algorithms in Python.
Academic Free License v3.0
83 stars 19 forks source link

Add a parameter to CSV Probes for printing numpy arrays as single line json #260

Closed lukepmccombs closed 1 year ago

lukepmccombs commented 1 year ago

Fixes #250

Adds a new parameter to FitnessStatsCSVProbe and AttributesCSVProbe which when True (default) prints numpy arrays as the single line json of their python list representation. This allows any numpy array variables to be restored fairly easily with json.loads.

Of possible note with this solution is that it may result in two different list formats existing in the csv output: python lists printed with the default and numpy lists printed with json. In some limited testing (not unit tests) the default print for nested float lists is json compliant, but this may not be universally true for all types and structures.