gambitproject / gambit

Gambit: The package for computation in game theory
http://www.gambit-project.org
GNU General Public License v2.0
406 stars 151 forks source link

ENH: Revise Python API for loading/saving games #357

Open tturocy opened 1 year ago

tturocy commented 1 year ago

Game objects currently just have generic .read_game and .write_game operations, where .write_game takes a format 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.

tturocy commented 4 months 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:

We will have the following functions (please add a note if there are others that are missing)

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.