Open tturocy opened 1 year ago
As an initial concrete proposal, we suggest we'll follow the conventions that pandas
uses in its I/O functions. Specifically, one can look at read_csv
(https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html) and to_csv
(https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html).
Specifically, we will have the following:
pygambit
. (The current functions are all part of the Game
class.)read_*
in pandas
.We will have the following functions (please add a note if there are others that are missing)
read_efg
- reads an .efg file formatread_nfg
- reads an .nfg file formatread_gbt
- reads a .gbt file (XML files produced by the GUI)read_agg
- reads an action-graph games file formatGame.to_efg
- writes an .efg fileGame.to_nfg
- writes an .nfg fileGame.to_gbt
- writes a .gbt fileGame.to_html
- writes out HTML tablesGame.to_latex
- currently the sgame
format supported by Game.write
.The function Game.parse_game
will be deprecated, as its functionality can be replicated by wrapping such a string in an io.StringIO
object and then passing it to the appropriate read_*
function as above, which functions will now accept file-like objects.
Game
objects currently just have generic.read_game
and.write_game
operations, where.write_game
takes aformat
parameter to determine the output format, while.read_game
tries various formats until one is successful.Looking at e.g.
pandas
, it seems it would be better to have functions that explicitly read and write the different supported formats.